CellSelect
Compact select styled as a settings cell
Usage
import {CellSelect} from "@peakui-pro/react";Anatomy
The list inside the popover composes the core ListBox, whose items carry the checkmarks.
import {CellSelect} from "@peakui-pro/react";
import {ListBox} from "@peakui/react";
// Rendered as: the Trigger (a <button>), the Label leading, the Value after it,
// the Indicator last, and the Popover's list below the row's end.
export default () => (
<CellSelect aria-label="Theme" defaultSelectedKey="default">
<CellSelect.Trigger>
<CellSelect.Label>Theme</CellSelect.Label>
<CellSelect.Value />
<CellSelect.Indicator />
</CellSelect.Trigger>
<CellSelect.Popover>
<ListBox>
<ListBox.Item id="default" textValue="Default">
Default
<ListBox.ItemIndicator />
</ListBox.Item>
</ListBox>
</CellSelect.Popover>
</CellSelect>
);Examples
Variants
variant restyles the row and its fill together.
Controlled
Settings Group
The row's leading label names the select; the cell fills the value column.
Custom Value
Font Family
Dynamic Items
A Collection with items inside the ListBox builds the list from data.
Disabled
Customization
Tailwind CSS
<CellSelect aria-label="Theme" className="w-full">
<CellSelect.Trigger>…</CellSelect.Trigger>
</CellSelect>Global CSS
@layer components {
/* The row's surface; the secondary variant swaps tone for shadow. */
.cell-select__trigger {
@apply rounded-lg;
}
}Styling Reference
PeakUI follows the BEM methodology, so variants and states are plain class names you can target.
CSS Classes
The CellSelect component uses these CSS classes (view source styles):
Base Classes
.cell-select- The root; fills the row a settings table gives it
Element Classes
.cell-select__trigger- The visible cell row; a surface 36px high with the label leading.cell-select__trigger--default- The default trigger variant.cell-select__trigger--secondary- A quieter row:bg-default-softwith no surface shadow.cell-select__label- The leading label; takes half the row's room and truncates.cell-select__value- The selected value; muted, end-aligned, takes the trailing half.cell-select__indicator- The chevrons glyph at the row's end; in flow at 12px.cell-select__popover- The popover the list opens in; the core Select's own beside the cell's name
Slots
[data-slot="cell-select"]- The root element[data-slot="cell-select-trigger"]- The row[data-slot="cell-select-label"]- The label[data-slot="cell-select-value"]- The value[data-slot="cell-select-indicator"]- The indicator; a custom child element takes the slot onto itself[data-slot="cell-select-popover"]- The popover
API Reference
CellSelect
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'secondary' | 'default' | The cell's own variant axis; it shadows the core Select's, which the cell does not take |
children | ReactNode | - | The parts |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', SelectRenderProps> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<typeof SelectRoot> | - | The core Select root's props: selectedKey, defaultSelectedKey, onSelectionChange, isDisabled, aria-label, items and the rest of React Aria's Select attributes |
CellSelect.Trigger
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | ((values) => ReactNode) | - | The row's content — the Label, the Value and the Indicator |
className | string | - | Additional classes |
render | DOMRenderFunction<'button', ButtonRenderProps> | - | Replaces the rendered <button> with your own element |
...rest | ComponentProps<typeof SelectTrigger> | - | The core Select.Trigger's props, React Aria's Button attributes among them |
CellSelect.Value
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | ((values) => ReactNode) | - | Custom content; the selected item's text renders without it. As a function it receives the selected item |
className | string | - | Additional classes |
render | DOMRenderFunction<'span', SelectValueRenderProps> | - | Replaces the rendered <span> with your own element |
...rest | ComponentProps<typeof SelectValue> | - | The core Select.Value's props, React Aria's SelectValue attributes among them |
CellSelect.Indicator
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | A custom indicator element; it takes the classes, the slot and the open state onto itself |
className | string | - | Additional classes |
render | DOMRenderFunction<'span', undefined> | - | Replaces the rendered element with your own; the default child is the IconChevronsExpandVertical glyph |
...rest | ComponentProps<'span'> | - | Native <span> attributes, handed to the indicator element |
CellSelect.Popover
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The list; composes the core ListBox |
placement | Placement | 'bottom end' | Where the list lands; the core's own default is 'bottom' |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', PopoverRenderProps> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<typeof SelectPopover> | - | The core Select.Popover's props, React Aria's Popover attributes among them |
CellSelect.Label
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The label text |
className | string | - | Additional classes |
render | DOMRenderFunction<'span', undefined> | - | Replaces the rendered <span> with your own element |
...rest | ComponentProps<'span'> | - | Native <span> attributes |