Sizing
How tall controls are as shipped, which sizes to pair, and how to size a screen or a region for fingers with touch-controls.
Sizing in Silkware is the sizing of the upstream shadcn components: a control has one of four heights, and every control that sits beside another shares the same default. Those sizes hold on every device. Where a screen or a part of it is meant for fingers, you switch it to touch sizing with one class, touch-controls, and its controls reach 44px.
Control sizes as shipped
| Size | Height | Button | Icon button | Also |
|---|---|---|---|---|
xs | 24px (h-6) | size="xs" | size="icon-xs" | Icons shrink to 12px. |
sm | 32px (h-8) | size="sm" | size="icon-sm" | SelectTrigger with size="sm". |
default | 36px (h-9) | size="default" | size="icon" | Input, select, tabs list, toggle row. |
lg | 40px (h-10) | size="lg" | size="icon-lg" |
Inputs, selects and the default button are all 36px, so a search field and its button align without extra classes. A badge is 20px (h-5). Checkboxes and radios are 16px.
Pair like with like: keep one size in a group of controls and one size per toolbar.
Keep one size in a group of buttons.
Don’t pair an extra small and a large button.
Touch controls
The shipped sizes meet the WCAG 2.2 AA target size (24px, or enough space around a smaller target) on every device, so nothing grows by itself. The brand asks for 44px where a finger is the pointer. Put touch-controls on a control, a region or a whole screen, and that element and everything inside it switch to touch sizing.
As shipped
With touch-controls
| Inside a touch-controls scope | What happens |
|---|---|
| Button, input, select, tab, menu item, pagination, sidebar item, link | Grows to 44px tall. Buttons, tabs and links are at least 44px wide too. |
| Icon button on its own | Grows to 44 by 44px. |
| A row with a checkbox, radio or switch | The row is 44px, so choices do not crowd each other. |
| Checkbox, radio, switch, slider thumb, toggle | Keeps its look. An invisible hit area around it is 44px. |
| Close icon of a dialog or sheet, a button inside an input group, carousel arrows, copy buttons | Keeps its look and place, with a 44px hit area. |
| Calendar | Day cells grow to 44px. A month is 332px wide. |
| Link in a sentence | Unchanged. Inline links are exempt, as in WCAG. |
Choose the condition
The class takes any Tailwind variant, so you decide when it applies.
| Class | Use it for |
|---|---|
pointer-coarse:touch-controls | A screen used with a mouse and on phones, such as sign-in or a form. Fingers get 44px, a mouse keeps the density. The usual choice. |
touch-controls | A region that only exists in the phone layout, such as a mobile menu sheet, or a surface that is only ever touched. |
max-md:touch-controls | A region that turns into its phone form below a breakpoint, such as the sidebar while it is a sheet. |
touch-controls-off | A part of a scope that stays compact: filter chips, a dense table, inline controls. |
The two buttons above carry no size class. Their wrapper has touch-controls, so both are 44px tall.
The chips sit in a touch-controls-off list inside the scope, so they keep their compact size while the action below is 44px.
- Menus, selects, popovers, dialogs and sheets open outside the page, so they do not inherit a scope. Put the class on their content as well:
SelectContent,DropdownMenu,Sheet,AlertDialog. - Do not add
h-11orsize-11to reach 44px. Usetouch-controls, which keeps the size in one token and keeps a mouse layout as shipped. - A class you put on a control still wins inside a scope:
min-h-8makes it 32px. - Change the size with
--touch-targetinapp/globals.cssor the theme editor:3remmatches Android's 48dp. Never set it below1.5rem, the WCAG minimum. - Text fields are 16px on a touch screen in every case, scope or not, so iOS does not zoom in when one takes focus.
Related
- Spacing for the gaps between controls.
- Breakpoints for changing layouts by width.