Skip to content

Using the Opleet design system

Owner: @zuki · Written by the Frontend Engineer · Last reviewed: 2026-11-04 · Conforms to the decisions through D88

How apps/web applies the Opleet design system: where the tokens and components live, how to add a screen, and the content rules to follow. The Frontend Engineer keeps this guide; the decisions and the rules outrank it (how we work).

It moved here on 2026-10-12 from the Google doc [Guide] Using the Opleet design system in v2 (#58, D28). On 2026-11-04 it was rewritten for the design system's version 2, which publishes shadcn/ui components (FE-M0-27 and FE-M0-28, D88): the op-* stylesheet, the twelve ported components and the token generator are gone.

  • The decisions outrank this guide and the design system's README. Where the README's sample copy differs, this guide wins: Indonesian is the default language (D7) and money is written Rp 4.250.000.
  • The design reference is the Opleet Design System made in Claude Design, version 2: liquid glass on a soft green canvas, Inter Tight, brand green #1E6F5E, as shadcn/ui components for Next.js, React 19 and Tailwind CSS v4. The old repository's design is outdated; only its flows and business logic still apply.
  • v2 uses the design system's own files, not a re-drawing of them: design/opleet/globals.css, tokens.json and README.md, components/ui/*, lib/utils.ts and components.json. design/opleet/SOURCE.md lists where each file came from and its SHA-256; shasum -a 256 -c design/opleet/SHA256SUMS, run in apps/web, checks the copies. Never edit one: change the design system first, then copy the new version in a step of its own.
  • Read the design system's README first (design/opleet/README.md): voice, casing, numbers, colour, glass levels, type scale, and which utility reads which token.
Path What
design/opleet/globals.css Tailwind v4, CSS only: the tokens as CSS variables, light and dark (data-theme), shadcn's variables mapped onto them, @theme inline for the utilities, the canvas and glass helpers. Imported once, in app/layout.tsx. Postcss only runs @tailwindcss/postcss (postcss.config.mjs).
design/opleet/tokens.json The tokens, source of truth for the design system. Nothing here generates from it any more.
design/opleet/README.md The design system's own guide.
design/opleet/assets/ The supplied logos and app icons, unchanged. app/icon.png and app/apple-icon.png are copies of two of the app icons.
components/ui/ The 26 components, imported through @ui/<name> in lower case with a dash: @ui/button, @ui/card, @ui/form-field, @ui/segmented-control. Radix, class-variance-authority and cn().
lib/utils.ts cn(): clsx and tailwind-merge, taught the design system's scales.
components.json shadcn's config for this layout. The shadcn CLI is not used here: a component is copied from the design system, never generated.
components/brand/Logo.tsx The supplied artwork through next/image; not a design system component.
components/shell/ Shell (the sidebar, the top bar and, below lg, MobileMenu), SidebarNav, nav-icons.ts, PoolSwitcher, LanguageSwitcher, ActionForm, PageHeader, Forbidden, NotFoundContent, Notice and ShellFrame.
components/errors/PlainError.tsx The plain page of R-APP-09, built from Card and Button.
lib/format.ts Rupiah (idr, idrShort), numbers (num) and plates (plate: B1234TOP becomes B 1234 TOP). Money is written Rp 4.250.000. Numbers keep Indonesian formatting in both languages; dates follow the user's language (D7). Tested by lib/format.test.ts.
lib/access/, lib/nav.ts my_permissions() read once per request, can(), and every page with its href, label, icon, permission, module and the v1 menus it replaces.
lib/i18n/, i18n/ getT() and useT(), the catalog behind @i18n/ (D29).
lib/errors/ The error-key mapper (D10, D29): a refusal's text from its key, filled from the JSON detail; else from its SQLSTATE class; else error.unknown, reported without the message or details.
lib/labels.ts label() and tone() for a database code, and BadgeTone, the tones a Badge takes.
app/design-preview/ Every component with sample data, light and dark, and the ones that open over the page behind buttons. It answers 404 unless NEXT_PUBLIC_DESIGN_PREVIEW=1, so it stays off on staging and production; a Playwright spec proves it (Testing the web app).

The aliases are in apps/web/tsconfig.json: @ui/<name> is components/ui, @ui/design/<file> is design/opleet, @i18n/ is i18n and @/ is the root of apps/web. Biome skips design/opleet, components/ui, lib/utils.ts and components.json (apps/web/biome.json), so the copies stay byte for byte what the design system published.

Icons are imported from lucide-react where they are used, as the design system's components do. The menu is the one place that names an icon with a string, because lib/nav.ts crosses from server to client code: its names are in components/shell/nav-icons.ts, and a misspelt name fails typecheck.

  1. Write the rules and the journey first (D27): the page's rules are in apps/docs, and the Playwright journey that proves them is written before the page (Testing the web app).
  2. Add the page to lib/nav.ts: its label as t() with the Indonesian default, icon, permission, module and the v1 menus it replaces. Then add its route under app/(shell)/. Until the route exists the shell shows a placeholder, and a role without the permission gets the refusal page.
  3. Start the page with PageHeader: title, subtitle, one primary action.
  4. Use the components: Card for panels (and its brand variant for the one KPI tile), Table for lists. Details open in a Sheet from the row, not in the list. A labelled field is FormField with FormLabel, FormControl, FormHint and FormError. A message that stays on the page is Notice; an event is a toast (toast() from @ui/sonner, the Toaster is mounted once in the root layout).
  5. Lay the page out with Tailwind utilities around the components, named from the tokens, as Layout with Tailwind says. A static padding, gap or width is a class, never an inline style.
  6. Show statuses with Badge using label() and tone() from lib/labels.ts, so the word always travels with the colour, in the user's language.
  7. Write every string the user sees as t('key', 'Indonesian default'), as the content rules below say.
  8. Format every number with lib/format.ts; figures use tabular numerals (op-num).
  9. Read and write through the database the way D3 says: reads through PostgREST under the user's session, writes that change status, money or numbers through RPC. A function, view, column or error key that is missing is a request under Interface in the backend runbook, never a workaround. Types come only from @opleet/db-types.
  10. Check the page in light and dark, and in Indonesian and English. The theme toggle sets the opleet-theme cookie and the root layout sets data-theme; the ID | EN toggle saves the language on the profile and in the opleet-locale cookie.

D7 makes Indonesian the default language, with English an optional toggle each user sets, stored in profiles.locale. D29 says how it is built.

  • Every string the user sees is t('module.screen.element', 'Indonesian default'), for example t('drivers.list.empty_title', 'Belum ada driver'). The key is a dotted path that names where the text appears, so a string on screen leads to the component that prints it. The Indonesian default sits at the call site while a screen is built.
  • Server code gets t from getT() and client components from useT(). A server component hands client components one language only.
  • The catalog is plain TypeScript in apps/web/i18n, with no library. pnpm --filter web i18n collects every call into i18n/messages.id.ts; English goes in i18n/messages.en.ts under the same key. typecheck fails when the catalog is out of date or one key has two defaults. Until a key has English, t() shows the Indonesian default.
  • English becomes required module by module. i18n/strict.json lists the key prefixes that must have English; a module's prefix is added when its pages are done, and from then on a missing English text fails typecheck.
  • Enum labels are an exhaustive record per language over the generated enum types, in i18n/enums.ts, so a value a migration adds fails typecheck until both labels exist. Badge tones are a separate map with no language.
  • Master data with two names is charge_types, lead_sources, inspection_item_types and body_panels, stored as name (Indonesian, required) and name_en (optional). pickName() reads name_en in English and falls back to name. Proper nouns and legal text keep one name.
  • Some text is Indonesian only, with no language parameter: contracts (PKS), BASTK, surat hutang, the public queue page and queue TV, and anything sent to drivers.
  • Real-world names stay as they are in both languages: BASTK, STNK, SIM A, Cuti, ETLE, Surat hutang.
  • A refusal from the database is shown through the error-key mapper, never from the exception text (D10). The mapper works from structured fields only: a known key (the list is the generated public.error_key enum, D30, so a key without Indonesian and English text fails typecheck), else a known SQLSTATE class, else error.unknown with a Sentry event that never carries the details. The key internal.unknown_error_key, which the database raises when a function names a key the enum lacks, is not in the enum: the mapper shows a general text and reports it.
  • The language comes from profiles.locale, with the opleet-locale cookie as the per-request fast path.
  • Margin and company amounts (margin and company_amount, on charges and payouts) are shown only when my_permissions() includes payment:margin (D31). The Backend Engineer's views leave them empty for a reader without it; the page shows them only with the permission.
  • NIK and phone are shown in full to every role that can read a driver, because checking them against the KTP photo is part of that role's work. Only the audit log masks them (D31).

The design system is a Tailwind v4 system (D88): a component looks the way its variants make it look, and the page lays it out.

  • Utilities are for layout and spacing around components: flex, grid, gap-*, p-*, widths, alignment, responsive breakpoints. Use them on your own wrappers and on the page.

  • Don't restyle a component with utilities. cn() lets a class win over a component's own, which is why it must not be used to change its colour, border, radius, shadow or font. To change a component, change its props or variant; if the design system has no such variant, ask for one in an issue, as with any design change. A utility that sets those on a design system component is a review comment.

  • Values come from the tokens. globals.css maps them: no raw hex colours, no pixel values in class names (w-[137px]), and no Tailwind default palette, radii, shadows or fonts, because it clears them.

  • A class is the utility's prefix plus the token's name:

    For Class Reads
    Colour bg-green-500, text-text-strong, border-border-subtle, bg-glass-fill-strong; shadcn's bg-primary, text-muted-foreground --green-500, --text-strong, --border-subtle, --glass-fill-strong
    Space p-5, gap-2, mt-3 --spacing is --space-1, the 4px base, so a number is that many steps
    Named sizes h-control-md, size-check, w-sheet, max-w-dialog, min-h-touch, min-h-topbar, w-sidebar --control-h-md, --sheet-w, --sidebar-w and the other sizes
    Radius rounded-sm, rounded-lg, rounded-xl, rounded-pill --radius-*
    Shadow shadow-glass, shadow-glass-raised, shadow-brand, shadow-1 --shadow-*
    Type text-fs-h1, text-fs-body, text-fs-control, font-mono text-fs-mono --fs-*, with line height, weight and tracking together
    Glass backdrop-glass, backdrop-glass-thin, backdrop-scrim --blur-*
    Helpers op-canvas, op-glass, op-eyebrow, op-num utilities of globals.css
  • Breakpoints are the design system's: sm: 480px, md: 768px (where the desktop layout becomes the phone layout; components use max-md:), lg: 1024px and xl: 1280px. The shell shows its sidebar from lg:.

  • Dark mode comes from the tokens, through data-theme on <html>. The dark: variant follows it, never the operating system's setting; it is for the design system's components, and a page uses tokens that already flip.

  • Tailwind's preflight is on. Plain global CSS goes in @layer base, because an unlayered rule beats every layered one, including the canvas and the font.

  • For a glass panel use Card or op-glass. backdrop-glass is for a new component of your own that needs the backdrop.

  • Write a class whole, never glued to a ${ }. Tailwind finds classes by reading the source as text, so `flex-1 justify-center${on ? " x" : ""}` is read as one word and justify-center is never generated. Use cn() with whole class names. Biome and typecheck don't catch it; look at the page, or at the built CSS.

  • Inline style={{ ... }} is for values that are only known at runtime, such as a width worked out from data.

  • Long class lists: keep them in the JSX, in reading order (layout, spacing, then the rest). Reviewers ask for a component when the same list appears three times.

  • Sentence case for titles, buttons and labels. Spaced upper case only for eyebrows ("FLEET STATUS").
  • A middle dot joins metadata: "Toyota Calya G AT · 2024".
  • Numbers the Indonesian way: Rp 4.250.000, not IDR 4.250.000; a decimal comma; jt for juta and M for miliar; plates as B 1234 TOP.
  • One primary action per view, in brand green. Status is never colour alone.
  • Never dense: the essentials at a glance, detail one click away.
  • No emoji.

The database stores English codes. i18n/enums.ts gives each one an Indonesian and an English label, and label() in lib/labels.ts reads them in the user's language (D7, D29). Examples:

Code Indonesian English
driver_stage.on_leave Cuti Cuti
queue_status.converted Masuk Lead Registered
queue_status.skipped Terlewat Skipped
charge_status.open Belum bayar Open
charge_status.partially_paid Cicil Partly paid
charge_status.paid Lunas Paid

When a page first shows an enum, add it to LabeledEnum in i18n/enums.ts with both labels. From then on, a value a migration adds fails typecheck until both labels exist.

Problem Fix
Fonts look wrong in screenshots Inter Tight and JetBrains Mono come from next/font in app/layout.tsx; next dev offline can't fetch them and falls back to system fonts.
A logo stretches in a flex column Give it self-start.
Dark mode doesn't apply on a page The root layout reads the opleet-theme cookie and sets data-theme on the html element. Check that the cookie is set. A portal (a dialog, a menu) follows the html element's theme, not a region's.
A utility has no effect on a design system component cn() merges the classes but the component's own variant may set the property under a state. Ask for a variant instead of forcing it.
A token class produces nothing The theme doesn't name it. Look it up in globals.css (@theme inline) or the README's table; never type the value.
The page has no background or the wrong font A plain global rule is beating the layered ones. Put it in @layer base, or remove it.
design/opleet, components/ui or lib/utils.ts changed and shasum -c fails Never edit them here. Restore the copy, or change the design system first, then copy the new version in a runbook step of its own and update design/opleet/SOURCE.md. Biome skips them; pnpm format must not change them.
A text stays Indonesian in English Its key has no English yet: add it to i18n/messages.en.ts. pnpm --filter web i18n counts the keys without English.
typecheck says the catalog is out of date Run pnpm --filter web i18n and commit i18n/messages.id.ts.
A spec looks for a button and the component renders a radio or a menu item The design system's SegmentedControl is a radio group and DropdownMenu items are menu items. The ID | EN switcher and the pool switcher keep buttons (R-APP-10's spec presses them by name), built from Button and Popover.

Per D8, design/opleet and components/ui stay inside apps/web, imported through the @ui/ path alias. They become a package only when a second app needs them, such as a partner portal or apps/docs; the driver app can't use them. The catalog stays in apps/web/i18n behind @i18n/ for the same reason, until backend code renders staff-facing text in the user's language (D29).