Theming & tokens

Colors and sizes come from one set of design tokens. On the web they are CSS variables in @dotwear/web/tokens.css; in SwiftUI they are a DotwearTheme value in the environment.

Lengths are counted in dots

Every length is a number of dots multiplied by the pixel unit (2px, i.e. 2 pt in SwiftUI). A button that is 16 dots tall is 32 px. Because everything is a whole multiple of one unit, borders, steps and shadows always land on whole pixels.

Colors

CSS variableSwiftUIValue
--dw-color-bg theme.colors.background #f8f8f8
--dw-color-fg theme.colors.foreground #181818
--dw-color-border theme.colors.border #181818
--dw-color-primary theme.colors.primary #181818
--dw-color-on-primary theme.colors.onPrimary #f8f8f8
--dw-color-danger theme.colors.danger #181818
--dw-color-focus theme.colors.focus #585858
--dw-color-disabled theme.colors.disabled #a8a8a8

Shape

CSS variableSwiftUIValue
--dw-shape-pixel-unit theme.pixelUnit 2px
--dw-shape-border-width theme.borderWidth 1 dot
--dw-shape-border-gap theme.borderGap 1 dot
--dw-shape-border-inner-width theme.borderInnerWidth 1 dot
--dw-shape-corner-step theme.cornerStep 1 dot

Using tokens

Web (React)

In CSS, use the variables directly: var(--dw-color-primary). From TypeScript:

import { tokens, tokenVars } from "@dotwear/web";

// CSS variables (follow overrides made in CSS)
const badge = {
  background: tokenVars.color.primary,
  color: tokenVars.color.onPrimary,
  padding: `calc(2 * ${tokenVars.shape.pixelUnit})`,
};

// Raw values (for canvas, charts, native bridges…)
const primaryHex = tokens.color.primary; // "#181818"

iOS (SwiftUI)

struct Badge: View {
    @Environment(\.dotwearTheme) private var theme

    var body: some View {
        Text("NEW")
            .padding(theme.dots(2))   // 2 dots → points
            .background(theme.colors.primary)
    }
}

Applying and customizing a theme

Web (React)

Override the variables after importing tokens.css — globally or for one part of the page.

:root {
  --dw-color-primary: #cc334d;
}

.admin-area {
  --dw-color-primary: #3a9d5d;
}

iOS (SwiftUI)

Set the theme at the root of your app. Any view can override it for its subtree with .dotwearTheme(...).

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            RootView()
                .dotwearTheme(.default)
        }
    }
}

extension DotwearTheme {
    static let brand: DotwearTheme = {
        var theme = DotwearTheme.default
        theme.colors.primary = Color(red: 0.8, green: 0.2, blue: 0.3)
        return theme
    }()
}

Keep the pixel unit a whole number. Changing it scales the whole UI by a whole factor; fractional values would blur edges.

Icon palettes are themed separately — see Palettes.

The Dotwear look

Dotwear recalls a four-shade handheld game screen: black, white and two grays, double-line frames, and the DotGothic16 pixel font (SIL Open Font License). The font is drawn on a 16 px grid, so keep text at 16, 32 or 48 px to stay sharp. Because there are only four shades, errors are shown with words and icons, never by color alone.

For a single-line frame, set --dw-shape-border-gap and --dw-shape-border-inner-width to 0.

Your order has been saved.