# Table

Crate: `libero`
Import: `use libero::components::{Table, column};`
Feature: `table` (off by default, turns on `badge`, `progress-bar`, `skeleton`, `checkbox`, `native-select`, `select`, `text-field`, `pagination`, `menu`, `sortable`, `icon`, `action-icon`, `button`, `collapse`, `use-debounce`; [features.md](features.md))
Source: <https://github.com/tdymel/libero/tree/main/libero/src/components/data_display/table>
Index: [index.md](index.md) lists every other page
Description: A sortable data table built from a row type and a list of column definitions.

A data table over your own row type. `data` holds the rows, and each
`column(..)` in `columns` reads one cell, whose type sets its sort order and
alignment. Sorting, selection, paging, filters, a column menu, pinned, resized
and reordered columns, row groups, tree rows, row details, cell editing and
virtual rows are each a prop away, their state held by the table or by you.

## Usage

```rust
use dioxus::prelude::*;
use libero::components::{Chip, Table, column};

#[derive(Clone, PartialEq)]
struct Person {
    name: String,
    role: String,
    bonus: Option<f64>,
}

#[component]
fn Demo() -> Element {
    let people = vec![
        Person { name: "Ada Lovelace".into(), role: "Owner".into(), bonus: Some(12.5) },
        Person { name: "Grace Hopper".into(), role: "Admin".into(), bonus: Some(8.0) },
        Person { name: "Alan Turing".into(), role: "Viewer".into(), bonus: None },
    ];

    rsx! {
        Table {
            caption: "Team members",
            data: people,
            columns: vec![
                column("Name").value(|p: &Person| p.name.clone()).sortable().row_header(),
                column("Role")
                    .value(|p: &Person| p.role.clone())
                    .sortable()
                    .render(|p: &Person| rsx! { Chip { size: "xs", "{p.role}" } }),
                column("Bonus")
                    .value(|p: &Person| p.bonus)
                    .format(|p: &Person| p.bonus.map(|b| format!("{b:.1} %")).unwrap_or_default())
                    .sortable(),
            ],
        }
    }
}
```

## Props

### Table

| Prop | Type | Default | Description |
|---|---|---|---|
| `data` | `Vec<T>` | required | One row each, in source order until a column is sorted. |
| `columns` | `Vec<Column<T>>` | required | Built with `column(..)`. |
| `column_defaults` | `ColumnDefaults` | none | Settings every column starts from: `ColumnDefaults::new().align(..).width(..).min_width(..)`. A column's own setting wins. |
| `caption` | `Option<String>` | `None` | A visible title above the header row, and the table's accessible name. |
| `empty` | `Option<Element>` | `None` | Shown in one full-width row when `data` is empty. Unset, the row reads the localized `table.no_rows`, "No rows". When the quick filter or the column filters leave no rows, the row reads `table.no_results`, "No matching rows", instead. |
| `no_results` | `Option<Element>` | `None` | Shown in one full-width row when the quick filter or the column filters leave no rows, over the localized `table.no_results`. |
| `loading` | `bool` | `false` | Rows are on their way. While no row shows, placeholder rows fill the body, a page of them when paged, else five, and the table is `aria-busy`. With rows shown, they stay usable under a thin progress bar over the table's top edge, named by the localized `table.loading`, "Loading rows". The empty row waits until loading ends. |
| `toolbar` | `Option<Element>` | `None` | A row above the table for your own controls, say an export or add button. With `show_quick_filter` the search field joins it at the end. It wraps on a narrow screen and stays put while the table scrolls. `TableColumnsButton`, `TableDensityButton`, `TableFilterButton` and `TableExportButton` work only in here. `TableColumnsButton` opens a checklist that shows and hides the hideable columns; `TableDensityButton` picks compact, standard or comfortable rows, `size` small, medium or large. |
| `csv_formula_guard` | `bool` | `true` | Gives a `TableExportButton` cell that starts with `=`, `+`, `-`, `@`, Tab or CR, a plain number aside, a leading `'`, so a spreadsheet reads it as text, not a formula (CSV injection, OWASP), as `table_csv` does. `false` exports every cell as it is, as `table_csv_raw` does. |
| `scroll` | `bool` | `false` | Wraps the table in a `ScrollArea` that scrolls sideways. The `caption` sits above the scrolled box, so it stays in view. `class`, `sx` and `attributes` stay on the table. |
| `max_height` | `Option<String>` | `None` | Caps the table's height, any CSS length. The rows scroll in a `ScrollArea`, both ways, under a header that stays put, with the scrollbar beside the rows only. The `caption` sits above the scrolled box. The header takes the page surface's colour: on another background, set it with `sx().selector("& thead th", ..)`. |
| `sticky_header` | `Option<String>` | `None` | Keeps the header in view while the page, or the scrolling container around the table, scrolls past the rows: this far below its top edge, a CSS length, say `"0"` or a fixed app header's height. It sticks to the nearest ancestor with an `overflow` other than `visible`, even one that only scrolls sideways. The footer and a `toolbar` do not stick. A focus scroll leaves the focused cell clear of the header. No effect with `max_height`, whose header stays put already, or with `scroll` and pinned columns, whose scroll area holds the header instead of the page; a debug build warns. |
| `virtual_row_height` | `Option<f64>` | `None` | With `max_height`, renders only the rows in view plus a few beyond each edge, so ten thousand rows scroll like fifty. Every body row is clipped to this height in px: one line per cell, longer text ends in an ellipsis. The table then lays out fixed, columns without a `width` sharing the rest evenly. A row holding focus stays rendered while it scrolls away. With `onrowreorder` a keyboard move scrolls to its slot, and a row dragged to the top or bottom edge scrolls the rows on. Ignored with `row_detail`, which renders every row; a debug build warns. |
| `onbottomreached` | `EventHandler<()>` | `None` | With `max_height`, called when the rows scroll to their bottom, by wheel, drag or End: append the next batch to `data`. Called again at the new bottom once rows were added. Not called while `loading` is set, so set it during a fetch to ask once. Without `max_height` it never fires; a debug build warns. |
| `sort` | `Option<Vec<TableSort>>` | `None` | The sorted columns, empty for source order. Set, the sort is controlled: pair it with `onsortchange`. Without `multi_sort`, one column sorts, the first entry naming a sortable header. Entries for a column that leaves `columns` are dropped. |
| `default_sort` | `Vec<TableSort>` | `[]` | Seeds the sort once. Ignored when `sort` is set. |
| `onsortchange` | `EventHandler<Vec<TableSort>>` | `None` | Called with the sort a header click asks for: ascending, then descending, then empty. |
| `multi_sort` | `bool` | `false` | Sorts by several columns, the first entry first. Shift, Ctrl or Cmd with a header click, or any tap on a touch screen, adds the column after the sorted ones, then flips and removes it. A plain click sorts by that column alone. Each sorted header shows its place. |
| `selectable` | `bool` | `false` | Adds a checkbox column, with a select-all box in its header. Set `row_key` with it, or the selection sticks to positions in `data`. |
| `selection` | `Option<Vec<String>>` | `None` | The selected rows' `row_key`s. Set, the selection is controlled: pair it with `onselectionchange`. It survives a sort. Keys of rows that leave `data` stay selected, so a selection can span a server's pages: drop them yourself when you delete rows. |
| `default_selection` | `Vec<String>` | `[]` | Seeds the selection once. Ignored when `selection` is set. |
| `onselectionchange` | `EventHandler<Vec<String>>` | `None` | Called with the selection a checkbox asks for. Select-all covers every row of `data` the quick filter keeps, and keeps keys of the other rows, say from another page of a server. |
| `row_key` | `RowFn<T, String>` | the row's index | A row's identity, unique per row, from a `\|row: &T\| ..` closure. Its DOM node follows it through a sort or a data change, so focus and state inside a row stay with it. |
| `onrowclick` | `EventHandler<T>` | `None` | Called with the clicked row. Pointer only: give keyboard users a button or link in a cell for the same action. A click on a button, link or field in the row is left to it and calls nothing here. |
| `row_states` | `RowFn<T, States>` | `None` | A row's states, rendered as its `data-state`. Style them with `sx().selector("& tbody tr", sx().when(..))`. |
| `row_attrs` | `RowFn<T, Vec<Attribute>>` | `None` | Extra attributes on a row's `tr`. |
| `row_detail` | `RowFn<T, Option<Element>>` | `None` | A row's detail, from a `\|row: &T\| ..` closure. `Some` gives the row a toggle in a leading column; open, the detail shows in a full-width row under it. Called for the shown rows on every render, or only the open ones with `row_has_detail`. Set `row_key` with it, or open details stick to positions in `data`. |
| `row_has_detail` | `RowFn<T, bool>` | `None` | Whether a row has a detail, without building it. Set, it decides the toggles, and `row_detail` is called for the open rows only: for large tables. |
| `animate_details` | `bool` | `false` | Slides the detail rows open and shut, as a `Collapse`; at once under reduced motion. Not with `onrowreorder`. |
| `expanded` | `Option<Vec<String>>` | `None` | The `row_key`s of the rows whose detail shows. Set, it is controlled: pair it with `onexpandedchange`. It survives a sort. |
| `default_expanded` | `Vec<String>` | `[]` | Seeds the open details once. Ignored when `expanded` is set. |
| `onexpandedchange` | `EventHandler<Vec<String>>` | `None` | Called with the open details a toggle asks for. |
| `onrowreorder` | `EventHandler<SortableMove>` | `None` | Adds a leading column with a drag handle and Move up and Move down buttons per row. Called with a move by positions in `data`; apply it with `step.apply(&mut rows)`, the table shows the old order until you do. Off while the rows are sorted, filtered or grouped. Paged, a row moves within its page. Set `row_key` with it. |
| `onrowupdate` | `EventHandler<RowUpdate<T>>` | `None` | Called when an `.editable(..)` cell commits, with a `RowUpdate`: the row's `key`, its `index` in `data`, the edited `column`'s header and `row`, a clone of the row with the new value set. Store it, `rows.write()[update.index] = update.row`; the table keeps no copy, so the cell shows `data` again until you do. An unchanged value calls nothing. |
| `row_grouping` | `Option<Vec<String>>` | `None` | Groups the rows by the cell text of these headers, outermost first: `vec!["Role".into()]`. Each group gets a row of its own, with a toggle in the first shown column naming its text and row count; rows with an empty cell form one group, "(empty)". Groups follow the sorted rows, so sorting by the grouped column orders them, and a filter drops the groups it empties. The grouped column stays shown. With `selectable`, each group row gets a box that selects or clears the group's rows, open or not, checked when all are selected and mixed when some are. With `virtual_row_height`, group rows take one row height each and count in `aria-rowindex`. Rows don't reorder while grouped. Paged, group rows take places on a page like rows, and a group split by a page break gets no second group row. The footer and an export cover the rows alone. Set, the grouping is controlled: pair it with `onrowgroupingchange`. |
| `default_row_grouping` | `Vec<String>` | `[]` | Seeds the grouping once. Ignored when `row_grouping` is set. |
| `onrowgroupingchange` | `EventHandler<Vec<String>>` | `None` | Called with the grouping a pick asks for. |
| `expanded_groups` | `Option<Vec<String>>` | `None` | The open groups' ids: their texts from the outermost group in, joined by `/`, as `"Admin"` or `"Admin/2024"`; a `/` or `\` in a text is escaped by `\`, and the empty group's text is empty. Set, it is controlled: pair it with `onexpandedgroupschange`. |
| `default_expanded_groups` | `Vec<String>` | `[]` | Seeds the open groups once. Ignored when `expanded_groups` is set. |
| `onexpandedgroupschange` | `EventHandler<Vec<String>>` | `None` | Called with the open groups a group toggle asks for. |
| `default_group_expansion` | `usize` | `0` | How many levels of groups start open, the first time there are rows to group, beside `default_expanded_groups`: 1 opens the outermost groups. 0 starts every group closed. Ignored with `expanded_groups`. |
| `parent_key` | `RowFn<T, Option<String>>` | `None` | A row's parent's `row_key`, `None` for a root: the rows nest under their parents, each level in the sort, behind a toggle in the first shown column named by the row and its child count. A key no row has, or a cycle, makes roots; a debug build warns. A filter keeps the kept rows' parents and opens them. Set `row_key` with it. Over `row_grouping`, which it ignores and drops from the column menu; a tree shows no `row_detail` and its rows don't reorder. With `virtual_row_height` its rows window as flat rows do. With `selectable`, a row's box selects the row and its descendants the filter keeps; a parent turns selected once all its descendants are and clears when one clears, and its box is mixed while only some of the row and its descendants are selected. A row's `aria-selected` tells its own selection. The table is a `role="treegrid"` whose rows are its stops: the arrows move between them, open and close them. |
| `row_has_children` | `RowFn<T, bool>` | `None` | Whether a tree row has children not in `data` yet, from a `\|row: &T\| ..` closure: the row gets a closed toggle, named by the row alone until its children load. Opening it calls `onexpandednodeschange` with its key: append its children to `data`, their `parent_key` naming it, or return `false` for it once it has none. Until either, the open row stays `aria-busy`. A row with children in `data` is a parent whatever this returns. |
| `expanded_nodes` | `Option<Vec<String>>` | `None` | The `row_key`s of the open tree rows. Set, it is controlled: pair it with `onexpandednodeschange`. |
| `default_expanded_nodes` | `Vec<String>` | `[]` | Seeds the open tree rows once. Ignored when `expanded_nodes` is set. |
| `onexpandednodeschange` | `EventHandler<Vec<String>>` | `None` | Called with the open tree rows a toggle asks for. |
| `default_node_expansion` | `usize` | `0` | How many tree levels start open, the first time there are rows, beside `default_expanded_nodes`: 1 opens the roots. 0 starts every row closed. Ignored with `expanded_nodes`. |
| `cell_focus` | `bool` | `false` | Makes the table a `role="grid"` whose header and body cells are one tab stop: Tab enters on one cell, the first header cell until focus moves, and the arrows, Home, End, Ctrl+Home, Ctrl+End, PageUp and PageDown move it. On a header cell Enter or Space sorts and Ctrl+Enter opens its column menu; on a body cell Shift+Space selects the row with `selectable`. The stop stays where it was left and follows its row through a sort. A button or field in a cell stays a tab stop of its own, and a widget that takes the arrows keeps them. The leading checkbox, detail and reorder cells, group rows, the filter row and the footer stay out of the key map. Paged, `aria-rowcount` counts every page's rows; with a hidden column each cell carries its `aria-colindex`. An editable column turns it on. Give the rows a `.row_header()` column. |
| `size` | `Responsive<Size>` | `md` | Cell padding and font size. Or one per breakpoint, `size: responsive(Size::Xs).md(Size::Md)`. Breakpoints follow the window, not the parent. The padding follows in CSS; the windowed row height, the toolbar, the pager and the filters read it in Rust, so a server-rendered page shows the base there until it loads. |
| `density` | `Option<Size>` | `None` | The size a `TableDensityButton` picked, over `size`; set, it is controlled. |
| `default_density` | `Option<Size>` | `None` | Seeds the density once. Ignored when `density` is set. |
| `ondensitychange` | `Option<EventHandler<Size>>` | `None` | The density a `TableDensityButton` pick asks for. |
| `striped` | `bool` | `false` | Shades every other body row. |
| `page` | `Option<u32>` | `None` | The shown page, 1-based. Set, the page is controlled: pair it with `onpagechange`. A page past the end shows the last one, which the table writes back through `onpagechange` once rows fill a page. |
| `default_page` | `u32` | `1` | Seeds the page once. Ignored when `page` is set. |
| `onpagechange` | `EventHandler<u32>` | `None` | Called with the page a page button asks for. A sort or quick-filter change asks for page 1, and a new page size for the page that keeps the first shown row. |
| `page_size` | `Option<usize>` | `None` | Rows per page. Set, the size is controlled: pair it with `onpagesizechange`. Turns on pagination. |
| `default_page_size` | `Option<usize>` | `None` | Seeds the page size once. Turns on pagination. |
| `onpagesizechange` | `EventHandler<usize>` | `None` | Called with the size picked in the page-size picker. |
| `page_sizes` | `Vec<usize>` | `[]` | The page-size picker's choices; empty hides the picker. Turns on pagination, the first one seeding the size. No cap. |
| `manual_sort` | `bool` | `false` | `data` comes sorted, say from a server: a header click only reports through `onsortchange`. |
| `manual_pagination` | `bool` | `false` | `data` is the current page only: the table draws the page controls and leaves the slicing to you. A column's `aggregate` then covers this page only. |
| `row_count` | `Option<usize>` | data's length | Rows over all pages with `manual_pagination`, for the page count and the range text. |
| `hidden_columns` | `Option<Vec<String>>` | `None` | The hidden columns' headers. Set, visibility is controlled: pair it with `onhiddencolumnschange`. A hidden sorted column keeps sorting. Columns sharing a header hide and show together: give hideable columns distinct headers. |
| `default_hidden_columns` | `Vec<String>` | `[]` | Seeds the hidden columns once. Ignored when `hidden_columns` is set. |
| `onhiddencolumnschange` | `EventHandler<Vec<String>>` | `None` | Called with the hidden columns a column menu pick asks for. |
| `quick_filter` | `Option<String>` | `None` | The quick filter's text. A row stays when every word occurs, ignoring case, in the text of one of its shown, `filterable` cells. Set, the filter is controlled: pair it with `onquickfilterchange`. The rows are filtered, then sorted, then paged. |
| `default_quick_filter` | `String` | `""` | Seeds the quick filter once. Ignored when `quick_filter` is set. |
| `onquickfilterchange` | `EventHandler<String>` | `None` | Called with the text typed into the quick-filter field. |
| `show_quick_filter` | `bool` | `false` | Puts a search field above the table that drives the quick filter. |
| `manual_filter` | `bool` | `false` | `data` comes filtered, say from a server: the quick filter and the column filters only report through `onquickfilterchange` and `oncolumnfilterschange`. Pair it with `manual_pagination` and `row_count` when paged. |
| `column_filters` | `Option<Vec<ColumnFilter>>` | `None` | Filters by header: `ColumnFilter::new("Age", FilterOperator::GreaterThan, "30")`, or `ColumnFilter::between("Joined", "2026-01-01", "2026-06-30")` for a date range. A row stays when it passes all of them (or any, with `filter_logic`) and the quick filter. A date's value is an ISO day (`2026-01-31`); typed into its field, a day reads in the locale's format, which the field's placeholder shows. A filter names its column by header, so of filterable columns sharing a header it tests the first only: give them distinct headers. Text operators ignore case, `Equals` too; number operators compare the value, not its formatted text, and take `1,5` as 1.5. An empty value, a number that does not parse (its field then reads Not a valid value), or an operator the column's type does not offer keeps every row. A hidden column's filter keeps filtering; a column that leaves `columns` takes its filters with it. Set, the filters are controlled: pair them with `oncolumnfilterschange`. The operators follow the column's type, such as contains or starts with for text, greater than for numbers, before, after, on or before, on or after and between for a `chrono::NaiveDate`, yes or no for booleans, is, is not and is any of for a select column (`ColumnFilter::any_of("Role", ["Admin", "Owner"])`). A date's value field is a `DateField`, the native date input on a WebView. A `between` end left empty is open, and ends the wrong way round are swapped. A column may hold several filters: the popover and the header field edit its first, `filter_panel` all of them. |
| `default_column_filters` | `Vec<ColumnFilter>` | `[]` | Seeds the column filters once. Ignored when `column_filters` is set. |
| `oncolumnfilterschange` | `EventHandler<Vec<ColumnFilter>>` | `None` | Called with the filters a filter popover or a header filter asks for. Typed values arrive once typing pauses for 300 ms, an operator or yes/no pick at once. |
| `filter_logic` | `Option<FilterLogic>` | `None` | How the column filters join: `FilterLogic::And` keeps a row that passes all of them, `Or` one that passes any. The quick filter applies on top either way. Set, it is controlled. |
| `default_filter_logic` | `FilterLogic` | `And` | Seeds the filter logic once. Ignored when `filter_logic` is set. |
| `onfilterlogicchange` | `EventHandler<FilterLogic>` | `None` | Called with the filter logic a pick asks for. |
| `header_filters` | `bool` | `false` | Adds a row of filter fields under the headers, one per `filterable` column: a text field, Any/Yes/No for a boolean column, or Any and the options for a select column (one multi-select showing the first pick and a count once the popover picked Is any of). A field edits its column's filter with the operator the filter popover set, else the type's first: Contains for text, Equals for numbers. Columns sharing a header edit one filter, which tests the first of them. |
| `filter_panel` | `bool` | `false` | A Filters button at the start of the toolbar row, showing the active filters' count, opens a dialog of every column filter; with a `toolbar`, put `TableFilterButton` in it where the button goes instead, one line each: column, operator, value and a remove button. Add filter appends a line for the first column without one; from two lines a Match pick sets `filter_logic`. Lines apply as the popover does; a line left empty with its first operator goes when the panel closes. Each line is a group named by its column, and the column picker lists columns by header, so filterable columns sharing a header read as one. `column_menu`'s Filter then opens the panel on its column's line instead of the popover, and closing it returns the focus to that menu's button, or to the filtered header's button it was opened from. |
| `pinned_columns` | `Option<PinnedColumns>` | `None` | The columns held at the table's start and end edges while the rest scroll sideways, by header: `PinnedColumns::default().start([..]).end([..])`. Start is the left in a left-to-right page, the right in a right-to-left one. Set, pinning is controlled: pair it with `onpinnedcolumnschange`. Pair it with `scroll` or `max_height`, and give every pinned column but the outermost on its side a `width`, which it then keeps exactly. Pins that leave the other columns under a third of the scroll area's width are released, the innermost first and the end side before the start, and hold again once it grows; the checkbox column stays pinned. A released column's menu moves it as an unpinned one's does, and its Unpin drops the pin. |
| `default_pinned_columns` | `PinnedColumns` | none pinned | Seeds the pinned columns once. Ignored when `pinned_columns` is set. |
| `onpinnedcolumnschange` | `EventHandler<PinnedColumns>` | `None` | Called with the pinned columns a column menu pick asks for. |
| `column_order` | `Option<Vec<String>>` | `None` | The headers in display order. Unlisted columns follow the listed ones in `columns` order, and pinned columns keep their pinned order. Set, the order is controlled: pair it with `oncolumnorderchange`. The sort, hidden and pinned columns name headers, so they follow a moved column. With `column_menu`, a grip at each unpinned header's start edge also drags the column to a gap. |
| `default_column_order` | `Vec<String>` | `[]` | Seeds the column order once. Ignored when `column_order` is set. |
| `oncolumnorderchange` | `EventHandler<Vec<String>>` | `None` | Called with the order a column menu's Move left or Move right, or a header drag, asks for, every header listed. |
| `resizable_columns` | `bool` | `false` | Puts a visible grip on each header's end edge, 24px wide on a touch screen, and Widen column, Narrow column (50px steps, the menu stays open) and Reset width in its `column_menu`, the drag-free way. Drag a grip, or double-click it to reset. A focused grip takes the keys: Left and Right move it 10px the way they point, 50px with Shift, Home and End go to the limits. A column opts out with `.resizable(false)` and sets its range with `.resize_limits(min, max)` in px, 50 to unbounded by default. Auto layout never draws a column narrower than its content. Blitz: use the menu, the grip does not drag reliably there. |
| `column_widths` | `Option<ColumnWidths>` | `None` | Resized widths in px by header, a `BTreeMap<String, f64>`, over the columns' own `width`. Set, the widths are controlled: pair them with `oncolumnwidthschange`. |
| `default_column_widths` | `ColumnWidths` | `{}` | Seeds the widths once. Ignored when `column_widths` is set. |
| `oncolumnwidthschange` | `EventHandler<ColumnWidths>` | `None` | Called with the widths a grip drag asks for when it ends, each grip key, and with each Widen, Narrow or Reset width. |
| `column_menu` | `bool` | `false` | Puts a menu button in each header: sort ascending or descending, unsort, add to the sort with `multi_sort`, filter a `filterable` column, group the rows by it or stop (a new grouping level goes innermost), move the column left or right past the next shown one, widen, narrow or reset it with `resizable_columns`, pin to the start or end or unpin, hide the column, and a Columns submenu that shows or hides the others. A pinned column has no move entries. Filter opens a popover with the operators of the column's type, a value and Clear; a filtered column's header then shows a filter button that reopens it. |
| `column_menu_parts` | `Parts<MenuPart>` | none | The column menus' `parts`, the `Menu` page's Style API. The menus open in a portal, out of the table's `sx`. |

Like every component, `Table` also takes the shared props `sx`, `class`,
`style`, `states`, `hidden_from`, `visible_from`, and any extra HTML attributes, `aria_label` among them.

### column()

| Prop | Type | Default | Description |
|---|---|---|---|
| `header` | `String` | required | The column's title, the argument to `column(..)`. |
| `value` | `fn(&T) -> V` | required | Reads one cell out of a row. `V` sets the sort order and alignment. Text sorts as text and aligns left, by the app's language on the web and, with the `collation` feature, on desktop, Android and native, else by accent-folded letters there; numbers sort numerically and align right, and `Option<V>` keeps the inner type's alignment, renders `None` empty and sorts it last in both directions. `bool` prints `true` or `false`; a `libero::chrono::NaiveDate` prints as `2024-03-09`, sorts by day and filters with Before, After, Between and the other date operators. Your own type joins them with one `impl CellValue`: `cell_text` is required, `sort_key` and `align` have defaults. |
| `sortable` | `bool` | `false` | Turns the header into a sort button. |
| `render` | `fn(&T) -> Element` | `None` | Replaces the cell body. Sorting still uses `value`. For an actions column, keep the header text (it names the column for a screen reader), draw the buttons here with `value` a placeholder, and name each button after its row. Capture signals: a closure that captures a plain value redraws only rows whose data changed. |
| `format` | `fn(&T) -> String` | `None` | Replaces the cell text, say a price with its currency. Sorting and alignment still follow `value`. |
| `align` | `CellAlign` | follows the cell type | Overrides the alignment the cell type chose and `column_defaults`. |
| `width` | `String` | `None` | The column's width, any CSS length. Columns without one share the rest. |
| `min_width` | `String` | `None` | The narrowest the column gets, any CSS length. |
| `resizable` | `bool` | `true` | Whether the table's `resizable_columns` gives it a grip and menu entries. |
| `resize_limits` | `(f64, f64)` | `(50, unbounded)` | How narrow and how wide a resize takes the column, in px. `min_width` still floors it on screen. |
| `header_render` | `fn() -> Element` | `None` | Replaces the header's body, inside the sort button when sortable, so keep it non-interactive then. The header text stays the column's name in `TableSort`, and a column drag's ghost shows that text. Capture signals, not values: the closure is not compared, so a changed value does not redraw the header. |
| `of` | `&ColumnType<V>` | `None` | Before `value`: starts the column from a shared `const` type, its alignment, widths and a `format` over the value. `V` must match `value`'s; the column's own settings win. |
| `row_header` | `bool` | `false` | Renders the column's cells as `th scope="row"`, so a screen reader names each row by it. One per table, usually the first. |
| `editable` | `fn(&mut T, V)` | `None` | Makes the column's cells editable, turning on `cell_focus`: a double click, a second tap, or Enter or F2 on the focused cell, opens a text field over the cell's value, Enter, Tab or leaving it commits through `onrowupdate`, Escape puts it back. `V: EditValue` parses the text: text, finite numbers, `bool` and `Option<bool>` (a checkbox: Space toggles, an `Option<bool>` one cycles empty, true, false), a `NaiveDate` (`2026-03-01`, the field names its form as a placeholder), and `Option<V>`, empty for `None`. Text that does not parse keeps the field open, marked invalid; leaving the field instead puts the old value back and announces it. The other cells read as read-only. |
| `validate` | `fn(&T, &V) -> Result<(), String>` | `None` | After `editable`: checks a parsed value against the row before the commit; an `Err` keeps the field open, marked invalid. |
| `editor` | `fn(EditCtx) -> Element` | the text field | After `editable`: draws your own editor in the cell. `EditCtx` gives the start `value` as text, a `label` to name it by, "Edit Age, Ana", and `commit` (the new text) and `cancel`. Focus it on mount; a commit that does not parse or validate keeps it open and sets `error`, the message the table shows under it: mark the field invalid with it, point its `aria-describedby` at `error_id` while `error` is set, and call `changed` when its text changes to clear it. |
| `filterable` | `bool` | `true` | Whether the quick filter searches the column's cell text, and whether it takes a column filter. Off for ids and codes that would match by accident. |
| `options` | `Vec<SelectOption>` | `[]` | Makes it a select column: its filter picks among these options, with the operators is and is not (one option) and is any of (several). A `SelectOption` is a `&str`, or a `(value, label)` pair: values match the raw cell text, before `format`, and are what a `ColumnFilter` holds; labels are shown. The quick filter and sorting still read the cell. |
| `hideable` | `bool` | `true` | Whether the column menu offers to hide the column. `hidden_columns` still hides it. |
| `row_groupable` | `bool` | `true` | Whether the column menu offers to group the rows by the column. `row_grouping` still groups by it. |
| `group` | `String` | `None` | Puts the column under a group header, shared with the adjacent columns of the same groups. Call it once per level, outermost first. The same name under another parent is another group, and a hidden column leaves its group. |
| `col_span` | `fn(&T) -> usize` | `None` | How many shown columns a row's cell covers, from this one on, say a total row's label. The covered cells are left out; the span stops at the row's end. Capture signals, not values: the closure is not compared. |
| `aggregate` | `Aggregate` | `None` | Adds a footer cell under the column that sums up its rows: `Sum`, `Avg`, `Min` or `Max` of the numeric cells, or `Count` of the filled ones. It covers the rows that pass the quick filter and the column filters, on every page. With `row_grouping`, each group row shows it too, over the group's rows, open or not. With `manual_pagination` it covers the loaded rows only: the table shows no total of rows it does not hold. A column without an aggregate gets an empty footer cell; with none at all there is no footer. The footer sticks to the bottom of a `max_height` table, as the header sticks to the top. Each cell names its aggregate before the value, from the localized `table.aggregate_name`. |
| `aggregate_format` | `fn(f64) -> String` | the number | The footer cell's text from the aggregate, say a price with its currency; by default the number as Rust prints it, so format a `Sum` or `Avg` of fractions. Not compared: capture signals, not values. |

`column()` is a builder, not a component, so it takes no shared props.

### table_csv()

| Prop | Type | Default | Description |
|---|---|---|---|
| `table_csv` | `fn(&[Column<T>], &[T]) -> String` | none | The header row and one line per row as CSV (RFC 4180, CRLF), each cell as its column's text, `format` applied and `render` ignored. Pass the rows and columns in the order you want; `save_file` saves it as a file. A cell that starts with `=`, `+`, `-`, `@`, Tab or CR, a plain number aside, gets a leading `'`, so a spreadsheet reads it as text, not a formula (CSV injection, OWASP). |
| `table_csv_raw` | `fn(&[Column<T>], &[T]) -> String` | none | `table_csv` with every cell as it is, formula starts included: for a reader that is no spreadsheet, or that neutralises them itself. |
| `table_text` | `fn(&[Column<T>], &[T]) -> Vec<Vec<String>>` | none | The same cells unjoined, the header row first, for your own writer. |

### TableExportButton

| Prop | Type | Default | Description |
|---|---|---|---|
| `onexport` | `EventHandler<String>` | required | Called with the table as CSV, as `table_csv` writes it (`table_csv_raw` with `csv_formula_guard: false`): the filtered, sorted rows of every page, in the shown columns. `save_file` saves it as a file: a download on the web, a save dialog on desktop, the share sheet on Android. `TableColumnsButton`, `TableDensityButton` and `TableFilterButton` take no props, and none of the four takes `class`, `sx` or `attributes`. |

## Accessibility

### Keyboard

| Key | Action |
|---|---|
| `Tab` | With `scroll` or `max_height`, when the table overflows and has no button in it: enters the scroll region, a tab stop. |
| `Left` or `Right` or `Up` or `Down` or `PageUp` or `PageDown` | In the scroll region, or on a header button inside it: scrolls the table. |
| `Enter` or `Space` | On a sortable header, a button: sorts by that column, flips it, then unsorts. |
| `Shift+Enter` or `Shift+Space` | With `multi_sort`, on a sortable header: adds that column after the sorted ones. |
| `Space` | On a row's checkbox: selects or deselects the row. On the header checkbox: selects or clears every row. |
| `Enter` or `Space` | With `row_detail`, on a row's toggle: opens or closes its detail. Tab then goes into the open detail. |
| `Enter` or `Space` | With `row_grouping`, on a group's toggle: opens or closes the group. Focus stays on the toggle. |
| `Enter` or `Space` or `Down` | With `column_menu`, on a header's menu button: opens the column menu, keyed like `Menu`. |
| `Space` or `Enter` | With `onrowreorder`, on a row's handle: lifts the row, then drops it. Up and Down move the lifted row, Home and End to the first or last place, Escape puts it back. |
| `Left` or `Right` | With `resizable_columns`, on a header's resize grip: moves it 10px the way the arrow points, 50px with Shift. |
| `Home` or `End` | On a resize grip: narrows the column to its minimum, or widens it to its maximum when it has one. |
| `Left` or `Right` or `Up` or `Down` | With `cell_focus`, on a header or body cell or a button in one: moves to the next cell that way, stopping at the edges. A cell spanning columns or header rows is one stop. |
| `Home` or `End` | With `cell_focus`, on a cell: moves to the row's first or last cell. |
| `Ctrl+Home` or `Ctrl+End` | With `cell_focus`: moves to the first header cell or the last row's last cell, scrolling it into view. |
| `PageUp` or `PageDown` | With `cell_focus`: moves up or down by the rows one view shows, 10 when the view cannot be measured. |
| `Enter` or `Space` | With `cell_focus`, on a sortable header cell itself: sorts by that column, as its button does. Focus stays on the cell. |
| `Ctrl+Enter` | With `cell_focus` and `column_menu`, on a header cell: opens its column menu, the keyboard way to its Filter and width items too. |
| `Shift+Space` | With `cell_focus` and `selectable`, on a body cell: selects or deselects its row. |
| `Right` | With `parent_key`, on a row: opens a closed row; on an open one moves to its first child, or with `cell_focus` to its first cell. |
| `Left` | With `parent_key`, on a row: closes an open row, else moves to its parent. With `cell_focus`, on a row's first cell: moves to the row. |
| `Up` or `Down` or `Home` or `End` or `PageUp` or `PageDown` | With `parent_key`, on a row: moves to the row before or after it, the first or last row, or by the rows one view shows. Ctrl+Home and Ctrl+End do as Home and End. |
| `Enter` | With `parent_key` and `onrowclick`, on a row: what a click on it does. |
| `Enter` or `F2` | On an editable cell: opens its editor, the field focused and its text selected, so typing replaces it. A second tap on the stop cell does the same on a touch screen. |
| `Enter` or `Shift+Enter` | In a cell's editor: commits the value and moves to the cell below or above. A value that does not parse or validate keeps the editor open, with its message under it. |
| `Tab` or `Shift+Tab` | In a cell's editor: commits the value and moves to the next or previous cell; the editor of that one opens with `Enter`. |
| `Space` | In a `bool` or `Option<bool>` cell's editor, a checkbox: toggles it. An `Option<bool>` one cycles empty, true, false. |
| `Escape` | In a cell's editor: puts the value back and returns focus to the cell. |
| `Escape` | In a filter popover: closes it and returns focus to the button that opened it: the column's menu button, or its filtered-header button. |
| `Tab` or `Shift+Tab` | In a filter popover: moves between its fields; past either end it closes and Tab goes on from the button that opened it. |

### Libero handles

- A debug build warns about an unnamed table, about `selectable`, `row_detail`
  or `onrowreorder` without `row_key`, about `selectable` with a first row
  whose name cell has no text, about an editable column without
  `onrowupdate`, and about a pinned column after one with no `width`.
- `.row_header()` cells are `th scope="row"`, so a screen reader reads the
  row's name as it moves down any other column. A group header is a `th
  scope="colgroup"`, read with each cell under it.
- With `scroll` or `max_height`, an overflowing table with no button in it is
  a named region and a tab stop, so the arrows can scroll it. With header
  buttons there is no extra stop: the arrows scroll from a focused button.
- Only sorted headers carry `aria-sort`. With `multi_sort`, each sort button's
  name adds its place, "sort order 2", and a tap always adds the column, as
  touch has no Shift.
- Each row's checkbox is named "Select" plus the row's name: the row header's
  text, else the first cell's, else the row's key ("Select 0"), so give that
  column text. The header
  checkbox reads mixed while some rows are selected. A selected row carries
  `aria-selected="true"`.
- Each detail toggle is a button named "Details for" plus the row's name, with
  `aria-expanded` and, while open, `aria-controls`.
- Each group toggle is a button named by the group's text and row count,
  "Admin, 2 rows", with `aria-expanded`; opening or closing it is said in a
  polite live region, "Admin expanded". The table keeps its table role: group
  rows are rows with a button, not a tree.
- A polite live region says what changed: the selected count, "2 rows
  selected"; the page range when the page or its size changes, "4–6 of 7"; a
  sort the reader picks, "Sorted by Age, ascending"; the rows left after a filter, "2
  rows"; the rows loaded by `onbottomreached`, "200 rows"; an export,
  "Exported 12 rows". The first render says nothing.
- Page buttons sit in a `nav` named after the caption, and the page-size
  picker is labelled. The quick-filter is a labelled search field described by
  the table's name, so two tables' fields differ.
- Filter popovers and the filter panel are named dialogs with labelled fields. A select column's Is any of is a named group of checkboxes, one per option, and in the header filters row a named multi-select.
  Focus moves in on open, and Escape closes them onto their button. A filtered
  header reads "Age is filtered".
- Each column menu button is named after its column, "Age column options". It
  shows on hover or focus, always on touch. A move (a header drag too), pin, hide (from any Columns menu too) or width
  change is said in a polite live region, a pin the room releases at once as "Name not pinned: not enough room", and the last shown column cannot be hidden:
  its controls say why.
- Pinned and moved columns move in the DOM too, so Tab and a screen reader
  meet the cells in the order they are seen.
- Rows and columns reorder without a drag (WCAG 2.5.7): a row has a named
  handle plus Move up and Move down buttons, a column moves from its menu. The
  header drag grip is pointer only and hidden from screen readers. While
  sorted or filtered the row controls stay tab stops but are `aria-disabled`
  and say why.
- Each resize grip is a tab stop, except in a `cell_focus` grid with
  `column_menu`, whose width items stand in for it; it is a vertical
  `role="separator"` named "Resize"
  plus the column, with its width and limits in `aria-valuenow`,
  `aria-valuemin` and `aria-valuemax`.
- `loading` marks an empty table `aria-busy`. With rows shown it adds a
  progress bar named "Loading rows" instead, as some screen readers hold back
  a busy table's rows.
- With `virtual_row_height`, `aria-rowcount` and `aria-rowindex` give the full
  count and each row's place, "row 5 001 of 10 001". Tab walks past the
  rendered rows, and the row holding focus stays rendered.
- A footer cell reads its aggregate's name before the value, "Average 7.8 %",
  and sits in the column its header names. In a `virtual_row_height` table the
  footer is the last counted row, and a focus scroll stops above it.
- The `toolbar` is a plain row, not a `role="toolbar"`: Tab moves through it
  as anywhere else.
- With `cell_focus`, the table is a `role="grid"` and one header or body cell
  is its tab stop, `tabindex="0"`, the rest `-1`, so Tab passes the grid in one
  step. A header cell's sort, menu and filtered buttons, and its resize grip
  with `column_menu`, are `tabindex="-1"` too: the cell is the one stop and its
  keys do their work. Up and Down pass by the `header_filters` row, text fields
  reached by Tab, whose arrows move the caret, and by group rows, whose toggles
  are stops of their own. Cells, column and row headers keep their roles; in a
  `virtual_row_height` table the focused cell's row stays rendered. The grid is
  `aria-readonly` without an editable column, `aria-multiselectable` with
  `selectable`.
- With `parent_key`, the table is a `role="treegrid"`: each body row carries
  `aria-level`, `aria-posinset`, `aria-setsize`, and `aria-expanded` when it has
  children or `row_has_children` says it will, `aria-busy` while open before they
  load, and one row is the tab stop, the first until focus moves. The row
  toggles are no Tab stops, as Left and Right do their work, and stay in the
  reading order. A collapse or filter that hides the focused row moves the stop,
  and the focus, to its nearest shown parent. With `cell_focus` its cells are
  stops too and the first header cell is the first.
- In a grid with an editable column, the other cells are `aria-readonly`. The
  editor is a text field named "Edit" plus the column and the row's name, "Edit
  Bonus, Ana", a number column's with a numeric keypad when its type has no
  sign (a signed one keeps the text keyboard for the minus) and a `bool`
  column's a checkbox, mixed while an `Option<bool>` is empty. A value that does not
  parse or validate marks it `aria-invalid`, shows the `validate` message (or
  "Not a valid value") under it, linked by `aria-describedby`, and announces it
  once; typing clears it. A custom `editor` gets the message as `EditCtx::error` and clears it with `EditCtx::changed`.
  On a touch screen, which has no Escape, a Cancel edit button sits beside it.
- With `sticky_header`, a focus scroll stops below the header, so a focused cell
  is never hidden under it (WCAG 2.4.11).

### You must

- Name every table: `caption` shows a title, `aria_labelledby` points at a
  heading already on the page, `aria_label` names it without text.
- Set `scroll: true` on a table wider than its container, or `max_height` on a
  long one.
- Mark the column that names a row with `.row_header()`.
- With `onrowclick`, also put a button or link for that action in a cell. A
  row is not a tab stop, so a keyboard cannot click it.
- With `selectable` or `row_detail`, give the rows a `.row_header()` column,
  so each checkbox and toggle gets a unique name.
- Keep `csv_formula_guard` on, and `table_csv` over `table_csv_raw`, when a
  CSV of text users typed can reach a spreadsheet (CSV injection, OWASP).

### Example

A stock list with `caption: "Stock"`, `row_detail` and `.row_header()` on the
Name column. A screen reader announces the "Stock" table, reads "Cherry" with
each cell of that row, and names the row's toggle "Details for Cherry".

### Limits

- On Blitz, once a `max_height` table's rows scroll, a click on a header's sort
  or menu button misses: Blitz hit-tests the header where it sat before the
  scroll. Tab to the button and press Enter instead.
- On Blitz, the same holds for a pinned column's cells once the table scrolls
  sideways. In a right-to-left page Blitz cannot scroll a wide table at all
  (todo 707), so pinning shows no effect there.
- On Blitz, a `max_height` table's scrollbar is the native one and runs past
  the header too.
- On Blitz, a `sticky_header` holds against the window and a `ScrollArea` as on
  the web, but whether a focus scroll leaves the focused cell clear of it is not
  checked: Blitz reports no `scroll-margin-top` back.
- On Blitz, a `max_height` table with column groups keeps only its last header
  row in place; the group rows scroll away with the rows. The same holds for
  the `header_filters` row.
- On Blitz, a row's handle does not drag: Blitz paints no moved table row. The
  keyboard and the move buttons reorder there.
- On Blitz, a header has no drag grip: columns reorder from the column menu
  there.
- Under a finger, a `virtual_row_height` table's reorder controls stand side by
  side in the row's height, so their press reach stops at the row's edge: set it
  at 44 or more for a 44px target.
- The footer and the leading checkbox, detail and reorder cells carry no
  `aria-colindex`; the leading cells sit at the first places.
- On Android, the arrows, the page keys, Enter and F2 do not reach a
  `cell_focus` grid or a tree's rows in the emulator's WebView (todo 958); a
  tap, a double click and a second tap do.
- How TalkBack reads a `cell_focus` grid or a treegrid is not checked yet.
- On Android, the filter popover cannot look into itself, so Tab does not close
  it at its ends and focus lands on the popover rather than its value field;
  Escape and Back close it.

## Theme defaults

`TableDefaults` on the theme.

| Field | Type | Description |
|---|---|---|
| `size` | `Size` | The size when the prop is unset, `Md`. |
| `sizes` | `Sizes<TableSizeLevel>` | Per size: `font_size`, `padding_x` and `padding_y` of every cell. `Md` is 1rem (16px), 12px and 10px. |
| `border_color` | `ColorValue` | Color of the header and row rules. |
| `hover_color` | `Option<ColorValue>` | Row background while hovered. `None`, the default, takes the theme's row hover tint: the first muted step that shows at 1.15:1 on the page and the card. |
| `stripe_color` | `Option<ColorValue>` | Every other body row's background with `striped`. `None`, the default, takes a lighter muted step than the hover that still shows at 1.05:1 on the page and the card, so a hovered stripe still changes. |
| `selected_color` | `ColorValue` | A selected row's background, hovered or not, `primary.1`. |
| `group_color` | `ColorValue` | A group row's background with `row_grouping`, `muted.1`. |
| `group_indent` | `&'static str` | How far each nested group's toggle moves in, `20px`. |

## CSS variables

| Variable | Description |
|---|---|
| `--lsx-table-font-size-{size}` | `font-size` of the table at that size. |
| `--lsx-table-padding-x-{size}` | Horizontal padding on every `th`/`td` at that size. |
| `--lsx-table-padding-y-{size}` | Vertical padding on every `th`/`td` at that size. |
| `--lsx-table-pad-x`, `--lsx-table-pad-y` | The padding resolved on the table for its size. |
| `--lsx-table-border-color` | Color of the `1px` header and row rules. |
| `--lsx-table-hover` | `background` of a hovered body row. |
| `--lsx-table-stripe` | `background` of every other body row with `striped`. |
| `--lsx-table-selected` | `background` of a selected body row. |
| `--lsx-table-group` | `background` of a group row. |
| `--lsx-table-group-indent` | How far each nested group's toggle moves in. |

## Data attributes

`data-align` on a `th`/`td` carries the cell alignment, and is omitted for the
default `start`.

| Attribute | Condition |
|---|---|
| `data-align="center"` | The column's alignment is `center`. |
| `data-align="end"` | The column's alignment is `end`, as for every numeric cell type. |
| `data-sortable` | On a sortable header. |
| `aria-sort` | On sorted headers only, `ascending` or `descending`. |
| `data-sort-order` | On the place badge inside a sorted header's button, with two or more sorted columns. |
| `data-select` | On the checkbox column's `th` and `td`s. |
| `aria-selected` | On every body row of a `selectable` table, `true` or `false`. |
| `data-empty` | On the body row that holds `empty`, `no_results` or their text. |
| `data-skeleton` | On each placeholder row of a `loading` table without shown rows. |
| `data-loading-bar` | On the box holding the progress bar of a `loading` table with shown rows. |
| `data-toolbar` | On the row above the table with `toolbar`; `data-toolbar-end` on the quick filter's box in it. |
| `data-detail-toggle` | On the toggle column's `th` and `td`s, with `row_detail`. |
| `data-detail` | On an open detail row, right after its row. |
| `data-stripe` | On every other body row with `striped`, detail rows not counted, group rows counted. |
| `data-row-group` | On a group row with `row_grouping`; `data-level` gives its depth, 0 outermost. |
| `data-group-toggle` | On a group row's toggle, holding `data-group-label` and `data-group-count`. |
| `data-group-lead` | On a group row's one cell over the lead columns, the checkbox column aside: with `selectable` the group's box has a `td[data-select]` of its own. |
| `data-group-aggregate` | On a group row's aggregate, an aggregating column's name and value over the group's rows. |
| `data-level` | On a body row with `parent_key`: its depth in the tree, 0 for a root. |
| `data-node-toggle` | On a tree row's toggle in its first shown cell, with `parent_key`; `data-node-spacer` on a leaf's spacer in its place; `data-node-cell` on the block holding either and the cell's content. |
| `data-reorder` | On the reorder column's `th` and `td`s, with `onrowreorder`. |
| `data-dragging` | On the body row being dragged or moved by keyboard. |
| `data-cell-stop` | On the header or body cell that is the tab stop, with `cell_focus`, or on the tree row that is, with `parent_key`. |
| `data-editing` | On the body cell whose editor is open; `data-cell-editor` on the editor's box in it, `data-cell-editor-cancel` on its cancel button, shown on a touch screen only. |
| `data-group` | On a column group's header cell. |
| `data-footer-lead` | On the footer's one cell over the lead columns, with an aggregating column. |
| `data-footer-name` | On the span naming an aggregate before the value in a footer cell. |
| `data-pin` | On a pinned column's `th` and `td`s, `start` or `end`. |
| `data-pin-edge` | On the pinned cells next to the scrolled columns, which draw a rule there. |
| `data-state` | On the table: `size-{size}`, plus `striped` and `row-click` when set, `pinned` with a pinned column and `pin-select` when the checkbox column pins too, `pin-detail` when the detail toggle column does, `pin-reorder` when the reorder column does, `sticky-footer` with `max_height`. On a body row: its active `row_states`. |
| `data-slot="range"` | On the paginated table's range text, "1–10 of 95". |
