Readouble

Livewire v3 wire:show

wire:show

Livewire の wire:show ディレクティブを使用すると、式の評価結果に基づいて要素を簡単に表示/非表示にできます。Livewire's wire:show directive makes it easy to show and hide elements based on the result of an expression.

wire:show ディレクティブは、Blade での @if の使用とは異なり、要素を DOM から完全に削除するのではなく、CSS (display: none) を使用して要素の表示/非表示を切り替えます。これは、要素がページに残るものの非表示になることを意味し、サーバへのラウンドトリップを必要とせずに、よりスムーズなトランジションを実現します。The wire:show directive is different than using @if in Blade in that it toggles an element's visibility using CSS (display: none) rather than removing the element from the DOM entirely. This means the element remains in the page but is hidden, allowing for smoother transitions without requiring a server round-trip.

基本的な使用法Basic usage

wire:show を使用して「Create Post」モーダルを切り替える実用的な例を次に示します。Here's a practical example of using wire:show to toggle a "Create Post" modal:

use Livewire\Component;
use App\Models\Post;

class CreatePost extends Component
{
    public $showModal = false;

    public $content = '';

    public function save()
    {
        Post::create(['content' => $this->content]);

        $this->reset('content');

        $this->showModal = false;
    }
}
<div>
    <button x-on:click="$wire.showModal = true">New Post</button>

    <div wire:show="showModal">
        <form wire:submit="save">
            <textarea wire:model="content"></textarea>

            <button type="submit">Save Post</button>
        </form>
    </div>
</div>

「Create New Post」ボタンをクリックすると、サーバへのラウンドトリップなしでモーダルが表示されます。投稿を正常に保存すると、モーダルが非表示になり、フォームがリセットされます。When the "Create New Post" button is clicked, the modal appears without a server roundtrip. After successfully saving the post, the modal is hidden and the form is reset.

トランジションの使用Using transitions

wire:show を Alpine.js のトランジションと組み合わせることで、スムーズな表示/非表示アニメーションを作成できます。 wire:show は CSS の display プロパティのみを切り替えるため、Alpine の x-transition ディレクティブは完全に機能します。You can combine wire:show with Alpine.js transitions to create smooth show/hide animations. Since wire:show only toggles the CSS display property, Alpine's x-transition directives work perfectly with it:

<div>
    <button x-on:click="$wire.showModal = true">New Post</button>

    <div wire:show="showModal" x-transition.duration.500ms>
        <form wire:submit="save">
            <textarea wire:model="content"></textarea>
            <button type="submit">Save Post</button>
        </form>
    </div>
</div>

上記の Alpine.js のトランジションクラスは、モーダルの表示/非表示時にフェードとスケールのエフェクトを作成します。The Alpine.js transition classes above will create a fade and scale effect when the modal shows and hides.

View the full x-transition documentation →

章選択

パッケージ

設定

バージョン変更
linkv3 linkv2
明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

テストコード表示
両コード表示
Pestのみ表示
PHPUnitのみ表示
OS表示
全OS表示
macOSのみ表示
windowsのみ表示
linuxのみ表示
JSフレームワーク
両フレームワーク
Reactのみ表示
Vueのみ表示
JSのみ表示

(JSが存在しない場合は、他を全表示)

和文変換

対象文字列と置換文字列を半角スペースで区切ってください。(最大5組各10文字まで)

本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作