# Kanban accessibility, RTL and localization

> The Kanban keyboard model with one tab stop, the grid roles that name each card's column and lane, live announcements, inherited right-to-left direction and localeText for every built-in string.

Canonical: https://salmonui.dev/docs/data-visualization/kanban-accessibility

The [Kanban](https://salmonui.dev/docs/data-visualization/kanban) board follows the APG grid
keyboard model: it is one tab stop,
and arrow keys move focus between cards. Try it in the demo: Tab into the
board, then use the keys below.

### Live demo: Kanban basics

Live demo: https://salmonui.dev/demos/data-visualization/kanban-basics

A sprint board with a multi-key column, WIP limits, stacked headers, card fields with tags and accent colors, tooltips, multiple selection, sorting, filtering, a hidden column, right to left and card drag.

`Demo.tsx`:

```tsx
'use client';
import { useMemo, useState } from 'react';
import { Checkbox } from '@salmonui/inputs/checkbox';
import { Kanban, type KanbanColumnDef, type KanbanColumnGroup, type KanbanKey, type KanbanSort } from '@salmonui/kanban';
import { Select } from '@salmonui/dropdowns/select';
import { TextField } from '@salmonui/inputs/text-field';

interface Task {
  id: string;
  title: string;
  summary: string;
  status: string;
  priority: number;
  tags: string;
  color: string;
}

const columnsFor = (hideBacklog: boolean): readonly KanbanColumnDef[] => [
  { key: 'backlog', header: 'Backlog', hidden: hideBacklog },
  { key: 'todo', header: 'To do', max: 4 },
  { keys: ['doing', 'review'], header: 'In progress', min: 1, max: 3 },
  { key: 'done', header: 'Done' },
];

const GROUPS: readonly KanbanColumnGroup[] = [
  { header: 'Planned', columns: ['backlog', 'todo'] },
  { header: 'Active', columns: ['doing', 'done'] },
];

const TASKS: readonly Task[] = [
  {
    id: 'T-1',
    title: 'Audit color tokens',
    summary: 'List every --salmon-* variable in use.',
    status: 'backlog',
    priority: 3,
    tags: 'theme',
    color: '#7c3aed',
  },
  {
    id: 'T-2',
    title: 'Keyboard drag spec',
    summary: 'Space lifts, arrows move, Space drops.',
    status: 'todo',
    priority: 1,
    tags: 'a11y,drag',
    color: '#dc2626',
  },
  {
    id: 'T-3',
    title: 'SSR snapshot tests',
    summary: 'Pin the server markup of every column.',
    status: 'todo',
    priority: 2,
    tags: 'ssr',
    color: '#2563eb',
  },
  {
    id: 'T-4',
    title: 'Card virtualization',
    summary: 'Measured heights per column.',
    status: 'doing',
    priority: 1,
    tags: 'perf',
    color: '#dc2626',
  },
  {
    id: 'T-5',
    title: 'WIP limit copy',
    summary: 'Announce over and under limits.',
    status: 'review',
    priority: 2,
    tags: 'a11y',
    color: '#2563eb',
  },
  {
    id: 'T-6',
    title: 'Release notes',
    summary: 'Summarize the board features.',
    status: 'done',
    priority: 3,
    tags: 'docs',
    color: '#16a34a',
  },
  {
    id: 'T-7',
    title: 'RTL pass',
    summary: 'Logical properties only.',
    status: 'backlog',
    priority: 2,
    tags: 'rtl',
    color: '#2563eb',
  },
];

const SORTS: Record<string, KanbanSort<Task>> = {
  data: { by: 'data' },
  priority: { by: 'field', field: 'priority', direction: 'asc' },
  title: { by: 'custom', comparator: (a, b) => a.title.localeCompare(b.title) },
};

const SORT_OPTIONS = [
  { value: 'data', label: 'Data order' },
  { value: 'priority', label: 'Priority field' },
  { value: 'title', label: 'Custom (title)' },
];

export default function KanbanBasicsDemo() {
  const [selected, setSelected] = useState<readonly KanbanKey[]>([]);
  const [search, setSearch] = useState('');
  const [sort, setSort] = useState('data');
  const [last, setLast] = useState('nothing yet');
  const [hideBacklog, setHideBacklog] = useState(false);
  const [rtl, setRtl] = useState(false);
  const columns = useMemo(() => columnsFor(hideBacklog), [hideBacklog]);
  const needle = search.trim().toLowerCase();

  return (
    <div style={{ display: 'grid', gap: 12 }}>
      <div
        style={{
          display: 'flex',
          flexWrap: 'wrap',
          gap: 12,
          alignItems: 'center',
        }}
      >
        <TextField type="search" label="Filter" value={search} onValueChange={(value) => setSearch(value)} placeholder="Title or tag" />
        <label>
          Sort{' '}
          <Select aria-label="Sort" data={SORT_OPTIONS} value={sort} onValueChange={(value) => value != null && setSort(String(value))} />
        </label>
        <Checkbox checked={hideBacklog} onCheckedChange={(checked) => setHideBacklog(checked)}>
          Hide Backlog
        </Checkbox>
        <Checkbox checked={rtl} onCheckedChange={(checked) => setRtl(checked)}>
          Right to left
        </Checkbox>
      </div>
      <div dir={rtl ? 'rtl' : 'ltr'}>
        <Kanban
          aria-label="Sprint board"
          data={TASKS}
          getCardId={(t) => t.id}
          columnField="status"
          columns={columns}
          columnGroups={GROUPS}
          card={{
            headerField: 'title',
            contentField: 'summary',
            tagsField: 'tags',
            accentField: 'color',
          }}
          getCardProps={({ card }) => ({ 'data-priority': card.priority })}
          selection="multiple"
          selectedCards={selected}
          onSelectedCardsChange={(value) => setSelected(value)}
          sort={SORTS[sort]}
          filter={needle ? (t) => t.title.toLowerCase().includes(needle) || t.tags.includes(needle) : undefined}
          cardsDraggable
          onCardMove={(e) => setLast(`${e.cardIds.join(', ')} to ${String(e.to.columnKey)} at ${e.index} by ${e.source}`)}
          onCardClick={(e) => setLast(`clicked ${String(e.id)}`)}
          tooltip={{
            delay: 400,
            render: ({ card }) => `${card.title}: ${card.summary}`,
          }}
        />
      </div>
      <p>
        Selected: <output>{selected.length ? selected.join(', ') : 'none'}</output> · Last event: <output>{last}</output>
      </p>
    </div>
  );
}
```

## Keyboard

| Key | Action |
| --- | --- |
| Tab | Enters the board on the last focused card (the first card at first); Tab again leaves it |
| ArrowUp / ArrowDown | Previous or next card in the cell; continues into the lane above or below |
| ArrowLeft / ArrowRight | Same position in the previous or next column with cards (mirrored in RTL) |
| Home / End | First or last card of the cell |
| Ctrl+Home / Ctrl+End | First or last card of the board |
| Enter | Selects the card, or opens the editor when `editor` or `renderEditor` is set |
| F2 | Opens the editor (with `editor` or `renderEditor`) |
| Space | Selects the card; with `cardsDraggable` lifts it ([keyboard drag](https://salmonui.dev/docs/data-visualization/kanban-drag-drop)) |
| Ctrl+Space, Ctrl+Enter | Toggles the card in the selection (`selection="multiple"`) |
| Shift+ArrowUp / Shift+ArrowDown | Extends the selection within the cell (`selection="multiple"`) |
| Escape | Clears the selection and hides the tooltip |

On macOS, Cmd works wherever Ctrl is listed. Collapsed columns are skipped.
The column header controls (collapse toggle, reorder grip with
Alt+ArrowLeft / Alt+ArrowRight) and the add buttons are ordinary buttons in
the tab order.

## Roles

The board is a `role="grid"` with `aria-roledescription="board"` and the
accessible name you give it (`aria-label` or `aria-labelledby`; give every
board one). Every board cell, a column or a column within a swimlane, is a
`row` that starts with a visually hidden `rowheader` naming the column, its
stacked group, the lane and the card count. Every card is a `gridcell`
with `aria-roledescription="card"` and, when selection is on,
`aria-selected`; `aria-multiselectable` marks `selection="multiple"`. A
swimlane is a `rowgroup` whose first row is the lane header.

A visual column is therefore an ARIA row: screen readers announce a card
with the name of its column, cards may hold interactive content (a link or
a button in `renderCard`), and each column keeps its own virtual window.

Draggable cards are described by the drag instructions. The tooltip is a
`role="tooltip"` element referenced by the card's `aria-describedby`. The
editor is a modal dialog labelled by its title; invalid fields carry
`aria-invalid` and point at their message.

## Live region

A polite live region announces keyboard drag steps (lift, each position,
drop, cancel), column moves, WIP limit changes and failed writes.
The status region shows the loading and load error texts; the board is
`aria-busy` while it loads.

## Right to left

The board inherits `dir` from its ancestors; there is no `rtl` prop.
Columns run from right to left, CSS uses
logical properties only, and ArrowLeft / ArrowRight (navigation, keyboard
drag and Alt+arrow column moves) follow the visual direction.

```tsx
<div dir="rtl">
  <Kanban /* ... */ />
</div>
```

## Localization

`localeText` overrides any built-in string; missing
keys fall back to `KANBAN_DEFAULT_LOCALE_TEXT`. Templates use `{param}`
placeholders. The object is plain JSON, so a server component can pass it.

```tsx
import { Kanban, type KanbanLocaleText } from '@salmonui/kanban';

const de: Partial<KanbanLocaleText> = {
  count: '{count} Karten',
  addCard: 'Karte zu {column} hinzufügen',
  add: 'Karte hinzufügen',
  empty: 'Keine Karten',
  dragInstructions: 'Leertaste zum Aufnehmen. Pfeiltasten bewegen, Leertaste legt ab, Escape bricht ab.',
};

<Kanban localeText={de} /* ... */ />
```

| Keys | Used for |
| --- | --- |
| `board`, `card` | `aria-roledescription` of the board and the cards |
| `count`, `limitMin`, `limitMax`, `overLimit`, `underLimit` | Header counts, WIP limits and their announcements |
| `collapse`, `expand`, `addCard`, `add`, `moveColumn`, `columnMoved` | Header and add buttons, column reorder |
| `unassigned`, `empty`, `columnPicker` | Unassigned lane, empty cells, the narrow-layout column picker |
| `loading`, `loadError`, `writeError` | Data states |
| `dragInstructions`, `lifted`, `position`, `dropped`, `cancelled` | Keyboard drag |
| `editTitle`, `newTitle`, `save`, `cancel`, `delete`, `required`, `fieldHeader`, `fieldContent`, `fieldColumn`, `fieldSwimlane` | The editor |
