Foundations
Icons
The Tabler icon set, the sizes components give icons and the colors that show state.
Deft takes its icons from @tabler/icons-react. Components set the size and color of the icons you put inside them, so in most places you render the bare icon.
Usage
Deft does not re-export icons. Import them from @tabler/icons-react and pass them as children, or as a component reference where a part has an icon prop.
import { Button, Input } from "@openperf/deft";
import { IconDots, IconPlus, IconSearch } from "@tabler/icons-react";
export const ProjectToolbar = () => (
<>
<Input.Root icon={IconSearch} placeholder="Search" />
<Button.Root>
<IconPlus />
New project
</Button.Root>
<Button.Root aria-label="More actions" shape="square" variant="ghost">
<IconDots />
</Button.Root>
</>
);Input.Root, Sidebar.Item, Select.Item, Combobox.Item and Chart.Marker take icon as a component (icon={IconSearch}), not as an element. They render it with aria-hidden.
Sizes
A Tabler icon is 24px by default. Deft components resize the icons inside them with a rule on the .tabler-icon class, which every Tabler icon has.
| Size | Class | Where |
|---|---|---|
| 10px | size-2.5 | Check mark of a Checkbox with size="sm" and of the checkbox items in Menu and Combobox. |
| 12px | size-3 | Chip, Tag, check mark of the default Checkbox, sort arrows in a Table header, Avatar sm and md, Chart.Marker. |
| 14px | size-3.5 | Button with size="xs", Menu and Combobox items, Tabs tabs, Avatar lg. |
| 16px | size-4 | Button with size="sm" or size="md", Select and Combobox triggers, Input, Select items, table cells, List, sidebar items, Property, Toast, Spinner. |
| 20px | size-5 | Breadcrumb separator, Avatar xl. |
Rules:
- Do not add a size class to an icon inside a Button, a Menu, Select or Combobox item, a Tabs tab, a Chip, a Tag, an Avatar,
List.IconorSidebar.Item. The part sets it. - A Button with
size="inline"sizes its icon to1em, so the icon follows the text around it. Table.CellandSidebar.Itemsize only icons that are their direct children. An icon nested deeper keeps 24px until you give it a class, as the dashboard does for the status icon of its error list:<StatusIcon className="size-3.5" />.- Outside these parts an icon has no size rule. Always give it a
size-*class.
Stroke
The base styles in theme.css set stroke-width: 1.75 on every .tabler-icon. Tabler's own default is 2.
Small check marks use a heavier stroke:
| Stroke | Where |
|---|---|
| 2.5 | Check and minus marks of Checkbox. Check marks of the checkbox items in Menu and Combobox. |
| 2 | Check mark of the selected item in Select, Combobox and Menu radio items. |
To change the stroke, use a class such as stroke-2. The stroke prop of a Tabler icon writes an SVG attribute, and the base rule overrides it.
Filled icons, whose names end in Filled, have no stroke. Toast uses them for its status icons.
Colors and states
Icons draw in currentColor. They take the text color of their parent unless a component or a class sets another one.
| State | Utility | Where |
|---|---|---|
| Resting | text-icon | Icons in default, field and ghost buttons, in menu items, tabs and tags, in Input, List, Property and sidebar items. |
| Current | text-default | Icon of the current sidebar item. Sort arrow of the sorted table column. |
| Decorative | text-subtle | Chevrons and selectors that only hint at behavior: the expand chevron of a table row, the submenu arrow, List.Chevron, Sidebar.Pill, Sidebar.User. |
| Selected | text-accent | Check mark of the selected item in Select, Combobox and Menu radio items. |
| On a fill | Inherited | Icons in primary buttons are text-on-accent. Icons in danger buttons and in menu items with tone="danger" are text-danger. |
| Status | text-success, text-warning, text-danger | Toast status icons. In the dashboard: unresolved errors are text-warning, regressed errors text-danger, resolved errors text-success. |
Rules:
- A resting icon is quieter than its label:
text-iconnext totext-secondaryortext-defaulttext. Indefault,fieldandghostbuttons the icon keepstext-iconon hover while the label turnstext-default. - Use a status color only for a status. An archived or ignored error in the dashboard keeps
text-icon. - Do not rely on color alone. The dashboard puts the status name next to each status icon.
Label icon-only buttons
An icon has no text, so a button that holds only an icon needs an aria-label. Deft does this for its own close buttons in Dialog, Drawer, Toast and Action bar. Use shape="square" for such a button so that it is as wide as it is tall.