Skip to content

rune-kit: take component metrics (button and switch sizes, field padding and radius, text style, checkbox colours) from Kit #573

Done

Description

@Stringsaeed

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.
  • TextArea: the text style is fixed at ty.ui on a 1.35 line with 8 pt padding; the design needs 14/20. (Related: TextArea: no plain mode, so a container can't draw its own box around a multi-line field #286.)
  • 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).

Activity

  1. Stringsaeed commented on Nov 11, 2026

    @Stringsaeed
    Author

    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).

  2. pascalandr commented on Nov 22, 2026

    @pascalandr

    Two additional metrics cases on Rune 21e5342b9a:

    • 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.

  3. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    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.

  4. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    I've opened a PR that adds Kit::metrics. It covers the five components in your issue:

    • button: a per-ControlSize table of height, horizontal padding, radius and icon size
    • switch: per-size compact track and knob sizes
    • field: TextInput height, horizontal padding, radius, and focus outline width and offset
    • text_area: TextArea text style and padding
    • checkbox: checked fill, border and mark colours

    Each entry defaults to None, which keeps today's values, and helpers such as FieldMetrics::kit(&k) return those values to start from. For your field:

    k.metrics.field = Some(FieldMetrics { height: 32.0, padding_x: 11.0, radius: 10.0, focus_width: 3.0, focus_offset: 0.0, ..FieldMetrics::kit(&k) });

    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.

    Fixed in #2172.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions