Repository navigation
Description
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.
- 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.
- 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.
- 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.
- 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.
- 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
- rune-kit: Composable headless components and public reusable utilities #2653 — Composable headless components and public reusable utilities.
- feat(rune-kit): add composable headless primitives and expose reusable utilities #3208 — Initial headless implementation.
- rune-kit: a split view of nested panes (a tree of horizontal and vertical splits) is missing, and SplitView can't be reused for one #2834 — Composable split panes and reusable grip behaviour.
- rune-kit: a zoom/pan/fit canvas for arbitrary content, not only images #720 — General-purpose zoom/pan canvas.
- rune-kit: First-party interactive node graph editor #2532 — Interactive canvas and node graph editor.
Activity
opencodejr commentedon Dec 2, 2026
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,Kithelpers) with styled components, but no styled component delegates toheadless::*yet (e.g.crates/rune-kit/src/controls/checkbox.rssets its own role, checked state, focusability, and handlers independently ofheadless::Checkbox).ComboboxState,DateFieldState,DatePickerState,DateTimeFieldState,TimeFieldState,NumberFieldState,ShortcutRecorderState,ToastStackState,TableState,TreeModel,SortableState,PaneState,ZoomPan), while their geometry, gesture, and event-binding layers stay private—includingView,Geom,gesture::*,ZoomPan::{measure, pan_live, drag, wheel, magnify, key}, andcanvas::bindincrates/rune-kit/src/zoom_pan/.unifying styled components onto
headless::*would eliminate behavioural drift and keep the public headless apis exercised byrune-kititself, while keepingtests/a11y/golden/and existing styled builder apis intact. exposing lower-levelzoom_paninternals also touches #2532 (needs-design), where boundedZoomPanvs unboundedLive-backed canvas primitives is still open.two architectural questions before committing to a plan:
rune-kitcomponents be refactored to build on top ofrune_kit::headlessas a single source of truth (starting with the controlsheadlessalready covers:Button,Switch,Checkbox,Collapsible/Disclosure,Menu,Popover,Tabs), or keepheadlessas an additive parallel layer sharing lower-level helpers?headlessbuilders 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 shouldzoom_panexposure move ahead independently of rune-kit: First-party interactive node graph editor #2532 or align with its unbounded canvas design?Vricken commentedon Dec 2, 2026
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.
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.
opencodejr commentedon Dec 2, 2026
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_panwith #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) callspress_on_return(), while styledSwitch(crates/rune-kit/src/controls/switch.rs) does not.leaving this under
needs-designfor a maintainer call on unifying styled components ontorune_kit::headless, the api granularity for remaining components, and howzoom_panaligns with #2532.