RowSelection
RowSelection is a legacy migration surface: one row's selection control for the Rust crate — an input the sheet would keep out of sight under a hand-drawn control (its class has no sheet rule today — see Accessibility), checked from the host's selected_keys and reporting the row key on press. It is the per-row half of the selection column; the column that draws every row and the select-all row is Selection.
New code should use HkTable's selectable column, which renders one checkbox per row and its select-all header, and reports the chosen rows through v-model:selectedRows. A standalone checkbox that is not about rows at all is HkCheckbox.
- Reach for RowSelection while migrating a Rust page that draws its own row markup and needs the control at its head; on a new table use HkTable's selectable.
- The two shapes it can draw are a checkbox with a tick glyph and a radio with a filled dot, chosen by selection_type.
- The column that owns every row is Selection; the data cells beside it are Cell.
Import
use *; // RowSelection, SelectionType
use *; // RowSelectionProps, rsx!, VNode
RowSelection is a plain function, RowSelection(RowSelectionProps { … }). Inside rsx! row_key may be omitted (empty string) even though it is the only field without a default — the macro fills it — so every prop has a value; selected_keys defaults to empty, selection_type to SelectionType::Checkbox, class to "" and on_select to None. RowSelectionProps is in the prelude and SelectionType is not (take it from hikari_components when you name it).
One checkbox
The control is div.hk-row-selection → label.hk-row-selection-label → input.hk-row-selection-input (the input the sheet would keep out of sight, if a stylesheet covered its class — see Accessibility) → span.hk-row-selection-custom, which gets hk-row-selection-checked when row_key is in selected_keys. A checked checkbox adds the tick SVG inside that span; an unchecked one leaves it empty.
The radio shape
selection_type: SelectionType::Radio swaps the drawn control for a dot: a checked radio renders span.hk-row-selection-radio-dot instead of the tick, and every instance shares name="hk-selection-radio-group" so the browser keeps them mutually exclusive.
The input's attribute name is written as a raw identifier (r#type), so no type attribute ever reaches the DOM whatever the mode. The visible shape and the shared name come from selection_type; the "type" does not follow it — see Accessibility.
In a row, and host classes
The component takes no row content: it is the control, and the host places it beside the row's own markup (the samples above put a span next to it in a flex row). class lands on the outer div after hk-row-selection, so it is how a host re-skins one row's control; there is no style prop.
on_select is an EventHandler<String> that fires with row_key when the input changes. The component keeps no state of its own — selected_keys is the whole truth, so a host that does not feed the new list back sees the tick stay where it was. A snapshot never runs the handler.
API
Rust
Props — RowSelection
| Prop | Type | Default | Description |
|---|---|---|---|
| row_key | String | "" | — |
| selected_keys | Vec<String> | [] | — |
| selection_type | SelectionType | SelectionType::Checkbox | — |
| class | String | "" | — |
| on_select | Option<EventHandler<String>> | None | — |
Accessibility
- The input is not a native checkbox. The mirror writes the attribute as a raw identifier (r#type), which rsx emits verbatim: the markup is <input checked="checked" name="" r#type="checkbox" class="hk-row-selection-input">. No type attribute reaches the DOM, so nothing announces a checkbox — and the class that would hide the box (hk-row-selection-input) has no rule in any sheet, so the untyped input also renders as a visible, unpositioned field. Verified by rendering the component.
- Pressing the drawn box still toggles the row, because the <label> wraps both the input and the span; the state itself is correct, only its exposed role is not.
- The input has no accessible name: there is no <label for>, no text inside the label, and no aria-label. Its name is empty, so the row's text has to supply the meaning — outside the control, as in the samples.
- The drawn span is decorative (a tick glyph or a dot), but it is a bare <span> with no aria-hidden; nothing marks it as such.
- Because there is no live type attribute at all, a radio-shaped row is not announced as a radio either. Host HkRadioGroup wherever the "pick one of these" meaning matters — Selection's radio mode carries the same missing attribute and cannot stand in for one.
- Nothing writes aria-selected or aria-current on the row; selection state lives only in the input.
Related components
- Selection — the whole selection column, including the select-all row.
- HkTable — the Vue table whose selectable column is the built-in replacement for this control.
- HkCheckbox — a standalone checkbox with a label, when the choice is not a table row.
- Cell — the data cells a row pairs with.
- Table — the component page for the Rust table this control was written for.