예제
명령 메뉴
명령 팔레트를 실제 구성에 맞게 다시 만들었습니다. 대화상자에서 콤보박스로 포커스를 넘기며, 필터링된 목록은 입력란 아래에 떠서 열리고 인라인 명령 목록으로 표시되지 않습니다.
미리보기
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>작동 방식
대화상자를 열면 포커스가 콤보박스 입력란으로 바로 이동하고, 스토어는 키를 입력할 때마다 컨텍스트에서 목적지 목록을 필터링합니다. Enter를 누르면 강조된 명령을 실행하고 두 레이어를 모두 닫으며, Escape를 누르면 먼저 목록으로 돌아간 뒤 대화상자를 닫습니다.
이 페이지의 모든 동작은 WordPress Interactivity API입니다. 각 컴포넌트가 자체 스토어를 등록하고, 서버 렌더링 컨텍스트에서 상태를 설정하며, 위 마크업의 디렉티브로 이벤트를 연결합니다. 페이지별 JavaScript는 없습니다.