EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Table·component·@astryxdesign/core

Table Selection Toolbar

Selection-aware bulk-action surface built on Toolbar. Pass selectionState from useTableSelectionState so count, visibility, and complete clearing stay synchronized with the Table selection plugin. The component owns no table or sticky layout: place it in flow or apply caller-owned positioning through xstyle.

Open in Playground @astryxdesign/core/Table

Showcases and examples

12 documented examples · Context from Table

Table — Sortable Columns

Table with sortable columns, click headers to sort ascending or descending.

Preview loads on approachPreview loads on approach
Exact source · table-sortable-table
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {
  Table,
  useTableSortable,
  useTableSortableState,
  proportional,
  pixel,
} from '@astryxdesign/core/Table';
import type {TableColumn} from '@astryxdesign/core/Table';

interface Employee extends Record<string, unknown> {
  id: string;
  name: string;
  email: string;
  role: string;
  age: number;
}

const employees: Employee[] = [
  {
    id: '1',
    name: 'Alice',
    email: 'alice@example.com',
    role: 'Engineer',
    age: 32,
  },
  {id: '2', name: 'Bob', email: 'bob@example.com', role: 'Designer', age: 28},
  {
    id: '3',
    name: 'Charlie',
    email: 'charlie@example.com',
    role: 'Manager',
    age: 45,
  },
  {
    id: '4',
    name: 'Diana',
    email: 'diana@example.com',
    role: 'Engineer',
    age: 37,
  },
  {id: '5', name: 'Eve', email: 'eve@example.com', role: 'Admin', age: 29},
];

const columns: TableColumn<Employee>[] = [
  {key: 'name', header: 'Name', width: proportional(1), sortable: true},
  {key: 'email', header: 'Email', width: proportional(2), sortable: true},
  {key: 'role', header: 'Role', width: proportional(1), sortable: true},
  {key: 'age', header: 'Age', width: pixel(80), sortable: true},
];

export default function TableSortableTable() {
  const {sortedData, sortConfig} = useTableSortableState<Employee>({
    data: employees,
    defaultSort: [{sortKey: 'name', direction: 'ascending'}],
  });

  const sortablePlugin = useTableSortable<Employee>(sortConfig);

  return (
    <Table
      data={sortedData}
      columns={columns}
      idKey="id"
      plugins={{sortable: sortablePlugin}}
    />
  );
}

Usage

Pass both outputs of useTableSelectionState to their matching consumers: selectionConfig to useTableSelection and selectionState to TableSelectionToolbar. Render product actions through startContent. Keep fixed or floating placement in the surrounding layout.

  • Pass selectionState directly from useTableSelectionState so the count and clear action stay synchronized with row selection.
  • Provide product actions as startContent instead of encoding them as configuration objects.
  • Inject the toolbar through the Table plugin or its horizontal scroll wrapper.

Typed props

PropType and behavior
selectionTableSelectionState · required
Shared selection state returned by useTableSelectionState: selectedKeys, selectedCount, hasSelection, and clearSelection.
startContentReactNode
Product-owned action controls aligned to the logical start. Child controls inherit the toolbar size.
labelstring · default Bulk actions
Accessible name for the action surface.
renderSelectionLabel(selectedCount: number) => ReactNode · default count => `${count} selected`
Overrides the visible count text for localisation or domain-specific copy.
clearLabelstring · default Unselect All
Visible label for the command that clears the complete controlled selection.
size'sm' | 'md' | 'lg' · default sm
Toolbar size. Cascades to product action controls and the clear action.
variantSectionVariant · default muted
Toolbar surface variant.
xstyleStyleXStyles
Caller-owned layout styles, including sticky positioning for floating compositions.