Display
Table
SimpleTable styles plain table markup with a sticky header, hover rows and an optional card layout in narrow containers.
<script>
import { SimpleTable } from "@codeatlasdev/ui";
</script>
<SimpleTable responsive="cards">
<thead>…</thead>
<tbody>…</tbody>
</SimpleTable>
SimpleTable styles plain thead and tbody markup inside a focusable, horizontally scrolling region. For search, sorting and pagination use DataTable. It is exported from @codeatlasdev/ui. @codeatlasdev/ui/table also exports a Table, a bordered wrapper around a plain <table> that forwards native table attributes.
Default (scroll)
A regular table at every width.
| Name | Role | Status | |
|---|---|---|---|
| Ana Souza | [email protected] | Admin | Active |
| Bruno Lima | [email protected] | Editor | Invited |
| Carla Dias | [email protected] | Viewer | Active |
Reference #139 · Pick in the gallery
Code
Cards on narrow containers
When the table's own container is narrower than 600px each row becomes a card. Every cell is captioned with its column header; `data-label` only overrides that. Resize the window to see it.
| Name | Role | Status | |
|---|---|---|---|
| Ana Souza | [email protected] | Admin | Active |
| Bruno Lima | [email protected] | Editor | Invited |
| Carla Dias | [email protected] | Viewer | Active |
Reference #138 · Pick in the gallery
Code
Dense, pinned and grouped
`density="compact"`, `frame={false}`, `scroll="none"` and `stickyColumns={2}` inside a panel that owns the scrolling, with collapsible group rows, a sortable header and interactive rows. Scroll the panel sideways: the checkbox and name columns stay put.
| Company | Owner | Stage | Value | ||
|---|---|---|---|---|---|
| Ana Souza | Atlas Co | Matheus | New | $12,000.00 | |
| Bruno Lima | Nimbus | Carla | New | $8,400.00 | |
| Carla Dias | Orbit | Diego | Won | $22,000.00 | |
| Diego Reis | Vertex | Matheus | Won | $5,600.00 | |
Nothing opened yet
Reference #491 · Pick in the gallery
Code
Dense records screens
For a CRM-style list (thousands of rows, ~10 columns) set density="compact" (rows up to 40px), frame={false} when the table sits in a framed panel, and scroll="none" when the page or panel is the scroller so the sticky header keeps working. stickyColumns={n} pins the first n columns (checkbox, primary column); their background follows hover, selected and focus states and is never transparent. headerCase="sentence" drops the uppercase micro labels.
TableRow:selectedsetsaria-selected;onactivatemakes the row reachable by Tab and activates it on click, Enter and Space with an inset focus ring. Events from a checkbox, button, link, menu or input inside the row never activate it (adddata-row-ignoreto any other element that must not).TableGroupRow: a section row that spanscolspancolumns. Withcollapsibleits label is a button witharia-expandedbound toopen; render the group’s rows under{#if open}. The label stays pinned to the left while the table scrolls.TableSortHeader: a sentence-case sortablethwith a direction icon. Pass the column’ssort('none' | 'asc' | 'desc', which setsaria-sort) and anonsorthandler; you own the sort state.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
selected | boolean | undefined | Sets `aria-selected` and the selected tint; pinned cells stay opaque. |
onactivate | (event: MouseEvent | KeyboardEvent) => void | undefined | Makes the row interactive (tabindex 0, click, Enter, Space). Nested controls do not trigger it. |
children | Snippet | undefined | The row's `td` cells. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
colspan | number | required | Number of columns to span. |
collapsible | boolean | false | Renders the label as a button with `aria-expanded`. |
open | boolean | true | Expanded state, bindable. Render the group's rows under `{#if open}`. |
label | Snippet | undefined | Group title and count. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
sort | 'none' | 'asc' | 'desc' | 'none' | Current direction; sets `aria-sort` on the `th`. |
onsort | () => void | undefined | Called when the header button is pressed; you own the next direction. |
children | Snippet | undefined | Column label. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
responsive | 'scroll' | 'cards' | 'scroll' | `scroll` keeps a regular table. `cards` turns each row into a card when the table's own width is below the `sm` breakpoint (600px). Cell captions come from the `thead` headers automatically. |
skeleton | boolean | false | Loading placeholder: rows keep their layout but are hidden, so the table has the exact loaded size. Render placeholder rows so the height matches. See Skeleton. |
density | 'default' | 'compact' | 'default' | `compact` renders rows of at most 40px. |
frame | boolean | true | `false` drops the table's own border and radius, for a table inside a framed panel. |
scroll | 'x' | 'none' | 'x' | `x`: the root is a focusable horizontal scroller. `none`: the root is `overflow: visible` and the caller owns scrolling, so the sticky header sticks to the page or panel. |
stickyColumns | number | 0 | Pins the first N columns (up to 6) to the left, with an opaque background in every row state. |
headerCase | 'upper' | 'sentence' | 'upper' | `sentence` renders header labels in regular size and their own case. |
class | string | '' | Extra class on the wrapper. |
children | Snippet | undefined | `thead` and `tbody` markup. |