Skip to content

rune-kit: Extend headless component coverage and unify styled/headless behaviour #3211

Backlog

Description

@Vricken

Motivation

Following #2653 and its implementation in #3208, Rune Kit now has an excellent foundation for headless components and reusable component-authoring utilities. Thank you for implementing this!

I’d like to propose extending this architecture consistently across Rune Kit, particularly by ensuring that styled components and downstream custom components consume the same public behavioural primitives.

  1. A single source of truth for component behaviour

Ideally, Rune Kit’s styled components should themselves be built on top of the same public headless primitives available to downstream developers, rather than maintaining separate implementations of equivalent behaviour.

For example, the styled Checkbox currently establishes its accessibility role, checked state and interaction behaviour directly in its own builder, independently of headless::Checkbox.

Where appropriate, the styled implementation could instead consume the headless primitive and supply its default presentation.

This would provide several benefits:

  • Avoid duplicating interaction logic, state machines and accessibility handling.
  • Ensure bug fixes and behavioural improvements benefit both styled and custom components.
  • Prevent styled and headless implementations from gradually diverging.
  • Ensure the public headless APIs are continuously exercised by Rune Kit itself.
  • Allow downstream developers to achieve the same behavioural quality as first-party components without duplicating their implementations.

Ideally, Rune Kit should be a reference consumer of its own public component-authoring APIs.

A downstream developer implementing a custom component should have access to the same reusable behavioural abstractions that Rune Kit uses internally.

  1. Extend headless coverage across interactive components

The new rune_kit::headless module provides Button, Toggle, Switch, Checkbox, Disclosure, Listbox, Menu, Tabs and Popover primitives.

It would be valuable to extend this coverage to the remaining interactive components and their underlying behaviour, including:

Form controls

  • Select and Combobox.
  • RadioGroup and SegmentedControl.
  • Slider and ColorPicker.
  • NumberField.
  • TimeField, DateField, DateTimeField and DatePicker.
  • TextInput and TextArea, building on Rune’s existing text editing primitives.
  • ShortcutRecorder.

Overlays and feedback

  • Dialog.
  • Tooltip and HoverCard.
  • Toast and notification interactions.

Data and navigation

  • Table.
  • Tree.
  • ScrollBar.
  • TabStrip, including drag reordering, grouping and tear-out.

Advanced interaction

  • Canvas and zoom/pan interactions.
  • Split panes and resize handles.
  • Drag-and-drop, selection and reordering.
  • CodeEditor and other specialised editing components.

Many of these already expose useful public state types or underlying primitives. The objective would be to make their remaining reusable behaviour independently accessible, without duplicating functionality that is already public.

Purely presentational components do not necessarily need separate headless equivalents.

  1. Apply the same principles to advanced components and interaction primitives

I think this architectural direction is particularly important beyond conventional form controls.

For example, Canvas and ZoomPan already provide a useful, largely unstyled foundation for building interactive canvases. They accept arbitrary El content without requiring a Kit, and expose coordinate transformations, zooming, panning and fit-to-content.

However, in crates/rune-kit/src/zoom_pan/, several underlying abstractions remain private:

  • Geom and View.
  • The gesture state machine.
  • ZoomPan::measure and pan_live.
  • Drag, wheel, magnification and keyboard handlers.
  • The canvas’s event-binding implementation.

An application that wants to substantially customise canvas interactions, introduce different camera constraints or construct its own canvas wrapper cannot necessarily reuse this existing functionality directly.

Similar considerations apply to more advanced components such as tables, trees, editors and drag-and-drop systems.

Where a complete headless component is not the most appropriate abstraction, exposing its reusable state machines, geometry, interaction handlers and composition utilities would serve the same purpose.

This also relates to #2532, where reusable canvas primitives would provide a foundation for node graph editors and other interactive canvas applications.

  1. Public APIs and source-level composability

A useful architectural principle would be that a developer should be able to inspect an existing Rune Kit component, copy its implementation into their own crate, and adapt its appearance, structure or behaviour while continuing to consume its underlying shared functionality through public APIs.

They should not need to recursively copy unrelated private dependencies or maintain a fork simply because their component differs from the default implementation.

This does not require exposing every private implementation detail. Rather, it means extracting reusable functionality into appropriate public abstractions and having Rune Kit itself consume those abstractions.

This would also enable third-party component libraries to build on Rune with the same foundational capabilities as Rune Kit.

  1. Behavioural consistency and testing

Sharing the behavioural implementation would also make it possible to test important invariants independently of presentation:

  • Keyboard navigation and activation.
  • Focus management and restoration.
  • Accessibility roles, states and actions.
  • Disabled and read-only behaviour.
  • Selection and editing state.
  • Pointer capture and gesture cancellation.
  • Reduced-motion behaviour where applicable.

Both Rune Kit’s styled components and downstream custom components would benefit from the same tested implementation.

Desired architectural direction

The intended relationship would be:

Rune Kit styled components Third-party/custom components
\ /
Shared public behaviour
and component utilities
|
Rune core

Rather than treating headless components as an alternative collection of controls alongside the existing styled library, I think they could become the common behavioural foundation on which Rune Kit itself is built.

The broader goal is comprehensive composability: developers should be able to use, extend, adapt or replace Rune Kit components without sacrificing their underlying interaction quality, accessibility or performance.

Would this be a suitable architectural direction for the remaining existing components and future additions to Rune Kit?

Related

Activity

  1. opencodejr commented on Dec 2, 2026

    @opencodejr
    Contributor

    confirmed against dev:

    • rune_kit::headless (feat(rune-kit): add composable headless primitives and expose reusable utilities #3208) shares lower-level helpers (Acts, list_nav, Grip, ButtonSkin, Kit helpers) with styled components, but no styled component delegates to headless::* yet (e.g. crates/rune-kit/src/controls/checkbox.rs sets its own role, checked state, focusability, and handlers independently of headless::Checkbox).
    • many remaining components already expose public state types (ComboboxState, DateFieldState, DatePickerState, DateTimeFieldState, TimeFieldState, NumberFieldState, ShortcutRecorderState, ToastStackState, TableState, TreeModel, SortableState, PaneState, ZoomPan), while their geometry, gesture, and event-binding layers stay private—including View, Geom, gesture::*, ZoomPan::{measure, pan_live, drag, wheel, magnify, key}, and canvas::bind in crates/rune-kit/src/zoom_pan/.

    unifying styled components onto headless::* would eliminate behavioural drift and keep the public headless apis exercised by rune-kit itself, while keeping tests/a11y/golden/ and existing styled builder apis intact. exposing lower-level zoom_pan internals also touches #2532 (needs-design), where bounded ZoomPan vs unbounded Live-backed canvas primitives is still open.

    two architectural questions before committing to a plan:

    1. styled-on-headless unification: should styled rune-kit components be refactored to build on top of rune_kit::headless as a single source of truth (starting with the controls headless already covers: Button, Switch, Checkbox, Collapsible/Disclosure, Menu, Popover, Tabs), or keep headless as an additive parallel layer sharing lower-level helpers?
    2. priority and granularity for remaining components: should the next slice expand headless builders for standard controls/overlays (Select/Combobox, RadioGroup, SegmentedControl, Slider, Dialog, Tooltip/HoverCard), or focus on opening up lower-level state/geometry/handler primitives on advanced components (zoom_pan, Table, Tree, ScrollBar, TabStrip)—and should zoom_pan exposure move ahead independently of rune-kit: First-party interactive node graph editor #2532 or align with its unbounded canvas design?
  2. Vricken commented on Dec 2, 2026

    @Vricken
    Author
    1. Styled-on-headless unification: Yes, absolutely. This is the central motivation of the proposal. Keeping styled and headless components as parallel implementations would introduce unnecessary duplication, create opportunities for behavioural divergence over time, and increase maintenance costs.

    Ideally, Rune Kit’s styled components should be consumers of the same public behavioural primitives available to downstream developers. Improvements and fixes should benefit both automatically, rather than needing to be implemented separately.

    1. Coverage and granularity: Ideally, this architecture should extend across all existing and future interactive components for consistency, rather than prioritising standard controls at the expense of advanced components, or vice versa.

    That doesn’t necessarily mean every component needs a dedicated headless builder. Purely presentational components have little reason to expose a separate behavioural abstraction, while more complex components may benefit from public state machines, geometry, gesture handlers and composition utilities instead.

    The important principle is that reusable behaviour should be accessible independently of presentation, and Rune Kit itself should consume those same public abstractions.

    Regarding zoom_pan and #2532, I would favour aligning their underlying abstractions to avoid introducing separate, overlapping canvas interaction systems. Both bounded and unbounded canvases should be able to share relevant functionality wherever appropriate.

    I’ll leave the precise API granularity and implementation structure to the maintainers. The desired outcome is comprehensive and consistent extensibility across Rune Kit, rather than a limited collection of independent headless alternatives.

  3. opencodejr commented on Dec 2, 2026

    @opencodejr
    Contributor

    that direction is clear: styled components consuming the same public behavioural primitives as downstream callers (single source of truth rather than parallel copies), extending consistently across both standard controls and advanced components (headless builders where appropriate, public state/geometry/gesture/handler primitives for complex ones, skipping purely presentational components), and aligning zoom_pan with #2532 so bounded and unbounded canvases share underlying abstractions.

    one concrete example of drift already on dev: headless::Switch (crates/rune-kit/src/headless/controls.rs) calls press_on_return(), while styled Switch (crates/rune-kit/src/controls/switch.rs) does not.

    leaving this under needs-design for a maintainer call on unifying styled components onto rune_kit::headless, the api granularity for remaining components, and how zoom_pan aligns with #2532.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions