Skip to content

Built-in Table component (<StxTable>) #1686

@glennmichael123

Description

@glennmichael123

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions