Skip to the content

createTheme

createTheme builds a resolved Theme — palettes, surface ladder, spacing, type, motion and the token layers — from a partial input. Every key is optional and merges over the stock defaults. Use it in tests, in scripts, or to pass a pre-built theme to ApollionProvider; for most apps the provider's colors prop is enough.
Theming

Usage

import { Button } from '@apollion-dsi/core/elements/button';
import { ApollionProvider, createTheme } from '@apollion-dsi/core/themes';

const theme = createTheme({
  colors: { main: '#003750', primary: '#32AFDC', warning: 'green' },
  dimension: 'normal',
  textSize: 'default',
});

<ApollionProvider theme={theme}>
  <Button text="Submit" color="warning" />
</ApollionProvider>;

A theme passed through theme is a single literal theme: the provider does not derive a dark pair from it. To keep the mode engine, pass colors to the provider instead, or pass a lightTheme/darkTheme pair.

Input

Key
Type
Default
Controls
colors
ColorsInput
stock seeds
Brand, function, feedback and contrast seeds — see Colors
dimension
'compact' | 'normal' | 'spacious'
'normal'
Spacing density
textSize
'smaller' | 'default' | 'larger' | 'largest'
'default'
Text and icon size
typeWeight
'light' | 'regular' | 'stronger'
'regular'
Origin of the font-weight ladder
spacing
SpacingInput
4px grid
Spacing multiplier and aliases
font
FontInput
stock type
Families, sizes, weights, line heights
border
BorderInput
stock
Widths, styles and radii
motion
MotionInput
stock
Durations, easings and intents
breakpoints
BreakpointInput
0/575/767/990/1200
Viewport bands
containerSizes
ContainerSizesInput
240–900
Container-query thresholds
layout
LayoutInput
stock
Page constants such as pageMaxWidth
zIndex
Partial<ZIndexInput>
stock
Overlay layering (sticky, dropdown, toast, modal)
component
ComponentTokensInput
stock
Per-component token overrides
Scrolls sideways inside the table. The page does not.

Static tokens

To produce the same theme as CSS variables, JSON or TypeScript, declare the seeds in apollion.config.mjs and run yarn apollion-tokens build. See Build CLI.

See also