Hero Search with Suggestions
A large hero search field with a live combobox suggestion list driven by the keyboard.
3 个框架中级
A search field above a table that filters rows live across every column, with a scroll wrapper.
<div class="w-full">
<label class="sr-only" for="table-filter">Filter rows</label>
<input id="table-filter" type="search" placeholder="Filter rows…" autocomplete="off" class="mb-3 w-full max-w-xs rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-100 dark:placeholder:text-gray-400 dark:focus-visible:ring-blue-400" />
<p class="mb-2 text-xs text-gray-600 dark:text-gray-300" role="status" aria-live="polite">2 of 3 rows</p>
<!-- The wrapper scrolls sideways so the table never pushes the page wider. -->
<div class="overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800">
<table class="w-full min-w-[24rem] text-left text-sm">
<thead class="bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-gray-900 dark:text-gray-400">
<tr><th scope="col" class="px-3 py-2 font-medium">Name</th><th scope="col" class="px-3 py-2 font-medium">Role</th></tr>
</thead>
<tbody class="divide-y divide-gray-200 dark:divide-gray-800">
<tr class="text-gray-800 dark:text-gray-100"><td class="px-3 py-2">Ada Lovelace</td><td class="px-3 py-2">Engineer</td></tr>
<tr class="text-gray-800 dark:text-gray-100"><td class="px-3 py-2">Grace Hopper</td><td class="px-3 py-2">Admiral</td></tr>
</tbody>
</table>
</div>
</div>| Prop | 类型 | 默认值 | 说明 |
|---|---|---|---|
columns必填 | string[] | - | 参与比较的列,按显示顺序排列。 |
rows必填 | TableRow[] | - | 图文交替排列的行,按顺序显示。 |
placeholder | string | 'Filter rows…' | Placeholder |
className | string | - | 合并到根元素上的额外类名。 |
A row survives when any of its cells contains the term; the header stays put and an empty state spans all columns. The table sits in an `overflow-x-auto` wrapper so it scrolls sideways instead of widening the page at 320px, and the visible-of-total count is announced via `aria-live`.