Chapter 02 Foundations
Space
One spacing scale for padding, margin and gap, one radius, two shared sizes.
Spacing
Quarters of a rem, the same step as Tailwind: p-4 is --ui-space-4, 1rem.
| Token | Value | Tailwind | For | Sample |
|---|---|---|---|---|
--ui-space-0 | 0 · 0px | p-0 · gap-0 | Reset a default margin or padding. | |
--ui-space-0-5 | 0.125rem · 2px | p-0.5 · gap-0.5 | Badge padding, an icon nudged into line with text. | |
--ui-space-1 | 0.25rem · 4px | p-1 · gap-1 | Inside lists and menus, between an icon and its label. | |
--ui-space-1-5 | 0.375rem · 6px | p-1.5 · gap-1.5 | Between a label, its control and its hint. | |
--ui-space-2 | 0.5rem · 8px | p-2 · gap-2 | Between buttons in a row (--ui-gap). | |
--ui-space-2-5 | 0.625rem · 10px | p-2.5 · gap-2.5 | Textarea and badge padding. | |
--ui-space-3 | 0.75rem · 12px | p-3 · gap-3 | Inside a control, between the items of a list. | |
--ui-space-4 | 1rem · 16px | p-4 · gap-4 | Between fields in a form, around a dialog on small screens. | |
--ui-space-5 | 1.25rem · 20px | p-5 · gap-5 | Between groups of fields. | |
--ui-space-6 | 1.5rem · 24px | p-6 · gap-6 | Card and dialog padding. | |
--ui-space-7 | 1.75rem · 28px | p-7 · gap-7 | Large card padding. | |
--ui-space-8 | 2rem · 32px | p-8 · gap-8 | Empty states, between blocks inside a section. | |
--ui-space-10 | 2.5rem · 40px | p-10 · gap-10 | Between sections on small screens. | |
--ui-space-12 | 3rem · 48px | p-12 · gap-12 | Between sections. | |
--ui-space-16 | 4rem · 64px | p-16 · gap-16 | Above and below a page header. | |
--ui-space-20 | 5rem · 80px | p-20 · gap-20 | Between bands of a landing page. | |
--ui-space-24 | 6rem · 96px | p-24 · gap-24 | Hero padding. | |
--ui-space-32 | 8rem · 128px | p-32 · gap-32 | Hero padding on wide screens. |
<section class="ui-card mb-12 grid gap-4 p-6">
<h2 class="head-sm">Order summary</h2>
<div class="flex py-2">
<span>Delivery</span>
<span class="ms-auto">EGP 45</span>
</div>
</section>Padding, margin and gap classes
Tailwind's classes read the kit's scale. Without Tailwind, the kit's own ui- classes do the same.
| Tailwind | Without Tailwind | Sets |
|---|---|---|
p-4 · m-4 | ui-p-4 · ui-m-4 | Padding or margin on all four sides. |
px-4 · mx-4 | ui-px-4 · ui-mx-4 | Start and end. |
py-4 · my-4 | ui-py-4 · ui-my-4 | Top and bottom. |
pt-4 · mt-4 | ui-pt-4 · ui-mt-4 | Top. |
pb-4 · mb-4 | ui-pb-4 · ui-mb-4 | Bottom. |
ps-4 · ms-4 | ui-ps-4 · ui-ms-4 | Start: left in English, right in Arabic. |
pe-4 · me-4 | ui-pe-4 · ui-me-4 | End: right in English, left in Arabic. |
gap-4 | ui-gap-4 | Between children of a flex or grid, both ways. |
gap-x-4 | ui-gap-x-4 | Between columns. |
gap-y-4 | ui-gap-y-4 | Between rows. |
Try the classes
Every demo below and its code follow the slider.
Padding
p-4: space inside the box, on all four sides.
<div class="p-4">Content</div>Margin
mb-4 on the first box: space outside it, before the next one.
<div class="mb-4">First</div>
<div>Second</div>Gap
gap-4 on a flex or grid parent: the same space between every child, none at the edges.
<div class="flex flex-wrap gap-4">
<div>One</div>
<div>Two</div>
<div>Three</div>
</div>Start flips in Arabic
ps-4 is padding on the start side: the left in English, the right in Arabic.
<div dir="rtl" lang="ar">
<div class="ps-4">المحتوى</div>
</div>Radius
Every radius is worked out from --ui-radius. Set it on :root and the whole scale follows; on a smaller part of the page, set every radius there, as the demo below does.
| Token | Value | Tailwind | For | Sample |
|---|---|---|---|---|
--ui-radius-none | 0 | rounded-none | Square: a drawer against the screen edge, the foot of a bottom sheet. | |
--ui-radius-xs | 0.125rem | rounded-xs | Hairline details. No component uses it yet. | |
--ui-radius-sm | 0.25rem | rounded-sm | Skeleton text lines. | |
--ui-radius-md | 0.375rem | rounded-md | Items inside a list or menu (smaller than the list around them), tooltips. | |
--ui-radius | 0.5rem | rounded-ui | The base: buttons, fields, lists, menus, popovers, alerts. | |
--ui-radius-lg | 0.75rem | rounded-lg | Medium panels of your own. No component uses it yet. | |
--ui-radius-xl | 1rem | rounded-xl | Cards, dialogs and the top of a bottom sheet. | |
--ui-radius-2xl | 1.5rem | rounded-2xl | Large panels of your own. No component uses it yet. | |
--ui-radius-full | 9999px | rounded-full | Pills and circles: badges, switches, spinners, progress bars, round icons. |
Try the radius
Set --ui-radius; real components follow.
One token re-shapes the kit
Button, field and badge take the base; the card takes double.
Order
:root {
--ui-radius: 0.5rem;
}Sizes
Two sizes every control and row of buttons shares.
| Token | Value | Tailwind | For | Sample |
|---|---|---|---|---|
--ui-control-height | 2.75rem · 44px | min-h-11 | Smallest touch target: buttons, fields, list items, tabs. Large buttons take 3.25rem. | |
--ui-gap | var(--ui-space-2) | gap-2 | Between buttons in a row and items in a group. |