ReviewOS

stacks/stx

Built-in Table component (<StxTable>)

#1686
Closed glennmichael123 opened this 23 days ago · 1 comment
23 days ago

Summary

Data table with sorting, filtering, selection, and pagination built-in.

Usage

<StxTable :data="users()" :columns="columns" searchable sortable selectable>
  <template #empty>
    <p>No users found</p>
  </template>
  <template #cell-actions="{ row }">
    <button @click="editUser(row)">Edit</button>
  </template>
</StxTable>

<script client>
  const users = state([])
  const columns = [
    { key: 'name', label: 'Name', sortable: true },
    { key: 'email', label: 'Email', sortable: true },
    { key: 'role', label: 'Role', filterable: true },
    { key: 'actions', label: '' },
  ]
  
  onMount(async () => {
    users.set(await fetch('/api/users').then(r => r.json()))
  })
</script>

Props

  • :data — array of row objects (signal-reactive)
  • :columns — column definitions
  • searchable — show search input
  • sortable — enable column sorting
  • selectable — row checkboxes with @select event
  • striped — alternating row colors
  • hoverable — row hover highlight
  • stickyHeader — fixed header on scroll
  • loading — show skeleton rows
  • emptyText — text when no data

Column definition

interface TableColumn {
  key: string
  label: string
  sortable?: boolean
  filterable?: boolean
  width?: string
  align?: 'left' | 'center' | 'right'
  render?: (value: any, row: any) => string  // custom cell renderer
}

Features

  • Client-side sort/filter/search (for small datasets)
  • Server-side mode (emits events, doesn't filter internally)
  • Responsive: horizontal scroll or stacked cards on mobile
  • Keyboard navigation
  • Slot per column for custom cell rendering
23 days ago

Delivered via @stacksjs/components, which ships with every stx app and is auto-registered (no import needed in .stx files). See CLAUDE.md § "Reach for stx primitives before vanilla JS" for the full inventory; the relevant components for this request are documented there.

Closing as effectively delivered. If a specific behavior or API affordance from the original request is missing from the shipped components, please open a focused ticket against @stacksjs/components describing the exact gap — that's easier to track than a broad "make it a builtin" ask.

Sign in to comment on this issue.