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

Chapter 02 Foundations

Layout

Components fit their container, not a list of devices. Most need no breakpoint at all: they wrap and shrink, and work down to 320 pixels wide, the width of a phone or of a page zoomed to 400%.

Breakpoints

Tailwind's five, in rem so they follow the reader's text size.

NameTokenrempxStarts
sm--ui-breakpoint-sm40rem640Large phones held sideways, small tablets.
md--ui-breakpoint-md48rem768Tablets.
lg--ui-breakpoint-lg64rem1024Laptops, tablets held sideways.
xl--ui-breakpoint-xl80rem1280Desktops.
2xl--ui-breakpoint-2xl96rem1536Wide desktops.

Tailwind's @container scale is smaller: @sm is 24rem, not 40rem.

Tailwind variantrempx
@3xs16rem256
@2xs18rem288
@xs20rem320
@sm24rem384
@md28rem448
@lg32rem512
@xl36rem576
@2xl42rem672
@3xl48rem768
@4xl56rem896
@5xl64rem1024
@6xl72rem1152
@7xl80rem1280

Page and grid

ui-page on the wrapper gives 12 columns, a capped width and padding that grows with the screen.

Class or tokenDoes
ui-pageThe page wrapper: centred, 12 columns, side padding and gap that grow with the screen.
ui-gridThe same 12 columns and gap with no padding, to split a column again.
ui-col-1 … ui-col-12Spans that many of the 12 columns.
ui-col-sm-6, ui-col-md-4 …Spans that many from that breakpoint up: sm, md, lg, xl, 2xl. Below it, the child fills the row.
--ui-page-maxWidest the columns get, 96rem (2xl). Set 64rem for a narrower site.
--ui-page-gutterSide padding, 1rem to 3rem.
--ui-grid-gapGap between columns and rows, 1rem to 2rem.

Try the page

Set the screen width: the side bar moves up at md, the cards add columns at sm and lg.

Screen 48rem (768px) · columns 0rem · below sm

A page from four classes

ui-page, ui-col-md-4 and ui-col-lg-3 for the side bar, and a nested ui-grid for the cards. No CSS of your own.

Angular
<div class="ui-page">
  <header>Header</header>
  <nav class="ui-col-md-4 ui-col-lg-3">Side bar</nav>
  <main class="ui-grid ui-col-md-8 ui-col-lg-9">
    <article class="ui-col-sm-6 ui-col-lg-4">Card 1</article>
    <article class="ui-col-sm-6 ui-col-lg-4">Card 2</article>
    <article class="ui-col-sm-6 ui-col-lg-4">Card 3</article>
  </main>
  <footer>Footer</footer>
</div>

Your own components

@container on the box, then a @min-[40rem]: variant: the card reads its box, so it fits a side bar and a full page.

Angular
<div class="@container">
  <article class="grid gap-4 @min-[40rem]:grid-cols-[12rem_1fr]">
    <img src="/kettle.jpg" alt="Steel kettle" />
    <p class="body-md">Steel kettle, 1.7 litres.</p>
  </article>
</div>

Widths

The fixed widths in the kit; nothing is wider than 320px less 2rem.

TokenValueFor
--ui-dialog-size24rem · 32rem · 48remSmall, default and large dialog.
--ui-page-max96remWidest the page columns get. Set 64rem for a narrow site.
--ui-page-gutter1rem → 3remSide padding of ui-page, grows with the screen.
--ui-grid-gap1rem → 2remGap between columns and rows.
.ui-toast24remToast.
.ui-popover22rem at mostPopover.
.ui-tooltip18rem at mostTooltip.

Rules

  • Nothing scrolls sideways at 320px except a table in its frame.
  • Below sm, a side bar's links go in a drawer.
  • Logical sides only, so the layout works right to left.