Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

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.

TokenValueTailwindForSample
--ui-space-00 · 0pxp-0 · gap-0Reset a default margin or padding.
--ui-space-0-50.125rem · 2pxp-0.5 · gap-0.5Badge padding, an icon nudged into line with text.
--ui-space-10.25rem · 4pxp-1 · gap-1Inside lists and menus, between an icon and its label.
--ui-space-1-50.375rem · 6pxp-1.5 · gap-1.5Between a label, its control and its hint.
--ui-space-20.5rem · 8pxp-2 · gap-2Between buttons in a row (--ui-gap).
--ui-space-2-50.625rem · 10pxp-2.5 · gap-2.5Textarea and badge padding.
--ui-space-30.75rem · 12pxp-3 · gap-3Inside a control, between the items of a list.
--ui-space-41rem · 16pxp-4 · gap-4Between fields in a form, around a dialog on small screens.
--ui-space-51.25rem · 20pxp-5 · gap-5Between groups of fields.
--ui-space-61.5rem · 24pxp-6 · gap-6Card and dialog padding.
--ui-space-71.75rem · 28pxp-7 · gap-7Large card padding.
--ui-space-82rem · 32pxp-8 · gap-8Empty states, between blocks inside a section.
--ui-space-102.5rem · 40pxp-10 · gap-10Between sections on small screens.
--ui-space-123rem · 48pxp-12 · gap-12Between sections.
--ui-space-164rem · 64pxp-16 · gap-16Above and below a page header.
--ui-space-205rem · 80pxp-20 · gap-20Between bands of a landing page.
--ui-space-246rem · 96pxp-24 · gap-24Hero padding.
--ui-space-328rem · 128pxp-32 · gap-32Hero padding on wide screens.
Angular
<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.

TailwindWithout TailwindSets
p-4 · m-4ui-p-4 · ui-m-4Padding or margin on all four sides.
px-4 · mx-4ui-px-4 · ui-mx-4Start and end.
py-4 · my-4ui-py-4 · ui-my-4Top and bottom.
pt-4 · mt-4ui-pt-4 · ui-mt-4Top.
pb-4 · mb-4ui-pb-4 · ui-mb-4Bottom.
ps-4 · ms-4ui-ps-4 · ui-ms-4Start: left in English, right in Arabic.
pe-4 · me-4ui-pe-4 · ui-me-4End: right in English, left in Arabic.
gap-4ui-gap-4Between children of a flex or grid, both ways.
gap-x-4ui-gap-x-4Between columns.
gap-y-4ui-gap-y-4Between rows.

Try the classes

Every demo below and its code follow the slider.

4 · 1rem · 16px

Padding

p-4: space inside the box, on all four sides.

Content
Angular
<div class="p-4">Content</div>

Margin

mb-4 on the first box: space outside it, before the next one.

First
Second
Angular
<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.

One
Two
Three
Four
Five
Angular
<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.

المحتوى
Angular
<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.

TokenValueTailwindForSample
--ui-radius-none0rounded-noneSquare: a drawer against the screen edge, the foot of a bottom sheet.
--ui-radius-xs0.125remrounded-xsHairline details. No component uses it yet.
--ui-radius-sm0.25remrounded-smSkeleton text lines.
--ui-radius-md0.375remrounded-mdItems inside a list or menu (smaller than the list around them), tooltips.
--ui-radius0.5remrounded-uiThe base: buttons, fields, lists, menus, popovers, alerts.
--ui-radius-lg0.75remrounded-lgMedium panels of your own. No component uses it yet.
--ui-radius-xl1remrounded-xlCards, dialogs and the top of a bottom sheet.
--ui-radius-2xl1.5remrounded-2xlLarge panels of your own. No component uses it yet.
--ui-radius-full9999pxrounded-fullPills and circles: badges, switches, spinners, progress bars, round icons.

Try the radius

Set --ui-radius; real components follow.

0.5rem · 8px

One token re-shapes the kit

Button, field and badge take the base; the card takes double.

Order

Saved
Angular
:root {
  --ui-radius: 0.5rem;
}

Sizes

Two sizes every control and row of buttons shares.

TokenValueTailwindForSample
--ui-control-height2.75rem · 44pxmin-h-11Smallest touch target: buttons, fields, list items, tabs. Large buttons take 3.25rem.
--ui-gapvar(--ui-space-2)gap-2Between buttons in a row and items in a group.