Skip to content
Data

Table

It styles `thead` and `tbody`; the markup stays yours. Sorting and selection are deliberately left out, because every project wants them slightly differently.

import
import { Table } from '@joshicodes/cock';

Selectable

Click a row. Selection is yours to track; the component only styles it.

NameBreedStatusEggs this week
H Henrietta
Orpington Laying6
G Gertrude
Sussex Broody1
M Mabel
Leghorn Laying7
D Doris
Silkie Molting0

Dense

Egg log, Coop 2. Sizes vary.
DayNestWeight
MondayBox 161 g
MondayBox 364 g
TuesdayFlower bed58 g

Behaviour

  • `tone="accent"` carries the theme colour into the header, the stripes and the hover state.
  • `<tr aria-selected="true">` marks a selected row in either tone.
  • The wrapper scrolls sideways, so a wide table does not break the page on a phone.

API

Read out of the component sources at build time, so it matches the version you installed. Every component also takes class, merged through tailwind-merge so your utility wins.

Props of Table

PropTypeDefault
tone

`accent` carries the theme colour into the header, stripes and hover.

'neutral' | 'accent''neutral'
striped

Tint every other row.

booleanfalse
hoverable

Highlight rows on hover.

booleantrue
dense
booleanfalse
bordered

Wrap in a bordered, scrollable container.

booleantrue
caption
string—
class
string—

Snippets of Table

SnippetTypeDefault
children
Snippet—

See also

cock. Yes, it stands for core component kit. We checked twice.