Components
List
Inset rows with a label, a description and a trailing control, action or chevron.
import { List, Switch } from "@openperf/deft";
<List.Root>
<List.Field description="Sent every Monday." htmlFor="digest" label="Weekly digest">
<Switch.Root id="digest" />
</List.Field>
</List.Root>;When to use
| Need | Component |
|---|---|
| One setting, record or destination per row | List |
| A few hand-composed rows in aligned columns | Table |
| Records with shared columns, sorting or selection | Data table |
| Read-only attributes of one object as key and value | Key value |
Anatomy
<List.Root>
<List.Item>
{/* or List.Field for a labeled control */}
<List.Icon /> {/* optional */}
<List.Header>
<List.Label />
<List.Description />
</List.Header>
<List.Control /> {/* or List.Actions / List.Chevron */}
</List.Item>
<List.Empty /> {/* instead of rows */}
</List.Root>List.Field renders the item, header, label, description and control slot around its children. Fill List.Empty with Empty.Title and Empty.Description from Empty.
Layouts
layout on List.Item and List.Field sets how the header and List.Control share the row. The breakpoint follows the width of the list, not the viewport.
| Layout | List narrower than 576px | List 576px or wider |
|---|---|---|
inline | One line; the control takes half the row | One line; control 256px |
wrap | Control on its own full-width line | One line; control 256px |
stacked | Header above the control | Header above the control |
Records
variant="tile" on List.Icon draws a 28px bordered box: an icon is centered in it and an Avatar fills it.
Links
Pass a link to render on List.Item to make the whole row navigate, and end it with List.Chevron.
Buttons
Pass a <button> to render when the row opens something or picks an option. A disabled button keeps its place but loses the hover state and the pointer cursor.
API
List.Item
Prop
Type
List.Field
Also takes the props of List.Item. Without htmlFor the label is not bound to the control: set aria-label on the control. List.Label takes the same htmlFor.
Prop
Type
List.Icon
Prop
Type