Foundations
Layout and density
Kanso lays screens out on a 4px grid, in window size classes, at two densities: comfortable for touch and compact for the web.
The grid, live
space-2xl· 24pxspace-2xs· 2pxspace-3xl· 32pxspace-4xl· 40pxspace-5xl· 56pxspace-lg· 16pxspace-md· 12pxspace-sm· 8pxspace-xl· 20pxspace-xs· 4px
Spacing
Every gap and inset is a step of the spacing scale. Kanso's is kui-spacing-kanso-2xs (2px) to kui-spacing-kanso-5xl (56px); Stack's gap takes the library's names for the same 4px steps, xxs (2px) to xxxl (40px), with xsPlus (6px) and lgPlus (20px) between them. The common ones:
- 16px (
kui-spacing-kanso-lg,gap="lg"): card padding, the phone's side margin, the gap inside a card. - 12px (
kui-spacing-kanso-md,gap="md"): between a row's lead and its text; between cards on a phone. - 24px (
kui-spacing-kanso-2xl,gap="xl"): between blocks on the web. - 32px and 40px (
kui-spacing-kanso-3xland-4xl,gap="xxl"and"xxxl"): page gutters on the web and on wide windows.
Space belongs to the container, not the child: a Stack sets the gap between its children, and no component carries an outer margin.
Window size classes
| Class | Width | Navigation | Layout |
|---|---|---|---|
| Compact | under 600px | NavigationBar at the bottom | One column; the FAB for the main creation action. |
| Medium | 600 to 839px | NavigationBar | One or two columns; cards may sit side by side. |
| Expanded | 840 to 1199px | A pane on the left | A main column and a side column. |
| Large | 1200 to 1599px | A pane | The same, with wider gutters. |
| Extra-large | 1600px and up | A pane | The same; text columns keep their measure. |
Line a design's own media queries up with these; they are not custom properties, since a media query cannot read one. ListDetail, SupportingPane, Dialog and Sheet change arrangement at them: a dialog fills the window below medium, and a sheet arrives from the bottom edge on a narrow window rather than from the side.
Lay screens out for compact first, then let columns appear as room grows. Text columns stay near 65 characters wide even on large windows; Container holds the measure.
Density
| Comfortable (phones, tablets) | Compact (web) | |
|---|---|---|
| Controls | kui-sizing-kanso-control-lg, 48px | kui-sizing-kanso-control-md, 40px, or -sm, 32px |
| Rows | kui-sizing-kanso-row, 60px, two lines | kui-sizing-kanso-row-compact, 44px, one line |
| Body text | t-body, 15px | t-body-small, 14px |
| Cards | kui-radius-kanso-2xl | kui-radius-kanso-xl |
Density changes sizes, never the order or the content. A web table row and a phone list row show the same facts.
The components keep their families' heights until each one moves: kui-sizing-control-xs (32px) to -xxl (136px) for controls and kui-sizing-row-xs (48px) to -lg (88px) for list rows. A theme can restate those tokens, which is the one axis of density a scheme has today.
Composition
- Put the page title block (date line and title) at the top, then the spotlight, then the summary, then the rest. On wide windows the spotlight and a form move to the side column (
SupportingPane), and a list can become aTable. - Keep the primary action reachable with the thumb on phones: the spotlight's main button, the FAB above the navigation bar.
- Align figures on the right edge of their row or column, in mono.