Skip to content

rune-kit: Kit::metrics for Button/Switch sizes, field box, TextArea type and Checkbox colours - #2172

Merged
opencodejr[bot] merged 1 commit into
devfrom
bot/issue-573
Nov 25, 2026
Merged

opencodejr[bot] merged 1 commit into
devfrom
bot/issue-573

Conversation

@opencodejr

@opencodejr opencodejr Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Closes #573 (the five components in the issue body).

What changed

  • New field Kit::metrics: rune_kit::Metrics, defined in crates/rune-kit/src/tokens/metrics.rs. Every entry is None by default, and None keeps today's built-in values, which still follow k.radius / k.ty / k.c when the control is built.
    • button: Option<BySize<ButtonMetrics>>: push Button height, horizontal padding, radius and icon per ControlSize. Replaces the private push_metrics; the deprecated ButtonSize sizes keep their own metrics.
    • switch: Option<BySize<SwitchMetrics>>: compact Switch track and knob sizes and inset per size. The built-in table is SwitchMetrics::NS_SWITCH. The web and standard looks are unchanged.
    • field: Option<FieldMetrics>: TextInput height and large height, horizontal padding (the leading spacer, leading-icon inset, right padding and clear-button margin all follow it; with no leading icon the text starts at least 6 pt in, because of the existing 6 pt gap), and the shared shell's radius and focus/invalid outline. focus_offset is measured outward from the box edge as El::outline takes it: -focus_width keeps the ring just inside, 0 or more draws a halo outside. TextArea takes the radius and outline.
    • text_area: Option<TextAreaMetrics>: TextArea text style and padding. The minimum and max-height calculations use the padding.
    • checkbox: Option<CheckboxColors>: checked/mixed fill, border and mark. Custom colours also stay under the pointer, with c.hover overlaid.
  • ButtonMetrics::kit, SwitchMetrics::NS_SWITCH, FieldMetrics::kit, TextAreaMetrics::kit and CheckboxColors::kit return today's values.
  • Kit::neutral and themes/opencode set metrics: Metrics::default(). Apps that build Kit as a struct literal must add that field too; the changelog entry says so.
  • Changelog: changelog/unreleased/2026-11-25-kit-metrics.md.

Not covered: the extra components from the issue comments (Menu/Select/Dialog/Toast/SegmentedControl radii, Keybind caps, IconButton hit target).

Testing

  • crates/rune-kit/tests/integration/kit_metrics.rs:
    • built-in defaults;
    • Tailwind-sized Button heights (32 pt, Mini 24), switch track and knob (32 × 18 / 14), TextInput height (32) and text inset (11 vs 8);
    • TextArea with 14/20 type and 12 pt padding: the input's 12 pt inset and resolved style, and minimum heights of 84 and 124 for 3 and 5 rows (rows * line + 2 * padding), against 80 by default;
    • a focused TextInput's outline as drawn: the built-in 1 pt ring matches the box exactly, and a 3 pt ring with offset 0 extends 3 pt past it on each side.
  • crates/rune-kit/src/controls/checkbox_tests.rs: custom checked fill, border and mark at rest; State::Hover keeps over(c.hover, fill) rather than surface_hover; unchecked boxes and kits without custom colours look as before.
  • Not compiled or run: the environment this was written in had no Rust toolchain, so cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaid and cargo check --workspace --all-targets still need to run in CI or locally.
  • Ran scripts/file-size.sh (no errors) and the public-repo hygiene grep on the diff (no matches).

Closes #573

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

0 participants