Basic Striped Table
A data-driven table with zebra striping, wrapped in a horizontal scroller that keeps it usable at 320px.
3 個のフレームワーク初級
Inline cell editing: click a cell to swap in an input, commit on Enter or blur and cancel on Escape.
<!--
A reading cell is a full-width <button> so it is keyboard-reachable and clearly
interactive; activating it swaps in an <input> with an aria-label naming the
field. Commit on Enter or blur, cancel on Escape - a lost edit on a blur is the
most common data-grid bug. Non-editable columns render as plain text. (State
lives in React/TS; this markup shows one cell mid-edit.)
-->
<div class="w-full overflow-x-auto">
<table class="w-full min-w-[32rem] border-collapse text-left text-sm">
<thead>
<tr class="border-b border-gray-200 dark:border-gray-800">
<th scope="col" class="px-3 py-2.5 font-medium text-gray-700 dark:text-gray-300">Item</th>
<th scope="col" class="px-3 py-2.5 font-medium text-gray-700 dark:text-gray-300">Qty</th>
</tr>
</thead>
<tbody>
<tr class="border-b border-gray-100 dark:border-gray-800">
<td class="px-1 py-1">
<button type="button" class="w-full rounded px-2 py-1.5 text-left text-gray-700 hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 dark:text-gray-300 dark:hover:bg-gray-800 dark:focus-visible:ring-blue-400">Cardstock</button>
</td>
<td class="px-1 py-1">
<input type="text" aria-label="Edit Qty" value="12" class="w-full rounded border border-blue-500 bg-white px-2 py-1.5 text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 dark:bg-gray-950 dark:text-gray-100 dark:focus-visible:ring-blue-400" />
</td>
</tr>
</tbody>
</table>
</div>| Prop | 型 | デフォルト | 説明 |
|---|---|---|---|
columns必須 | EditColumn[] | - | 比較対象の列(表示順)。 |
rows必須 | DataRow[] | - | 画像とテキストが交互に並ぶ行(順序どおり)。 |
onCommit | (id: string, key: string, value: string) => void | - | On commit |
className | string | - | ルート要素にマージされる追加クラス。 |
Mark columns `editable`; a reading cell is a full-width `<button>` (keyboard-reachable and obviously interactive) that swaps in an `<input>` with an `aria-label` naming the field. Commit on Enter or blur, cancel on Escape - the lost-edit-on-blur bug handled.