Skip to content

@vibe-labs/design-components-tables

Table component tokens, styles, and TypeScript types for the Vibe Design System.

Usage

css
@import "@vibe-labs/design-components-tables";
ts
import { TableVariants, TableSizes, TableAlignments, TableSortDirections } from "@vibe-labs/design-components-tables/types";
import type { TableColumn, TableSortState, TableStyleProps } from "@vibe-labs/design-components-tables/types";

Contents

Tokens (tables.css)

CSS custom properties defined in @layer vibe.tokens:

Container

TokenDefault
--table-bg--surface-base
--table-border-color--border-subtle
--table-border-width--border-width-1
--table-radius--radius-lg
TokenDefaultDescription
--table-header-bg--surface-subtleHeader background
--table-header-color--text-mutedHeader text color
--table-header-font-size--text-xsHeader font size
--table-header-font-weight--font-boldHeader font weight
--table-header-text-transformuppercaseHeader text transform
--table-header-height-{sm|md|lg}2rem / 2.5rem / 3remSize-dependent height
--table-header-px--space-3Horizontal padding

Row

TokenDefaultDescription
--table-row-height-{sm|md|lg}2.25rem / 2.75rem / 3.25remSize-dependent height
--table-row-px--space-3Horizontal padding
--table-row-border-color--border-subtleRow separator color
--table-row-bgtransparentDefault row background
--table-row-bg-stripe--surface-subtleAlternating row background
--table-row-hover-bg--surface-hover-overlayHover background
--table-row-selected-bgaccent @ 8% mixSelected row background
--table-row-selected-border--color-accentSelected row left accent strip

Cell

TokenDefault
--table-cell-px--space-2
--table-cell-font-size-{sm|md|lg}text-xs / text-sm / text-base
--table-cell-color--text-primary

Sort Indicator

TokenDefault
--table-sort-indicator-color--text-muted
--table-sort-indicator-active-color--color-accent
--table-sort-indicator-size0.75rem

Empty State

TokenDefault
--table-empty-py--space-12
--table-empty-color--text-muted
--table-empty-font-size--text-sm
TokenDefault
--table-footer-bgtransparent
--table-footer-border-color--border-subtle
--table-footer-px--space-3
--table-footer-py--space-2

Generated Styles (tables.g.css)

Component classes generated into @layer vibe.components.

Table Container

Flex column with border, radius, and overflow hidden. Supports four variants:

  • default — border + background
  • outlined — border only, transparent bg
  • elevated — no border, shadow elevation
  • ghost — no border, no background (rows only)

Size Modifier

data-size="sm|md|lg" controls header height, row height, and cell font size in one attribute.

Flags

  • striped — alternating row backgrounds via :nth-child(even)
  • hoverable — row hover background transition
  • interactive — pointer cursor on rows
  • fixed-header — sticky header with z-index
  • full — width: 100%

Header Cell

Flex item with uppercase muted text. Sortable columns show a chevron indicator:

  • [data-sortable] — cursor: pointer, chevron appears on hover
  • [data-sorted="asc"] — chevron rotated up, accent color
  • [data-sorted="desc"] — chevron down, accent color

Row

Flex row with bottom border separator. Supports:

  • [data-selected] — accent-tinted background + left border accent strip
  • [data-disabled] — reduced opacity, no pointer events
  • Last row automatically drops bottom border

Cell

Flex item with column padding and alignment. Supports:

  • [data-align="left|center|right"] — horizontal alignment
  • [data-truncate] — ellipsis overflow (with child element support)
  • [data-mono] — monospace font + tabular-nums
  • [data-nowrap] — prevent wrapping without truncation

Empty State

Centred muted text with generous vertical padding for no-data states.

Flex row with top border. Attachment point for pagination or summary content.

  • [data-align="left|center|right|between"] — content alignment

TypeScript Types (types/)

ts
// Runtime constants
TableSizes; // ['sm', 'md', 'lg']
TableVariants; // ['default', 'outlined', 'elevated', 'ghost']
TableAlignments; // ['left', 'center', 'right']
TableSortDirections; // ['asc', 'desc']

// Column definition — generic over row type
interface TableColumn<T> {
  key: keyof T & string;
  label: string;
  width?: string;
  minWidth?: string;
  align?: TableAlignment;
  sortable?: boolean;
  truncate?: boolean;
  mono?: boolean;
  hidden?: boolean;
  cellClass?: string;
  headerClass?: string;
}

// Sort state
interface TableSortState {
  key: string;
  direction: TableSortDirection;
}

// Row identifier
type TableRowKey<T> = (keyof T & string) | ((item: T) => string | number);

// Per-element style props
interface TableStyleProps {
  variant?;
  size?;
  striped?;
  hoverable?;
  interactive?;
  fixedHeader?;
  full?;
}
interface TableHeaderStyleProps {}
interface TableHeaderCellStyleProps {
  align?;
  sortable?;
  sorted?;
}
interface TableRowStyleProps {
  selected?;
  disabled?;
}
interface TableCellStyleProps {
  align?;
  truncate?;
  mono?;
  nowrap?;
}
interface TableEmptyStyleProps {}
interface TableFooterStyleProps {
  align?;
}

Dist Structure

FileDescription
index.cssBarrel — imports tokens + generated styles
tables.cssToken definitions
tables.g.cssGenerated component styles
index.js / index.d.tsTypeScript types + runtime constants

Dependencies

Requires tokens from @vibe-labs/design (colors, surfaces, borders, spacing, typography, transitions, elevation).

Pagination delegates to @vibe-labs/design-components-pagination — this package does not own --pagination-* tokens.

Build

bash
npm run build