Basic Dropdown
A menu button with the full keyboard model - arrows, Home/End, Escape, focus restore.
6 個のフレームワーク中級
A menu where exactly one row is checked and picking a new one closes it.
<!--
Exactly one row is aria-checked at a time via role="menuitemradio", and picking
a new one closes the menu - single-select is a decision, not an accumulation.
The trigger shows the current value so the answer is visible without opening.
-->
<div class="relative inline-block">
<button type="button" aria-haspopup="menu" aria-expanded="true" aria-controls="rd-menu" class="inline-flex items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-3.5 py-2 text-sm font-semibold text-gray-700 hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:focus-visible:ring-blue-400 dark:focus-visible:ring-offset-gray-900">
<span class="text-gray-500 dark:text-gray-400">Priority:</span>
Medium
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="m6 9 6 6 6-6" /></svg>
</button>
<ul id="rd-menu" role="menu" aria-label="Priority" class="absolute left-0 top-[calc(100%+0.375rem)] z-20 min-w-48 max-w-[calc(100vw-2rem)] rounded-xl border border-gray-200 bg-white p-1 shadow-lg dark:border-gray-700 dark:bg-gray-900">
<li role="none">
<button type="button" role="menuitemradio" aria-checked="false" class="flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus-visible:bg-gray-100 focus-visible:text-gray-900 focus-visible:outline-none dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100 dark:focus-visible:bg-gray-800 dark:focus-visible:text-gray-100">
<span aria-hidden="true" class="flex h-4 w-4 flex-none items-center justify-center"></span>
Low
</button>
</li>
<li role="none">
<button type="button" role="menuitemradio" aria-checked="true" class="flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus-visible:bg-gray-100 focus-visible:text-gray-900 focus-visible:outline-none dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100 dark:focus-visible:bg-gray-800 dark:focus-visible:text-gray-100">
<span aria-hidden="true" class="flex h-4 w-4 flex-none items-center justify-center">
<svg class="h-4 w-4 text-blue-600 dark:text-blue-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5" /></svg>
</span>
Medium
</button>
</li>
<li role="none">
<button type="button" role="menuitemradio" aria-checked="false" class="flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus-visible:bg-gray-100 focus-visible:text-gray-900 focus-visible:outline-none dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100 dark:focus-visible:bg-gray-800 dark:focus-visible:text-gray-100">
<span aria-hidden="true" class="flex h-4 w-4 flex-none items-center justify-center"></span>
High
</button>
</li>
</ul>
</div>| Prop | 型 | デフォルト | 説明 |
|---|---|---|---|
label必須 | string | - | 読み込み中に読み上げられるアクセシブルなラベル。 |
options必須 | Option[] | - | レンダリングする項目の配列。 |
value必須 | string | - | 指標の現在値。フォーマット済みの文字列を渡します。 |
onChange | (id: string) => void | - | On change |
Exactly one row is `aria-checked` at a time via `role="menuitemradio"`, and choosing a new one closes the menu - single-select is a decision, not an accumulation. The trigger shows the current value so the answer is visible without opening. The tick is `aria-hidden`; `aria-checked` carries the meaning. This is a menu of radios, not a `listbox` - use it when the options are few and read as commands; reach for `forms-select` when they are a long value list.