Selecting individual cells.
| Order | Customer | Status | Total |
|---|---|---|---|
| #1042 | A. Whitfield | Shipped | £64.00 |
| #1041 | R. Okafor | ProcessingC2 | £128.50 |
| #1040 | M. Iqbal | Shipped | £22.00 |
| #1039 | S. Novak | Refunded | £40.00 |
<div class="csel" data-mode="single" style="--accent:#241430;">
<div class="csel__scroll">
<table class="csel__table">
<caption>Expense sheet</caption>
<thead><tr><th scope="col">Order</th><th scope="col">Customer</th><th scope="col">Status</th><th scope="col">Total</th></tr></thead>
<tbody>
<tr><td>#1042</td><td>A. Whitfield</td><td>Shipped</td><td>£64.00</td></tr>
<tr class="csel__row">
<td>#1041</td><td>R. Okafor</td>
<td class="csel__cell csel__block">Processing<span class="csel__ref">C2</span></td>
<td class="csel__cell csel__block">£128.50</td>
</tr>
<tr><td>#1040</td><td>M. Iqbal</td><td>Shipped</td><td>£22.00</td></tr>
<tr><td>#1039</td><td>S. Novak</td><td>Refunded</td><td>£40.00</td></tr>
</tbody>
</table>
</div>
</div>
<style>
.csel { font: 14px system-ui, sans-serif; color: #241430; background: #FAF7F2; max-width: 480px; border: 1px solid #24143020; border-radius: 10px; overflow: hidden; }
.csel__scroll { overflow-x: auto; }
.csel__table { border-collapse: collapse; width: 100%; }
.csel__table caption { text-align: left; font-weight: 600; padding: 10px 14px; }
.csel__table th, .csel__table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #24143020; white-space: nowrap; }
.csel__table th { background: var(--accent); color: #FAF7F2; }
.csel__cell { position: relative; }
.csel__ref { position: absolute; top: 2px; right: 4px; font-size: 10px; font-weight: 600; color: var(--accent); }
.csel[data-mode="single"] .csel__block:first-of-type { outline: 2px solid var(--accent); outline-offset: -2px; }
.csel[data-mode="row"] .csel__row { background: #A8E6C155; }
.csel[data-mode="block"] .csel__block { background: #A8E6C155; outline: 1px solid var(--accent); outline-offset: -1px; }
</style><div class="max-w-[480px] rounded-[10px] border border-[#24143020] font-sans text-sm text-[#241430] bg-[#FAF7F2] overflow-hidden" data-mode="single" 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">Expense sheet</caption>
<thead><tr class="text-[#FAF7F2]" style="background:#241430">
<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">Status</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]">#1042</td><td class="p-3.5 border-b border-[#24143020]">A. Whitfield</td><td class="p-3.5 border-b border-[#24143020]">Shipped</td><td class="p-3.5 border-b border-[#24143020]">£64.00</td></tr>
<tr class="csel__row">
<td class="p-3.5 border-b border-[#24143020]">#1041</td><td class="p-3.5 border-b border-[#24143020]">R. Okafor</td>
<td class="csel__block p-3.5 border-b border-[#24143020] relative">Processing<span class="absolute top-0.5 right-1 text-[10px] font-semibold" style="color:#241430">C2</span></td>
<td class="csel__block p-3.5 border-b border-[#24143020]">£128.50</td>
</tr>
<tr><td class="p-3.5 border-b border-[#24143020]">#1040</td><td class="p-3.5 border-b border-[#24143020]">M. Iqbal</td><td class="p-3.5 border-b border-[#24143020]">Shipped</td><td class="p-3.5 border-b border-[#24143020]">£22.00</td></tr>
<tr><td class="p-3.5 border-b border-[#24143020]">#1039</td><td class="p-3.5 border-b border-[#24143020]">S. Novak</td><td class="p-3.5 border-b border-[#24143020]">Refunded</td><td class="p-3.5 border-b border-[#24143020]">£40.00</td></tr>
</tbody>
</table>
</div>
</div>
<style>
[data-mode="single"] .csel__block:first-of-type { outline: 2px solid var(--accent); outline-offset: -2px; }
[data-mode="row"] .csel__row { background: #A8E6C155; }
[data-mode="block"] .csel__block { background: #A8E6C155; outline: 1px solid var(--accent); outline-offset: -1px; }
</style>function CellSelection({
caption = "Expense sheet",
accent = "#241430",
mode = "single",
showRef = true,
}) {
const cellStyle = { padding: "10px 14px", borderBottom: "1px solid #24143020", whiteSpace: "nowrap" };
const blockStyle = {
...cellStyle,
position: "relative",
background: mode === "row" || mode === "block" ? "#A8E6C155" : "transparent",
outline: mode === "block" ? `1px solid ${accent}` : mode === "single" ? `2px solid ${accent}` : "none",
outlineOffset: -2,
};
const rowStyle = { background: mode === "row" ? "#A8E6C155" : "transparent" };
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" }}>
{["Order", "Customer", "Status", "Total"].map((h) => <th key={h} scope="col" style={cellStyle}>{h}</th>)}
</tr>
</thead>
<tbody>
<tr><td style={cellStyle}>#1042</td><td style={cellStyle}>A. Whitfield</td><td style={cellStyle}>Shipped</td><td style={cellStyle}>£64.00</td></tr>
<tr style={rowStyle}>
<td style={cellStyle}>#1041</td><td style={cellStyle}>R. Okafor</td>
<td style={blockStyle}>Processing{showRef && <span style={{ position: "absolute", top: 2, right: 4, fontSize: 10, fontWeight: 600, color: accent }}>C2</span>}</td>
<td style={blockStyle}>£128.50</td>
</tr>
<tr><td style={cellStyle}>#1040</td><td style={cellStyle}>M. Iqbal</td><td style={cellStyle}>Shipped</td><td style={cellStyle}>£22.00</td></tr>
<tr><td style={cellStyle}>#1039</td><td style={cellStyle}>S. Novak</td><td style={cellStyle}>Refunded</td><td style={cellStyle}>£40.00</td></tr>
</tbody>
</table>
</div>
</div>
);
}