---
title: "Design system"
description: "Brand tokens, fonts, type scale, spacing and the components built on them."
url: https://pr-179-docs.preview-lehoetel.findmalek.engineer/docs/design-system
markdown: https://pr-179-docs.preview-lehoetel.findmalek.engineer/docs/design-system.md
---

# Design system

Mobile first: most guests scan a QR code on a cheap Android phone, hotel staff use the dashboard on a phone or a desktop. Both must be fast and comfortable.

## Tokens

The brand tokens live in `packages/ui/src/styles/theme.css` (`:root` and `.dark`) and are the le-hoetel brand as given in the kickoff prompt. Never edit them per component and never hard code a color. Hotels override `--primary` and one accent at runtime through their branding config, so every color in the UI must come from a token (`bg-primary`, `text-muted-foreground`, `border-border`).

### Hotel branding at runtime

A hotel's `primary_color` and `accent_color` become css variables through `brandStyle` (`@le-hoetel/common/color`): `--primary` with `--primary-foreground`, and `--brand-accent` with `--brand-accent-foreground` (`bg-brand-accent`, `text-brand-accent-foreground`). The foreground is black or white, whichever has more contrast, so text on a brand color always passes AA (4.5:1). The dashboard layout sets them on the app shell, the public capture page does the same. A color that is under 3:1 against the light or dark page background (WCAG 1.4.11, `brandContrastIssues`) is not blocked: the admin create form and the hotel settings page show a warning under the field.

- `globals.css` maps the tokens to Tailwind (`@theme inline`), holds the type scale, the `coarse` variant and a few utilities
- `--radius` is `0.625rem`. Controls and cards use `rounded-lg`, small items (menu rows, kbd, tooltip) `rounded-md`, badges `rounded-full`
- dark mode is the `.dark` class set by `next-themes`; test both themes for every new screen

## Fonts

| Role | Font | Why |
| --- | --- | --- |
| Latin (en, fr) | Inter, variable | one file for every weight (about 48 KB for the `latin` subset, covers French accents), very readable at small sizes on low density screens, tabular and lining numbers |
| Arabic (ar) | Cairo, variable | one file for every weight (about 31 KB, `arabic` subset), clean modern naskh/kufi hybrid, renders well at 14 to 16 px on low end Android, ships with Latin digits that match Inter |
| Mono | JetBrains Mono | codes and ids only, never preloaded |

Decisions:

- both are loaded with `next/font/google`, `display: "swap"` and only the subsets we need. Each file is self hosted, so there is no request to Google at runtime
- variable fonts beat several static weights: one request instead of three or four, and the file sizes above are the whole cost
- the browser downloads a font file only when a character from its `unicode-range` is on screen. So French and English pages never download Cairo, and the Arabic font is not preloaded (`preload: false`). Arabic pages pay one small swap
- `--font-sans` is `var(--font-latin), var(--font-arabic), system-ui`. Mixed text (an Arabic sentence with a Latin hotel name) picks the right font per character with no extra code
- we chose Cairo over IBM Plex Sans Arabic and Noto Kufi Arabic because those ship as separate static weights (more requests) or as larger files, and Cairo stays legible at body size on 720p phones
- numbers stay Western digits (`0-9`), the habit in Tunisia and what Inter and Cairo both draw
- Arabic text gets a taller line height (`:lang(ar)` in `globals.css`), because Arabic marks need the room

Each app declares the fonts in `app/fonts.ts` (`next/font` must run inside the app) and sets `fontVariables` on `<html>`. The `lang` and `dir` attributes on `<html>` are owned by the i18n routing.

## Type scale

Defined in `globals.css`, usable as Tailwind classes:

| Class | Size | Use |
| --- | --- | --- |
| `text-display` | 36 to 56 px fluid | landing hero only |
| `text-h1` | 28 to 40 px fluid | page title |
| `text-h2` | 22 to 30 px fluid | section title |
| `text-h3` | 20 px | card or dialog title |
| `text-body` | 16 px | default, forms |
| `text-small` | 14 px | secondary text, dense tables |
| `text-caption` | 12 px | badges, hints, legal |

Form inputs are 16 px on mobile (below that iOS zooms the page on focus) and 14 px from `md`.

## Spacing and touch targets

- spacing is Tailwind's 4 px scale. Page padding is `px-4` on mobile, `md:px-6` after; stack with `gap-*`, avoid margin between siblings
- every control a thumb can hit is at least 44 px (`h-11`, token `--spacing-touch`). Button, input, select, tabs, switch and menu rows already follow it
- compact variants (`size="sm"`, `xs`, icon buttons) are small with a mouse and grow to 44 px on touch screens through the `coarse:` variant (`@media (pointer: coarse)`). Do not rebuild that per screen
- checkboxes and radios are 20 px with a 44 px hit area, put them inside a `Field` with a label so the label is tappable
- keep 8 px between two tap targets
- use `pb-safe` and `pt-safe` for bars pinned to a screen edge (iPhone notch and home indicator)

## Components

All in `@le-hoetel/ui/components/*`, built on shadcn with Base UI, with the RTL migration applied (`"rtl": true` in `components.json`). Add more with `pnpm ui:add <component>`, then check it against the rules in [component patterns](https://pr-179-docs.preview-lehoetel.findmalek.engineer/docs/component-patterns.md).

| Need | Component |
| --- | --- |
| actions | `button` (variants, sizes, `loading`) |
| text input | `input`, `textarea`, `input-group` |
| choice | `checkbox`, `radio-group`, `switch`, `select` |
| form layout and errors | `field` (`Field`, `FieldLabel`, `FieldDescription`, `FieldError`), `label` |
| phone number | `phone-input` (dial code and number, shell only, validate in the api) |
| overlays | `dialog`, `alert-dialog`, `sheet` (`start`, `end`, `top`, `bottom`), `dropdown-menu`, `tooltip` |
| navigation | `tabs`, `breadcrumb`, `sidebar` |
| data | `table`, `card`, `badge`, `avatar`, `item` |
| feedback | `sonner` toasts, `alert`, `spinner` |
| states | `empty-state`, `loading-state` (`ListSkeleton`, `CardSkeleton`), `skeleton` |

## Empty and loading states

- loading: show a skeleton with the shape of the final content (`ListSkeleton`, `CardSkeleton`, `Skeleton`), never a blank page and never a lone spinner for a whole page. A spinner is for a pending button (`<Button loading>`) or a short inline wait
- skeletons carry `role="status"` and a screen reader label, passed in by the caller so it is translated
- empty: use `EmptyState` with an icon, a one line title, a sentence that says what to do next, and one primary action. An empty list is an onboarding moment, not an error
- error: `Alert` with `variant="destructive"` for a block, a toast for a transient failure. Say what happened and what to try, never expose raw errors

## Dark mode

Tokens switch under `.dark`. Rules: no `bg-white` or `text-black`, use `bg-background` and `text-foreground`; images and logos must work on both backgrounds; borders come from `border-border`, which turns into a translucent white in dark mode.
