Foundations
Spacing and sizes
The spacing steps, control heights and row heights that Deft components share.
Deft spaces everything on Tailwind's 4px scale and adds named tokens for the paddings and heights that repeat across components.
Spacing scale
The numeric steps are Tailwind's defaults, and Deft does not redefine them. One step is 4px, so gap-2 is 8px and px-3 is 12px. Components stay on a short list of steps:
| Step | Value | Where components use it |
|---|---|---|
px | 1px | Gap between table rows, between menu items and between sidebar items. |
0.5 | 2px | Gap between the buttons of a Toolbar and of an Action bar. Padding of the Tabs list. |
1 | 4px | Padding of Menu, Select and Combobox popups and of List. Gap inside Chip and Badge. |
1.5 | 6px | Gap between the icon and the label of a button. Gap between the parts of a Field. |
2 | 8px | Side padding of sm buttons, chips and menu items. Gap inside Input, table cells and menu items. Gap between the buttons of a Dialog footer. |
2.5 | 10px | Side padding of md buttons, Input and sidebar items. |
3 | 12px | Side padding of table rows and the gap between their cells. Padding of List items, Panel and Popover. |
5 | 20px | Side padding of the Dialog header, body and footer. |
When you lay out your own content, start from these steps: 8px between controls in a row, 12px between cells and inside panels.
Page padding
Two named distances set the side padding of a page. They are declared as --spacing-* variables in theme.css, so they work with every spacing utility.
| Token | Utility | Value | Use |
|---|---|---|---|
--spacing-inset | px-inset | 20px | Side padding of Shell.Bar. The dashboard uses it as the page padding below the md breakpoint. |
--spacing-gutter | px-gutter | 32px | Page padding in the dashboard from the md breakpoint up. |
The two differ by 12px, which is the side padding of a table row. A Table pulls its rows out by that amount, so inside a px-gutter page the hover fill of a row starts 20px from the edge while the cell text stays on the 32px line.
<div className="px-inset md:px-gutter">{children}</div>Control and row heights
Every control and row takes its height from a token, so a button, an input and a select placed side by side line up.
| Token | Utility | Value | Use |
|---|---|---|---|
--spacing-control-xs | h-control-xs | 22px | Button size="xs", Tabs tabs, Tag. |
--spacing-control-sm | h-control-sm | 26px | Button size="sm": the default of Toolbar buttons and the size of the close buttons in Dialog, Drawer, Toast and Action bar. Menu items with size="sm". Sidebar.Pill. |
--spacing-control-md | h-control-md | 28px | The default. Button size="md", Select and Combobox triggers, Input, menu, select and combobox items, sidebar items, Property, the Table header row. |
--spacing-control-lg | h-control-lg | 30px | No Deft component uses it. The dashboard uses it for skeleton placeholders and the row of the error occurrence navigator. |
--spacing-chip | h-chip | 24px | Chip. |
--spacing-row | h-row | 32px | Table rows at the default density. |
--spacing-row-compact | h-row-compact | 28px | Table rows with density="compact", legend rows of Meter.Parts, Waterfall rows with density="tree". |
--spacing-row-dense | h-row-dense | 26px | Table rows with density="dense", Waterfall rows with density="flat". |
Rules:
- Set the height through the
sizeordensityprop of the component. The props map to these tokens. Writeh-control-*yourself only for an element that has to line up with a control, such as a skeleton placeholder. - Controls have a fixed height. Menu items,
Section.Header,Block.Headerand table rows use the token as a minimum height and grow when their content wraps. - Table rows sit 1px apart and have no divider lines.
- A
size="inline"button has no fixed height. It inherits the font size of the text around it and adds 3px of vertical padding.
Fixed sizes
Some elements do not use the control scale. Their sizes are fixed in the component.
| Element | Size |
|---|---|
| Badge, Kbd | 18px high |
| Switch | 18px by 32px |
| Checkbox | 16px, or 14px with size="sm" |
| Dot | 6px |
| Avatar | 16, 18, 20, 22 or 40px for xs, sm, md, lg, xl |
| OTP input cell | 44px high |
| List item | 48px minimum |
Layout widths
| Token | Utility | Value | Use |
|---|---|---|---|
--spacing-sidebar | w-sidebar | 232px | Width of Sidebar. left-sidebar offsets a Backdrop inside a Shell from the md breakpoint up. |
--breakpoint-md | md: | 900px | From this width the sidebar is a column beside the content. Below it the sidebar opens as an overlay and Shell.Bar shows its trigger. |
--container-table-compact | @max-table-compact: | 52rem | A table narrower than this switches to its compact column template and hides cells with priority="low". |
--container-table-stacked | @max-table-stacked: | 36rem | A table narrower than this stacks each row, hides the header and hides cells with priority="medium". |
The two table tokens are container widths, not viewport widths: a table reacts to the space it gets, wherever it is placed.