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; in
React Native they come from <DotwearTheme> and are read with useDotwear(); in
Flutter they are a DotwearThemeData theme extension, read with Dotwear.of(context).
Lengths are counted in dots
Every length is a number of dots multiplied by the pixel unit (2px, i.e. 2 pt in
SwiftUI, 2 dp in React Native and 2 logical pixels in Flutter). A button that is 16 dots tall is 32 px. React Native and Flutter round one dot down to
a whole number of device pixels, so on a 2.625× screen a dot is 5 device pixels. Because everything is a whole multiple of one unit, borders,
steps and shadows always land on whole pixels.
Colors
| CSS variable | SwiftUI | React Native | Flutter | Value | |
|---|---|---|---|---|---|
--dw-color-bg |
theme.colors.background |
colors.background |
dw.colors.background |
#f8f8f8 |
|
--dw-color-fg |
theme.colors.foreground |
colors.foreground |
dw.colors.foreground |
#181818 |
|
--dw-color-border |
theme.colors.border |
colors.border |
dw.colors.border |
#181818 |
|
--dw-color-primary |
theme.colors.primary |
colors.primary |
dw.colors.primary |
#181818 |
|
--dw-color-on-primary |
theme.colors.onPrimary |
colors.onPrimary |
dw.colors.onPrimary |
#f8f8f8 |
|
--dw-color-danger |
theme.colors.danger |
colors.danger |
dw.colors.danger |
#181818 |
|
--dw-color-focus |
theme.colors.focus |
colors.focus |
dw.colors.focus |
#585858 |
|
--dw-color-disabled |
theme.colors.disabled |
colors.disabled |
dw.colors.disabled |
#a8a8a8 |
Shape
| CSS variable | SwiftUI | React Native | Flutter | Value |
|---|---|---|---|---|
--dw-shape-pixel-unit |
theme.pixelUnit |
theme.pixelUnit |
dw.theme.pixelUnit |
2px |
--dw-shape-border-width |
theme.borderWidth |
theme.borderWidth |
dw.theme.borderWidth |
1 dot |
--dw-shape-border-gap |
theme.borderGap |
theme.borderGap |
dw.theme.borderGap |
1 dot |
--dw-shape-border-inner-width |
theme.borderInnerWidth |
theme.borderInnerWidth |
dw.theme.borderInnerWidth |
1 dot |
--dw-shape-corner-step |
theme.cornerStep |
theme.cornerStep |
dw.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)
}
}
React Native
useDotwear() returns the theme, its colors, and dots(n) to convert dots to dp.
function Badge() {
const { colors, dots } = useDotwear();
return (
// dots(2): 2 dots → dp, always a whole number of device pixels
<View style={{ padding: dots(2), backgroundColor: colors.primary }}>
<Text style={{ color: colors.onPrimary }}>NEW</Text>
</View>
);
}
// Raw values (for charts, native modules…)
const primaryHex = tokens.color.primary; // "#181818"
Flutter
Dotwear.of(context) returns the theme, its colors, and dots(n) to convert dots to logical pixels.
class Badge extends StatelessWidget {
const Badge({super.key});
@override
Widget build(BuildContext context) {
final dw = Dotwear.of(context);
return Container(
padding: EdgeInsets.all(dw.dots(2)), // 2 dots → a whole number of device pixels
color: dw.colors.primary,
child: Text('NEW', style: TextStyle(color: dw.colors.onPrimary)),
);
}
}
// Raw values
const primary = DotwearTokens.colorPrimary;
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
}()
}
React Native
Wrap your app in <DotwearTheme>. Nest another <DotwearTheme theme={…}> to override values for a subtree.
<DotwearTheme>
<RootView />
</DotwearTheme>
// Only the values you pass are changed; the rest follow the outer theme
<DotwearTheme theme={{ colors: { primary: "#cc334d" } }}>
<RootView />
</DotwearTheme>
Flutter
Pass the theme to MaterialApp. Use Theme(data: …) to override it for a subtree.
MaterialApp(
theme: const DotwearThemeData().toThemeData(),
home: const RootView(),
);
final brand = const DotwearThemeData().copyWith(
colors: const DotwearColors(primary: Color(0xFFCC334D)),
);
// MaterialApp(theme: brand.toThemeData(), …)
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.