You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rune-kit: take component metrics (button and switch sizes, field padding and radius, text style, checkbox colours) from Kit #573
Porting an app whose design system is shadcn/Tailwind, most rune-kit components theme well through Kit, but a few metrics are fixed in code, so matching the design needs a wrapper or a decoration per component:
Button: heights per size are AppKit's (16/20/24/28/36); a Tailwind design needs 24/28/32/36 with its own horizontal padding and radius per size.
TextInput: the 2/8 pt padding, radius.md and the 1 pt inside focus ring are fixed; the design needs 32 pt height, 11 pt horizontal padding, radius 10 and an outer focus halo.
Switch: only the NSSwitch and the web sizes exist; the design needs 32 × 18.4 and 24 × 14.
Checkbox: the checked fill uses surface_weak; the design needs the primary fill and its foreground for the mark.
Wanted: these taken from Kit (per-size tables for Button and Switch, padding/radius/ring for fields, text style for TextArea, checked colours for Checkbox), defaulting to today's values.
Context: found while building a macOS menu-bar text expander on Rune (pinned at 29aacb6).
More components from the same port that need their metrics from Kit: Menu, Select and Dialog corner radii (10 / 10 / 14–18 pt here vs 6 pt), Toast radius (14 vs 8) and width (356 vs 320), the Checkbox checked fill/border/mark colours, Keybind cap size (18–20 pt caps vs 14), and the TextInput gap after its leading spacer (6 pt, which shifts text 6 pt right of a CSS-padded field).
With every Kit::radius entry set to zero, an open Select::new("shape", &["Square", "Rounded"]).appearance(SelectAppearance::Field).open(true) still has 6 pt popup corners and 4 pt option corners. SegmentedControl::new(&["System", "Dark", "Light"], Some(0)).fit() still uses 6 pt corners for the track and selection. The Select popup also fixes its option heights.
IconButton::new(kit.glyph.close).label("Close").control_size(ControlSize::Regular).on_press(|_: &mut ()| {}).build(&kit) exposes a 24 × 24 pt action in the accessibility tree (Small 20, Large 28). A wrapper sized to 26 pt on desktop or 32 pt on touch doesn't resize the actual button target.
Expected: source these metrics from Kit or let callers override them while keeping today's defaults. For IconButton, the hit target, focus cue and semantic bounds should all follow the effective size.
Thanks for the detailed list, and for the extra cases in the comments. I checked the current dev code, and the metrics you describe are fixed in the components; Kit doesn't expose them:
Button heights, padding and radius come from per-ControlSize literal tables in crates/rune-kit/src/controls/actions.rs (16/20/24/28/36).
Switch track and thumb sizes are literals in crates/rune-kit/src/controls/switch.rs. The only other variant is web().
Checkbox paints its checked state with c.surface_weak / c.std_border (crates/rune-kit/src/controls/checkbox.rs).
Kit (crates/rune-kit/src/tokens/kit.rs) has palette, type, radius, motion and elevation tokens, but no per-component metrics.
#286 added TextArea::plain(). It doesn't change the text style or padding, so it doesn't cover the TextArea point here.
I'm treating this as a feature request: component metrics (Button and Switch size tables, field padding/radius/focus ring, TextArea text style, Checkbox checked colours) read from Kit, with today's values as the defaults. The radius and size cases from the comments (Menu, Select, Dialog, Toast, SegmentedControl, Keybind, the IconButton hit target) belong to the same request.
focus_offset is measured outward from the edge, so 0 gives an outer halo and -focus_width keeps the ring inside. Text starts at least 6 pt in, whatever padding_x is.
The PR doesn't cover the extra components from the comments (Menu/Select/Dialog/Toast radii, Keybind caps, the IconButton hit target). It also hasn't been compiled or tested yet: the environment it was written in had no Rust toolchain, so CI still needs to build and test it.
Activity
Stringsaeed commentedon Nov 11, 2026
More components from the same port that need their metrics from
Kit:Menu,SelectandDialogcorner radii (10 / 10 / 14–18 pt here vs 6 pt),Toastradius (14 vs 8) and width (356 vs 320), theCheckboxchecked fill/border/mark colours,Keybindcap size (18–20 pt caps vs 14), and theTextInputgap after its leading spacer (6 pt, which shifts text 6 pt right of a CSS-padded field).pascalandr commentedon Nov 22, 2026
Two additional metrics cases on Rune
21e5342b9a:Kit::radiusentry set to zero, an openSelect::new("shape", &["Square", "Rounded"]).appearance(SelectAppearance::Field).open(true)still has 6 pt popup corners and 4 pt option corners.SegmentedControl::new(&["System", "Dark", "Light"], Some(0)).fit()still uses 6 pt corners for the track and selection. The Select popup also fixes its option heights.IconButton::new(kit.glyph.close).label("Close").control_size(ControlSize::Regular).on_press(|_: &mut ()| {}).build(&kit)exposes a 24 × 24 pt action in the accessibility tree (Small 20, Large 28). A wrapper sized to 26 pt on desktop or 32 pt on touch doesn't resize the actual button target.Expected: source these metrics from
Kitor let callers override them while keeping today's defaults. ForIconButton, the hit target, focus cue and semantic bounds should all follow the effective size.opencodejr commentedon Nov 25, 2026
Thanks for the detailed list, and for the extra cases in the comments. I checked the current
devcode, and the metrics you describe are fixed in the components;Kitdoesn't expose them:Buttonheights, padding and radius come from per-ControlSizeliteral tables incrates/rune-kit/src/controls/actions.rs(16/20/24/28/36).Switchtrack and thumb sizes are literals incrates/rune-kit/src/controls/switch.rs. The only other variant isweb().Checkboxpaints its checked state withc.surface_weak/c.std_border(crates/rune-kit/src/controls/checkbox.rs).Kit(crates/rune-kit/src/tokens/kit.rs) has palette, type, radius, motion and elevation tokens, but no per-component metrics.#286 added
TextArea::plain(). It doesn't change the text style or padding, so it doesn't cover theTextAreapoint here.I'm treating this as a feature request: component metrics (Button and Switch size tables, field padding/radius/focus ring,
TextAreatext style,Checkboxchecked colours) read fromKit, with today's values as the defaults. The radius and size cases from the comments (Menu, Select, Dialog, Toast, SegmentedControl, Keybind, theIconButtonhit target) belong to the same request.opencodejr commentedon Nov 25, 2026
I've opened a PR that adds
Kit::metrics. It covers the five components in your issue:button: a per-ControlSizetable of height, horizontal padding, radius and icon sizeswitch: per-size compact track and knob sizesfield:TextInputheight, horizontal padding, radius, and focus outline width and offsettext_area:TextAreatext style and paddingcheckbox: checked fill, border and mark coloursEach entry defaults to
None, which keeps today's values, and helpers such asFieldMetrics::kit(&k)return those values to start from. For your field:focus_offsetis measured outward from the edge, so 0 gives an outer halo and-focus_widthkeeps the ring inside. Text starts at least 6 pt in, whateverpadding_xis.The PR doesn't cover the extra components from the comments (Menu/Select/Dialog/Toast radii, Keybind caps, the
IconButtonhit target). It also hasn't been compiled or tested yet: the environment it was written in had no Rust toolchain, so CI still needs to build and test it.Fixed in #2172.