Product & design

Design system

The receipt concept, typed tokens, typography, components, Storybook, accessibility and voice.

La documentación técnica está en inglés.

The Splitmize Design System lives in src/design-system/. It is plain React with no Next.js dependency, documented in Storybook, and it is the only place the app gets colors, type, spacing and components from.

npm run storybook        # http://localhost:6006
npm run build-storybook  # static build in storybook-static/

This page is the overview: concept, architecture and rules. Storybook is the catalogue: every component with live controls, every variant, the props tables generated from TSDoc, the token pages and an accessibility (axe) panel in both themes.

The concept: a receipt, not a dashboard

Splitting a bill happens at a table, with a slip of thermal paper in front of you. Splitmize leans into that object instead of dressing a calculator up as a fintech dashboard:

  • The bill is a receipt — zig-zag torn edges, monospace figures, dotted leaders between item and price, a double rule above the total, a barcode at the bottom. It updates live next to the form.
  • Paid people get a rubber stamp, slightly rotated, with worn ink.
  • The logo is a heavy sans "S" cut by a diagonal slash. The type follows it (a relaxed grotesque, no serif), and the slash reappears as a graphic device behind the hero receipt and on step indicators.
  • The page is warm paper, not white; dark mode is a dark table with the receipt still made of paper.

Principles

  1. A receipt, not a dashboard. The bill is the hero object.
  2. Relaxed, not cute. Informal type and copy; no mascots, confetti or bouncy everything.
  3. Numbers are sacred. Always mono with tabular figures, always formatted by Intl, never decorated or animated.
  4. One loud color. Splitmize red marks the primary action and brand moments. Everything else is ink on paper.
  5. Real content, real structure. Illustrations are made of the product itself, computed by the real engine.

What we avoid

These are the tells of generic, auto-generated UI. Don't introduce them.

AvoidDo instead
Purple/blue gradients, glassmorphism, glowing blobsFlat paper surfaces, one brand red, ink black
Emoji as icons (💰 👥 🎉)The stroke icon set (Icon), or no icon
"Revolutionize", "seamless", "effortless", "optimize"Plain, specific sentences (see voice)
Three identical feature cards with iconsContent shaped like the domain: a menu board, a receipt, a comparison slip
Centered everything, rounded-2xl everywhereLeft-aligned editorial layout; small radii; hard offset shadows on primary forms
The default font every template ships withBricolage Grotesque + Chivo Mono, set with intent
Stock illustrationsReal UI fragments rendered from real data

Architecture

src/design-system/
  tokens/              Source of truth, as typed TypeScript data
    palette.ts         Tier 1: raw color scales (sand, red, green, amber, blue)
    semantic.ts        Tier 2: color roles (light + dark), people palette, contrast pairs
    typography.ts      Families, sizes, weights, leading, tracking, composite text styles
    layout.ts          Space scale, radii, control sizes, breakpoints, z-index, page layout
    effects.ts         Shadows, durations, easings, paper grain
    css.ts             tokensToCss(): turns all of the above into CSS custom properties
  styles/
    base.scss          Reset, element defaults, utilities (.visually-hidden, .no-print…)
    _mixins.scss       text-label, text-numeric, focus-ring, zigzag, truncate, button-reset…
    _breakpoints.scss  up($bp) / down($bp) media-query mixins
  utils/               cx() class joiner, WCAG contrast math
  components/<Name>/   <Name>.tsx · <Name>.module.scss · <Name>.stories.tsx
  docs/                Storybook MDX pages (foundations, guidelines) and their blocks
  index.ts             The public API — the only import path the app uses

How tokens reach the page

 tokens/*.ts ──► tokensToCss() ──► <style id="splitmize-tokens"> in app/[locale]/layout.tsx
      │                       └──► the same string in .storybook/preview.tsx
      ├──► Storybook Foundations pages (rendered from the same objects)
      └──► tokens.test.ts (contrast, naming, and every var() used in any .scss exists)

Tokens are data, not a stylesheet, so one definition feeds the app, Storybook, the documentation pages and the tests. Components consume them only as CSS custom properties: var(--color-accent), var(--space-4), var(--radius-md).

Rules

  • Import from @/design-system, never from a component file: import { Button, Field, Money } from '@/design-system'.
  • The design system never imports from next/*, the bill store or src/features/. Pure helpers from src/lib/ (money formatting) are fine. This keeps components runnable in Storybook on plain Vite, and keeps routing out of them: a link that looks like a button is <Link className={buttonClassName({ variant: 'primary' })}>.
  • Only semantic tokens in styles. No hex values, no ad-hoc pixel spacing. A test fails if a stylesheet references a token that doesn't exist.
  • Feature styles compose, they don't restyle. Feature .module.scss files lay components out (grids, gaps, order); they don't override a component's colors or type. If a feature needs a new look, it becomes a variant.

Tokens

Color

Colors are named by role, not by hue. Each role has a light and a dark value; the dark theme applies under prefers-color-scheme: dark and under [data-theme='dark'] (the theme toggle).

GroupRolesNotes
Surfacesbg, bg-raised, bg-sunken, bg-inverseWarm paper by day, a dark table at night.
Textfg, fg-muted, fg-subtle, fg-inverseEvery text role passes AA on bg and bg-raised.
Linesborder, border-strongborder-strong is also the hard offset shadow.
Brandaccent, accent-hover, accent-fg, accent-text, accent-on-inverse, accent-soft, accent-vivid, stampaccent carries white text (≥ 4.5:1); accent-text is brand red for text on paper, accent-on-inverse on bg-inverse; stamp is the rubber-stamp ink; accent-vivid is decoration only (the slash) and fails text contrast on purpose.
Statussuccess, success-soft, warning, warning-soft, focusStatus colors are for status only.
Receiptreceipt-bg, receipt-fg, receipt-muted, receipt-rule, receipt-accent, receipt-successStay paper-colored in dark mode. The paper-surface mixin swaps the text, accent, success and stamp roles for these inside Receipt and Card variant="paper", so children read as ink on paper.
MiscoverlayBackdrop behind dialogs.

As CSS: --color-<role> (e.g. --color-fg-muted).

Contrast is tested. contrastPairs in semantic.ts lists every foreground/background combination the UI uses, with its minimum ratio (7, 4.5 or 3). The test suite computes each pair in both themes; a color change that breaks AA fails the build.

People palette. --color-person-0 … --color-person-9 are riso-print inspired (blue, green, rust, violet, teal, magenta, mustard, slate, wine, olive). Each passes 4.5:1 with white initials. A person keeps the lowest unused color, so the first ten people at a table never share one. The palette deliberately excludes the brand red so a person is never confused with an error or a stamp.

Typography

RoleFaceWhy
Words (display, UI, body)Bricolage Grotesque (variable: weight, width, optical size)A grotesque with slightly irregular, ink-trapped shapes: relaxed without being cute, modern without looking like every template. The optical-size axis tightens it at headline sizes and opens it at text sizes, so one family does both jobs.
Numbers, receipt, labelsChivo Mono (variable weight)Money aligns in columns with tabular figures, and receipts are printed in mono. Also used for small uppercase labels.

The app self-hosts both with next/font (exposed as --font-bricolage and --font-chivo-mono); Storybook loads them from @fontsource-variable/*. --font-sans and --font-mono resolve to either.

Components never pick sizes ad hoc. They use the composite text styles, implemented by Text/Heading:

StyleSizeUse
display-lgfluid 44 → 100px, 800Landing hero only.
display-smfluid 36 → 56px, 800Page and section titles.
title-lg / title-md / title-sm34 / 26 / 18px, 700Step titles, card headings, list headings.
body-lg / body / body-sm18 / 16 / 14px, 400Leads, default text, hints.
label12px mono, 500, +0.12em, uppercaseField labels, kickers (Eyebrow).
numericmono, tabular figuresAmounts (Money).

Sizes are in rem so they follow the reader's browser setting. Inputs are at least 16px so iOS doesn't zoom on focus.

Space, radius, depth, motion

TokenValues
--space-*4px grid: 0, 0-5 (2px), 1 (4px), 1-5, 2, 2-5, 3, 4 (16px), 5, 6, 8, 10, 12, 16, 20, 24 (96px)
--radius-*xs 4 · sm 6 · md 10 · lg 16 · xl 24 · pill
--control-*sm 34px · md 44px (minimum touch target) · lg 54px
--shadow-*sm, paper (things made of paper), pop (dialogs, toasts), offset (hard 4px ink shadow on the primary form of a screen)
--duration-* / --ease-*fast 120 · base 200 · slow 320ms; out, in-out, spring
Layout--container 1240px, --gutter clamp(16px, 4vw, 40px), --header-height 60px
Breakpointssm 560 · md 820 · lg 1080 · xl 1280 (mobile-first; mirrored in _breakpoints.scss, kept in sync by a test)

Paper grain is an inline SVG turbulence texture (--texture-grain, light theme only).

Components

Every component has a header comment (what it is for, when not to use it, keyboard and screen-reader behavior), TSDoc on every prop, and stories for each variant and state.

GroupComponents
Typography & layoutText, Heading, Eyebrow, Money · Stack, Cluster, Container
ActionsButton (primary, secondary, outline, ghost, danger · sm/md/lg · icons · loading), IconButton, buttonClassName(), Chip
FormsField (label + hint + error wiring), Input, PercentInput, Select, MoneyInput, Switch, SegmentedControl (chips / cards), Stepper
DisplayAvatar, AvatarToggle, AvatarStack, Badge, Card (raised / sunken / outline / paper, emphasis), EmptyState, Icon, Logo, Notice, Skeleton, Stamp
ReceiptReceipt, ReceiptHeader, ReceiptRow, ReceiptRule, ReceiptTotal, ReceiptNote, Barcode
Navigation & overlaysStepNav, Dialog (native <dialog>, sheet variant), ToastProvider / useToast

Feature-level compositions live with their feature, not in the design system: BillReceipt (a whole bill as a receipt, in src/features/bill/) has its own stories under Patterns/.

Patterns worth knowing

  • Field takes a render function so any control gets correct labelling without Field knowing what it is:
    <Field label="Preço" hint="Total da linha" error={error}>
      {(control) => <MoneyInput {...control} value={price} onValueChange={setPrice} currency="BRL" locale="pt-BR" />}
    </Field>
  • MoneyInput keeps the typed text while focused, reports every parseable keystroke in minor units, normalizes on blur and accepts both decimal conventions.
  • SegmentedControl is a WAI-ARIA radio group: one tab stop, arrows move and select, Home/End jump to the ends, disabled options are skipped.
  • Card emphasis gets the hard ink offset shadow. One per screen: the primary form.
  • Stamp is decorative. Always pair it with real state (text or aria attributes).

Storybook

Configuration lives in .storybook/:

FileRole
main.tsReact + Vite builder, MDX with GFM tables, a11y and themes addons, react-docgen-typescript (props tables come from TSDoc).
preview.tsxInstalls the generated tokens and base.scss, the fonts, a light/dark switcher (sets <html data-theme>), a phone viewport plus one per breakpoint.
theme.ts, manager.ts, manager-head.htmlThe branded Storybook UI.

Sidebar structure: Introduction · Foundations (principles, colors, typography, spacing & layout, elevation & motion, iconography — rendered from the token objects) · Components (actions, forms, display, feedback, navigation, overlays, layout) · Patterns (feature compositions such as the bill receipt) · Guidelines (voice & tone, accessibility, contributing).

Adding a component

  1. Check whether a variant of an existing component covers it. A new component must be used in at least two places, or encode a rule that's easy to get wrong.
  2. Create components/<Name>/<Name>.tsx, <Name>.module.scss and <Name>.stories.tsx. Follow an existing component's header comment and TSDoc style; mark defaults with @default.
  3. Export it and its prop types from src/design-system/index.ts.
  4. Add interaction tests to components/__tests__/ if it handles keyboard input, ARIA state or value normalization.
  5. Check the axe panel in both themes, then npm run check.

Changing tokens

Edit the TypeScript files in tokens/. The CSS, the Foundations pages and the tests all follow. If you add a new foreground/background combination to the UI, add it to contrastPairs too.

Motion

Motion explains, it doesn't decorate:

  • the hero receipt "prints" row by row (≤ 1.5 s total), and the stamp thumps down at the end;
  • new rows and steps slide in 6px with --ease-out;
  • avatars spring slightly on toggle.

Everything respects prefers-reduced-motion globally (animations collapse to 1ms).

Accessibility

  • Text and controls meet WCAG AA contrast in both themes, enforced by tests.
  • Every interactive element is a real button, a, input or select. Toggles expose aria-pressed; on/off settings use role="switch"; single-choice groups use role="radiogroup" + aria-checked with roving focus.
  • Controls are at least 44px tall at the default size.
  • Avatars are aria-hidden; their buttons carry the person's name as text for screen readers.
  • Moving between steps moves focus to the step heading. A skip link jumps to #main.
  • Toasts are announced through a polite live region; field errors use role="alert" and aria-invalid.
  • Dialogs are native <dialog> elements: focus trap, Esc and inert background for free.
  • Keyboard: Enter submits every add form; Ctrl/⌘+Z / Ctrl/⌘+Shift+Z undo and redo outside text fields.

Voice

Splitmize talks like the friend who always ends up doing the math: relaxed, precise, a little funny, never cute.

  • Specific beats clever. "10% do garçom (só pra quem quiser pagar)" says more than "Taxas flexíveis".
  • Say what happens. Buttons are verbs with objects: "Adicionar item", "Copiar link", "Marcar como pago".
  • Jokes live in empty states and headlines, never in errors or money. "O primeiro chopp a gente nunca esquece." is fine; a joke next to an amount isn't.
  • Local, not translated. Brazilian Portuguese is the source: "racha a conta", "a galera", "conferência de mesa". Other languages get their own idioms, not literal translations.
  • No marketing filler: avoid "revolutionary", "seamless", "experience", "optimize", exclamation marks.
Editar esta página en GitHub