Design system
Your design system is what makes the app feel like one product: colour, type, spacing, radius, elevation, motion, chart palettes, and the styles used by buttons, inputs, cards, tabs, modals, and other widgets.
Fission reads Design System Package JSON at build time. Your app doesn’t parse JSON at runtime. A build script reads dsp.json and tokens.json, resolves references, and generates normal Rust code. Your app chooses a generated theme and puts it in Env.
That keeps rendering simple. Widgets read typed Rust values from
cx.view.env().theme in a Compose view; they do not search JSON or look up
token names while drawing a frame. Code generation happens during the Cargo
build, not during component conversion.
What gets generated
A DSP package has two main files:
dsp.json, which describes the package, components, patterns, assets, and where the token file lives.
tokens.json, which contains primitive and semantic values such as colors, font sizes, spacing, radius, shadows, motion, and chart palettes.
Fission’s generator turns them into a Rust type that implements DesignSystem.
include!(concat!(env!("OUT_DIR"), "/app_design_system.rs"));
DesktopApp::new(MyApp)
.with_design_system::<AppDesignSystem>(DesignMode::Light)
.run()?;
AppDesignSystem is generated during cargo build, compiled into your app, and used like any other Rust type.
Add a DSP package to an app
Create a design/ folder and put the package files in it:
my-app/
Cargo.toml
build.rs
design/
dsp.json
tokens.json
src/
main.rs
Then generate the Rust theme from your app’s package:
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=design/dsp.json");
println!("cargo:rerun-if-changed=design/tokens.json");
let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
let dsp_path = manifest_dir.join("design/dsp.json");
fission_design_system_codegen::generate(
fission_design_system_codegen::Config::new(dsp_path)
.out_file("app_design_system.rs")
.type_name("AppDesignSystem")
.crate_path("fission::theme"),
)
.expect("failed to generate design system");
}
Config is built with methods rather than a struct literal, so new options can be added without
breaking your build.rs:
| | |
|---|
| | The dsp.json to generate from. |
| | File written under OUT_DIR. |
| | Name of the generated design system type. |
| | Path the generated code uses to reach the theme crate. Use fission::theme through the fission facade. |
| {crate_path}::FissionDefaultDesignSystem | Design system whose component recipes fill in any recipe this one omits. |
.require_complete_components() | | Fail the build when a required component recipe is missing instead of inheriting it. |
Your design system only needs recipes for the components it changes. Missing recipes come from
inherit_from, so widgets don’t fall back to empty styles. Call require_complete_components()
when it must stand alone.
Migrating from the Config struct literal
Earlier releases constructed Config with a struct literal. Config is now #[non_exhaustive],
so replace the literal with the builder:
// Before
fission_design_system_codegen::Config {
dsp_path,
out_file: "app_design_system.rs".into(),
type_name: "AppDesignSystem".into(),
crate_path: "fission::theme".into(),
}
// After
fission_design_system_codegen::Config::new(dsp_path)
.out_file("app_design_system.rs")
.type_name("AppDesignSystem")
.crate_path("fission::theme")
Add the generator as a build dependency:
[dependencies]
fission = { version = "0.16.0", default-features = false, features = ["desktop"] }
[build-dependencies]
fission-design-system-codegen = "0.16.0"
Generated code uses Fission’s public theme API. Import Fission as usual:
use fission::prelude::*;
include!(concat!(env!("OUT_DIR"), "/app_design_system.rs"));
Let the user choose light or dark
If users can choose light or dark mode, keep that choice in GlobalState and mirror it into Env with .with_sync_env(...).
DesktopApp::new(MyApp)
.with_design_system::<AppDesignSystem>(DesignMode::Light)
.with_sync_env(|state: &MyState, env: &mut Env| {
env.theme = AppDesignSystem::theme(state.theme_mode);
env.window.title = WindowTitle::plain("My Fission App");
})
.run()?;
Env is shared with widgets during component conversion. Putting the generated Theme there means every widget sees the same colours, typography, sizes, shadows, and motion for that frame.
What Fission consumes today
The generated theme is more than metadata. Fission resolves DSP component styles into typed runtime structs.
Buttons consume hierarchy styles such as primary, secondary_color, secondary_gray, tertiary_color, link_color, and destructive. Button sizes such as sm, md, lg, and xl map to first-class component size slots. State tables such as default, hover, active, focus, and disabled resolve into typed style values before the widget renders.
Inputs, badges, tabs, cards, modals, tooltips, and progress bars follow the same model. They read generated component styles for background fills, text colors, borders, radius, padding, font sizes, font weights, line heights, shadows, and state-specific overrides. Charts read the generated data-visualization palette from the theme instead of inventing a separate chart palette.
The key rule is that JSON stops at build time. Runtime code sees Rust values.
Colour pairs
Every component fill has a matching colour for its text and icons. Ask for the pair together so the content stays legible:
use fission::theme::ColorRole;
fission_component! {
pub InvoiceHeading<()> {}
view(_heading, _state, cx) {
let pair = cx.view.env().theme.tokens.colors.pair(ColorRole::Card);
} =>
Container(
child: Text(cx.tr("invoice.title")).color(pair.on),
).bg(pair.fill)
}
| | | |
|---|
| | | |
| | | |
| | | |
| | | surface_raised, on_surface |
| | | surface_sunken, text_muted |
| | | |
| | | |
| | | |
| | | |
input, the border of text fields, falls back to border.
These newer roles are optional. If the DSP leaves one out, Fission uses the
fallback in the last column, so {color.light.card} still works when
tokens.json has no card value. Declare the role under color.light and
color.dark to give it its own value. Validate foreground/background contrast
in both modes; pairing token names does not prove accessibility after custom
colours, opacity, imagery, or glass effects are applied.
Start from a bundled system when it fits
Fission ships DSP packages for several common product styles. They aren’t special renderer modes; each is a normal dsp.json and tokens.json package under crates/core/fission-theme/design. The generator turns it into a Rust DesignSystem at build time.
| | |
|---|
Fission default (Tidewater) | FissionDefaultDesignSystem | You want Fission's own look: teal actions on a faintly teal-tinted canvas, with compact controls. |
| FissionMaterialDesign3DesignSystem | You want an Android-oriented, role-based design system with Material-style color, shape, and component density. |
| FissionFluent2DesignSystem | You want a Microsoft productivity-app feel with Fluent-style density, neutral surfaces, Segoe-style typography, and restrained radius. |
| FissionLiquidGlassDesignSystem | You want layered translucent surfaces, luminous tint, larger radius, and depth-forward presentation. |
| FissionCupertinoDesignSystem | You want UIKit-style iOS conventions while using the cross-platform Cupertino naming convention. |
| | You want a warmer Fission look: the orange of the Fission logo on stone neutrals, with slightly rounder corners. |
| FissionGraphiteDesignSystem | You want a restrained Fission look: ink-black primary actions, zinc neutrals, one blue accent for focus, links and selection controls. |
Use a preset exactly the same way you use a generated app design system:
use fission::prelude::*;
use fission::theme::{DesignMode, FissionCupertinoDesignSystem};
DesktopApp::new(MyApp)
.with_design_system::<FissionCupertinoDesignSystem>(DesignMode::Light)
.with_sync_env(|state: &MyState, env: &mut Env| {
env.theme = FissionCupertinoDesignSystem::theme(state.theme_mode);
})
.run()?;
Presets are a starting point, not a cage. Copy one into your app’s design/ folder if you need to change its brand colour, radius scale, chart palette, or component states. Then generate AppDesignSystem from your copy.
The architecture stays the same: DSP JSON goes in at build time, and widgets read typed Rust theme values at runtime.
Where to get DSP and token files
You can start from Fission's default package, export from a design tool, or use public token systems as reference material.
Adobe introduced Design System Package as an open package format for sharing design-system information across tools, including tokens, documentation, snippets, and examples.
Google's Material token repository documents Material Design DSP usage and can be used as a reference for a real DSP-style token package.
Adobe Spectrum publishes structured design-token data for colors, layout, typography, and component tokens.
Tokens Studio and Style Dictionary are useful when your team already manages design tokens in Figma or JSON and needs to transform them for engineering.
Token generators such as Tokenry can produce a first pass of primitive and semantic tokens when you are starting from a brand color instead of an existing system.
Useful links:
Example app
The repository includes examples/todo-design-system. It’s deliberately small: a todo list, text input, buttons, badges, a card, and a light/dark toggle.
Its build.rs uses Fission’s bundled DSP package rather than copying large JSON files into the example. In your app, copy the default package, use your design team’s package, or point the generator at output from your design tooling.
Run it with:
cargo run -p todo-design-system
Packaged fonts and design fidelity
Design-system packages can declare font files in assets.fonts. Codegen checks
them at build time and exposes them through DesignSystem::font_faces().
Native shells register the faces for rendering. HTML delivery is a separate
policy: Web, Static site, and SSR default to WebFontDelivery::None; choose
External or Inline explicitly when browser CSS should load those fonts.
Declaring a face does not silently add base64 font bytes to every page's CSS.
Use typed layout and paint primitives with your design tokens: Length for responsive dimensions, Fill for gradients, BoxShadow for elevation, and BackdropFilter for glass or blur. This keeps visual fidelity inspectable and testable instead of hiding it in target-specific code.