Selecting one or more rows.
| Select | Order | Customer | Total |
|---|---|---|---|
| #1042 | A. Whitfield | £64.00 | |
| #1041 | R. Okafor | £128.50 | |
| #1040 | M. Iqbal | £22.00 |
<div class="rsl" data-active="1" style="--accent:#241430;">
<div class="rsl__scroll">
<table class="rsl__table">
<caption>Customer orders</caption>
<thead><tr><th scope="col"><span class="sr-only">Select</span></th><th scope="col">Order</th><th scope="col">Customer</th><th scope="col">Total</th></tr></thead>
<tbody>
<tr><td><label class="rsl__chk"><input type="checkbox" checked><span class="sr-only">Select order #1042</span></label></td><td>#1042</td><td>A. Whitfield</td><td>£64.00</td></tr>
<tr><td><label class="rsl__chk"><input type="checkbox"><span class="sr-only">Select order #1041</span></label></td><td>#1041</td><td>R. Okafor</td><td>£128.50</td></tr>
<tr><td><label class="rsl__chk"><input type="checkbox"><span class="sr-only">Select order #1040</span></label></td><td>#1040</td><td>M. Iqbal</td><td>£22.00</td></tr>
</tbody>
</table>
</div>
</div>
<style>
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}
.rsl { font: 14px system-ui, sans-serif; color: #241430; background: #FAF7F2; max-width: 480px; border: 1px solid #24143020; border-radius: 10px; overflow: hidden; }
.rsl__scroll { overflow-x: auto; }
.rsl__table { border-collapse: collapse; width: 100%; }
.rsl__table caption { text-align: left; font-weight: 600; padding: 10px 14px; }
.rsl__table th, .rsl__table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #24143020; white-space: nowrap; }
.rsl__table th { background: var(--accent); color: #FAF7F2; }
.rsl__table input { accent-color: var(--accent); width: 16px; height: 16px; }
.rsl--stripe tbody tr:nth-child(even) { background: #24143008; }
.rsl[data-active="1"] tbody tr:nth-child(1) { background: #A8E6C155; }
.rsl[data-active="2"] tbody tr:nth-child(2) { background: #A8E6C155; }
.rsl[data-active="3"] tbody tr:nth-child(3) { background: #A8E6C155; }
</style><div class="max-w-[480px] rounded-[10px] border border-[#24143020] font-sans text-sm text-[#241430] bg-[#FAF7F2] overflow-hidden" data-active="1" style="--accent:#241430;">
<div class="overflow-x-auto">
<table class="border-collapse w-full">
<caption class="text-left font-semibold px-3.5 py-2.5">Customer orders</caption>
<thead><tr class="text-[#FAF7F2]" style="background:#241430">
<th scope="col" class="p-3.5"><span class="sr-only">Select</span></th>
<th scope="col" class="p-3.5 text-left whitespace-nowrap">Order</th>
<th scope="col" class="p-3.5 text-left whitespace-nowrap">Customer</th>
<th scope="col" class="p-3.5 text-left whitespace-nowrap">Total</th>
</tr></thead>
<tbody>
<tr><td class="p-3.5 border-b border-[#24143020]"><label class="inline-flex"><input type="checkbox" checked class="[accent-color:var(--accent)] w-4 h-4"><span class="sr-only">Select order #1042</span></label></td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">#1042</td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">A. Whitfield</td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">£64.00</td></tr>
<tr><td class="p-3.5 border-b border-[#24143020]"><label class="inline-flex"><input type="checkbox" class="[accent-color:var(--accent)] w-4 h-4"><span class="sr-only">Select order #1041</span></label></td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">#1041</td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">R. Okafor</td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">£128.50</td></tr>
<tr><td class="p-3.5 border-b border-[#24143020]"><label class="inline-flex"><input type="checkbox" class="[accent-color:var(--accent)] w-4 h-4"><span class="sr-only">Select order #1040</span></label></td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">#1040</td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">M. Iqbal</td><td class="p-3.5 border-b border-[#24143020] whitespace-nowrap">£22.00</td></tr>
</tbody>
</table>
</div>
</div>
<style>
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}
[data-active="1"] tbody tr:nth-child(1) { background: #A8E6C155; }
[data-active="2"] tbody tr:nth-child(2) { background: #A8E6C155; }
[data-active="3"] tbody tr:nth-child(3) { background: #A8E6C155; }
</style>function RowSelection({
caption = "Customer orders",
accent = "#241430",
multiSelect = true,
activeRow = "1",
stripe = false,
}) {
const rows = [
["#1042", "A. Whitfield", "£64.00"],
["#1041", "R. Okafor", "£128.50"],
["#1040", "M. Iqbal", "£22.00"],
];
const cell = { padding: "10px 14px", borderBottom: "1px solid #24143020", whiteSpace: "nowrap" };
const active = Number(activeRow);
return (
<div style={{ maxWidth: 480, borderRadius: 10, border: "1px solid #24143020", overflow: "hidden", font: "14px system-ui, sans-serif", color: "#241430", background: "#FAF7F2" }}>
<div style={{ overflowX: "auto" }}>
<table style={{ borderCollapse: "collapse", width: "100%" }}>
<caption style={{ textAlign: "left", fontWeight: 600, padding: "10px 14px" }}>{caption}</caption>
<thead>
<tr style={{ background: accent, color: "#FAF7F2" }}>
<th scope="col" style={cell}></th>
{["Order", "Customer", "Total"].map((h) => <th key={h} scope="col" style={cell}>{h}</th>)}
</tr>
</thead>
<tbody>
{rows.map((row, i) => (
<tr key={row[0]} style={{ background: active === i + 1 ? "#A8E6C155" : stripe && i % 2 === 1 ? "#24143008" : "transparent" }}>
<td style={cell}>
{multiSelect
? <input type="checkbox" defaultChecked={i === 0} aria-label={`Select order ${row[0]}`} style={{ accentColor: accent, width: 16, height: 16 }} />
: <input type="radio" name="rsl-row" defaultChecked={i === 0} aria-label={`Select order ${row[0]}`} style={{ accentColor: accent, width: 16, height: 16 }} />}
</td>
{row.map((c, j) => <td key={j} style={cell}>{c}</td>)}
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}