Surface
Two surfaces: night, a deep pine-teal, and paper, lit by the glow. Every piece works on both because it only reads surface tokens.
<html data-surface="night"> · <html data-surface="paper">
Night and paper
Without data-surface, the system's light or dark preference decides. Any element can set its own surface, as these two do.
NightCheckoutPayments and orders.
WellFailingNew
PaperCheckoutPayments and orders.
WellFailingNew
Code
import { Badge, Button, Card, Status } from '@sypnia/ui/react';
// The same pieces on both surfaces. A page sets one on <html data-surface="night|paper">; without it, the system's
// light or dark preference decides. Any element can set its own, as these two do.
export default function Both() {
return (
<div className="sy-cols" style={{ '--cols': 2, '--gap': 0 } as React.CSSProperties}>
{(['night', 'paper'] as const).map((s) => (
<div key={s} data-surface={s} className="sy-stack" style={{ '--gap': 'var(--s-4)', padding: 'var(--s-5)', background: 'var(--bg)', color: 'var(--fg)' } as React.CSSProperties}>
<strong style={{ fontFamily: 'var(--font-voice)', fontSize: 'var(--text-xl)', fontWeight: 400 }}>{s === 'night' ? 'Night' : 'Paper'}</strong>
<div className="sy-row"><Button variant="primary">Create project</Button><Button>Import</Button></div>
<div className="sy-row"><Status tone="ok">Well</Status><Status tone="fail">Failing</Status><Badge tone="light">New</Badge></div>
<Card title="Checkout" meta="3 problems">Payments and orders.</Card>
</div>
))}
</div>
);
} The surface tokens
Components use these names, never a colour. The whole list is on the Tokens page.
--bgThe page--bg-raisedPanels, cards, dialogs--bg-insetFields--fgText--fg-mutedHints--lineQuiet borders--light-fillThe light--failFailingCode
// Components only read surface tokens, so night and paper are never written twice.
const tokens = [['--bg', 'The page'], ['--bg-raised', 'Panels, cards, dialogs'], ['--bg-inset', 'Fields'], ['--fg', 'Text'], ['--fg-muted', 'Hints'], ['--line', 'Quiet borders'], ['--light-fill', 'The light'], ['--fail', 'Failing']];
export default function Tokens() {
return (
<div className="sy-grid" style={{ '--min': '11rem', '--gap': 'var(--s-3)' } as React.CSSProperties}>
{tokens.map(([t, what]) => (
<div key={t} className="sy-row sy-row--nowrap" style={{ '--gap': 'var(--s-3)' } as React.CSSProperties}>
<span style={{ width: '2.25rem', height: '2.25rem', borderRadius: 'var(--r-2)', background: `var(${t})`, border: '1px solid var(--line)', flex: 'none' }} />
<span className="sy-stack" style={{ '--gap': 0 } as React.CSSProperties}><code>{t}</code><span className="sy-text--xs sy-text--muted">{what}</span></span>
</div>
))}
</div>
);
} When to use it
Use it when
- Choosing the surface of a whole page (on
<html>), or of one section that must stand apart. - Following the person's system preference: set nothing.
Do not use it when
- Styling a component differently on each surface: use the tokens, and both work.
- Mixing surfaces inside one panel.
For everyone
- Text and controls keep at least 4.5:1 contrast on both surfaces (checked for every token pair).
- On paper the light gets an ink ring, so it never depends on a pale colour alone.