Upstream: crates/rune-kit/README.md § Use at
65f8eb43f710, MIT © Anomaly. Bundled by build-rune-apps; links point at this snapshot or at GitHub at that rev.
Use
let k = rune_theme_opencode::kit(cx.system_dark());
let mut layer = Vec::new(); // overlay contents, mounted above everything
let body = col()
.child(Button::new("Save").variant(ButtonVariant::Contrast).on_press(|s: &mut App| s.save()).build(k))
.child(Switch::new(s.sync).label("Sync").on_toggle(|s: &mut App| s.sync = !s.sync).build(k))
.child(
Select::new("model", &MODELS)
.current(Some(&s.model))
.open(s.open == Some("model"))
.on_toggle(|s: &mut App| s.toggle("model"))
.on_close(|s: &mut App| s.open = None)
.on_choose(|s: &mut App, v: &str, _: &mut Tx| s.model = v.into())
.build(k, &mut layer),
);
rune_kit::root(body, layer) // the view's root
AppSpec { fonts: rune_theme_opencode::FONTS, families: rune_theme_opencode::FAMILIES, .. }
loads Inter and IBM Plex Mono.
For a small app theme, derive the semantic colours from three opaque tokens:
let t = rune::Theme::from_json(THEME, dark)?;
let mut k = rune_kit::Kit::from_palette(rune_kit::PaletteSeed {
bg: t.color("bg"),
fg: t.color("text"),
accent: t.color("accent"),
});
k.radius.sm = 3.0;
Layers step OKLab lightness away from bg; borders, hover and press are fg at low alpha,
as a browser blends it (solved over bg, k.blend_over, when built in a window that blends in
linear light). Secondary text uses OKLab with contrast floors of 4.5:1
(muted) and 3:1 (faint), when the supplied foreground supports them. Focus rings are a neutral
blue (set k.c.border_focus to change it), and elevation rings follow k.c.border_base when
painted, so overriding border tokens after from_palette restyles them too. It uses neutral
typography and motion; override individual tokens as needed. The default glyph set includes k.glyph.lock, k.glyph.eye and k.glyph.eye_off.
- Builders end in
.build(&kit); overlays take.build(&kit, &mut layer)and return their trigger. Content isEl::anchoredto the trigger (flips, shifts, stays inside the window). - Handlers attach through the builder (
on_press,on_toggle,on_select,on_choose,on_edit) so disabled components drop them. For pointer menus, storeSome(point)fromEl::on_secondary_pressand usecontext_menu("menu", trigger, s.point).item(..).on_close(..).build(k, &mut layer). Clear the point on close or selection; positioning uses Menu's viewport-aware anchor. .state(State::Hover | Pressed | Focus | Disabled)forces a visual state (the stories'data-state); at rest the runtime drives hover and press.- Translucent tokens are authored for sRGB blending, as a browser composites them, which is how
windows blend by default. In a window that blends in linear light (
srgb_blend(false)) they resolve re-solved overbg_baseinstead (rune::theme::for_blend): get the kit in the view, whererune::theme::blends_srgbreports the window's mode, so a liveTx::set_srgb_blendswitch is followed. Colours painted on other surfaces (contrast buttons, accent switches) go throughKit::on(colour, backdrop).