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 — Row Selection

Table with row selection checkboxes and a select-all header checkbox.

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

'use client';

import {useState} from 'react';
import {
  Table,
  useTableSelection,
  useTableSelectionState,
  proportional,
} from '@astryxdesign/core/Table';
import type {TableColumn} from '@astryxdesign/core/Table';

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

const users: User[] = [
  {id: '1', name: 'Alice', email: 'alice@example.com', role: 'Engineer'},
  {id: '2', name: 'Bob', email: 'bob@example.com', role: 'Designer'},
  {id: '3', name: 'Charlie', email: 'charlie@example.com', role: 'Manager'},
  {id: '4', name: 'Diana', email: 'diana@example.com', role: 'Engineer'},
  {id: '5', name: 'Eve', email: 'eve@example.com', role: 'Admin'},
];

const columns: TableColumn<User>[] = [
  {key: 'name', header: 'Name', width: proportional(1)},
  {key: 'email', header: 'Email', width: proportional(2)},
  {key: 'role', header: 'Role', width: proportional(1)},
];

export default function TableSelectableTable() {
  const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());

  const {selectionConfig} = useTableSelectionState<User>({
    data: users,
    idKey: 'id',
    selectedKeys,
    setSelectedKeys,
  });
  const selectionPlugin = useTableSelection<User>(selectionConfig);

  return (
    <Table
      data={users}
      columns={columns}
      idKey="id"
      plugins={{selection: selectionPlugin}}
    />
  );
}

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.