Contoh
Menu perintah
Palet perintah yang dibuat ulang sesuai perilaku sebenarnya: dialog mengalihkan fokus ke combobox dengan daftar hasil filter mengambang di bawah input, bukan daftar perintah sebaris.
Pratinjau
Go to dashboard
Go to deployments
Go to billing
Create new project
Invite a teammate
Rotate API key
Toggle dark mode
Open documentation
Contact support
HTML
<bs:bsui-stack direction="row" gap="2" align="center">
<bs:bsui-dialog>
<bs:bsui-dialog-trigger trigger_label="Search documentation" trigger_variant="outline" />
<bs:bsui-dialog-backdrop />
<bs:bsui-dialog-popup>
<bs:bsui-dialog-content>
<bs:bsui-combobox name="command" placeholder="Type a command or search...">
<bs:bsui-combobox-input />
<bs:bsui-combobox-popup>
<bs:bsui-combobox-option value="dashboard" label="Go to dashboard" />
<bs:bsui-combobox-option value="deployments" label="Go to deployments" />
<bs:bsui-combobox-option value="billing" label="Go to billing" />
<bs:bsui-combobox-option value="new-project" label="Create new project" />
<bs:bsui-combobox-option value="invite" label="Invite a teammate" />
<bs:bsui-combobox-option value="rotate-key" label="Rotate API key" />
<bs:bsui-combobox-option value="theme" label="Toggle dark mode" />
<bs:bsui-combobox-option value="docs" label="Open documentation" />
<bs:bsui-combobox-option value="support" label="Contact support" />
</bs:bsui-combobox-popup>
</bs:bsui-combobox>
</bs:bsui-dialog-content>
</bs:bsui-dialog-popup>
</bs:bsui-dialog>
<bs:bsui-text content="or press" variant="caption" tag="span" />
<bs:bsui-kbd label="Cmd" />
<bs:bsui-kbd label="K" />
</bs:bsui-stack>Cara kerjanya
Saat dialog dibuka, fokus langsung berpindah ke input combobox, dan store-nya memfilter daftar tujuan dalam konteks setiap kali tombol ditekan. Enter menjalankan perintah yang disorot dan menutup kedua lapisan, sementara Escape menutup daftar terlebih dahulu, lalu dialog.
Setiap perilaku di halaman ini adalah Interactivity WordPress API: setiap komponen mendaftarkan store sendiri, menginisialisasi statusnya dalam konteks yang dirender di server, dan menghubungkan event dengan direktif pada markup di atas. Tidak ada JavaScript khusus halaman.