Repository navigation
Description
rune-kit: Composable headless components and public reusable utilities
Motivation
Rune Kit provides a growing collection of themeable components, and Rune's underlying primitives allow applications to build custom UI from scratch.
However, there is an important middle ground between configuring an existing component and completely reimplementing it.
An application may want to retain most of a component's existing functionality while significantly changing its appearance, structure or interaction behaviour. Ideally, developers should be able to copy an existing Rune Kit component into their own crate, modify the relevant parts, and continue using its underlying shared utilities.
Currently, private helpers, internal state and tightly coupled presentation and behaviour can make this difficult without duplicating implementation logic or maintaining a fork.
This is particularly relevant given Rune's contribution model, where downstream developers cannot necessarily implement a change locally and have that exact implementation upstreamed through a pull request.
Proposed architectural principles
1. Separate behaviour from presentation
Where appropriate, components should be built on reusable, headless behavioural primitives, independently of their default visual implementations.
These could expose functionality such as:
- Component state machines and interaction state.
- Keyboard navigation and focus management.
- Accessibility roles, properties and actions.
- Selection, filtering and search behaviour.
- Dragging, reordering and interaction lifecycle management.
- Overlay positioning, dismissal and focus restoration.
- Validation and editing behaviour.
- Animation and transition state.
The existing styled Rune Kit components would consume these primitives, while applications could also use them to construct entirely different presentations.
For example, an application should be able to create a substantially different dropdown without independently implementing keyboard navigation, focus management, accessibility and selection behaviour.
Radix UI, React Aria and Base UI are useful references for this separation.
2. Expose reusable component utilities publicly
Where Rune Kit components rely on helpers that could reasonably be useful to downstream component authors, those helpers should be accessible through public APIs.
This includes:
- Styling and visual-state utilities.
- Theme token resolution.
- Focus rings, disabled states and interaction feedback.
- Layout, sizing and positioning helpers.
- Selection and navigation utilities.
- Reusable animation definitions.
- Component state accessors and configuration types.
- Shared event handling and callback abstractions.
Ideally, copying a component's implementation into an application should not require recursively copying unrelated private dependencies.
For example, Button and IconButton currently share internal helpers such as Skin, skin and paint in controls/actions.rs. Exposing suitable reusable styling abstractions would make it easier to construct custom button variants while preserving existing theme and interaction behaviour.
This does not necessarily mean making every implementation detail public. Internal invariants and implementation-specific machinery can remain private. The goal is to expose meaningful, reusable abstractions rather than requiring downstream developers to duplicate them.
3. Support structural customisation and composition
Theme tokens are useful for changing visual properties, but some customisations require changing the structure of a component.
Where appropriate, components should provide mechanisms for:
- Replacing individual visual elements or component parts.
- Supplying arbitrary
Elcontent. - Decorating existing elements without losing their behaviour.
- Overriding rendering through callbacks or builders.
- Accessing relevant internal state through public getters or handles.
- Composing existing behavioural primitives in new ways.
- Supporting component-owned state without unnecessarily requiring knowledge of the application's root state type.
For example, an application might want to replace a dropdown's trigger, customise how its options are rendered, or place its list inside a different overlay while retaining the underlying selection behaviour.
The objective is not to add a builder option for every conceivable customisation, but to provide sufficiently flexible composition primitives.
Existing precedents
Several previous issues appear to originate from this broader architectural limitation:
-
rune-kit
Table: reusable column sizing, column reorder and visibility, fit to content, and a header over app rows #1389 — Reusable table column management: An application wanted to reuse Rune Kit's table headers, column sizing and ordering while providing its own rows and selection model. Private sizing and header-building helpers prevented this. -
rune-kit
MenuandPopupList: submenus have no keys or hover-open, items are keyed by position, names can't differ from the drawn text, and list items take no rich label #1387 — Menu and PopupList customisation:PopupListCore::build_listwas private, preventing an application from reusing the existing list implementation inside its own custom popup. -
rune-kit: a zoom/pan/fit canvas for arbitrary content, not only images #720 — Generic zoom/pan canvas: Zooming and panning functionality existed within image previews, but other applications could not easily reuse it. The issue author described implementing approximately 200 lines of equivalent interaction state before the functionality was extracted into
CanvasandZoomPan. -
rune-kit
Reorderrounds the dragged row's target, clamps out-of-bounds drops, hides its drag offset, and omitsTx#1396 — Reorder customisation: Private drag state and landing logic prevented an application from implementing different drop behaviour while retaining the existing reorder functionality. The author reported approximately 400 lines of downstream reimplementation. -
rune-kit: Tree has no scroll bar, and an app can't attach one to its internal viewport #1195, rune-kit: DiffView has no scroll bars, and a scroll_xy viewport can't have both bars #1160 and rune-kit: TextArea: enable and style a scroll bar on its internal scroll viewport #908 — Scrollbar composition: Applications could not attach scrollbars to internal viewports belonging to existing components, resulting in separate requests for Tree, DiffView and TextArea.
-
rune-kit: take component metrics (button and switch sizes, field padding and radius, text style, checkbox colours) from Kit #573, rune-kit: many controls have sizes a theme cannot change #2362 and rune-kit: Make IconButton dimensions and glyph sizes themeable #2536 — Component theming: Hardcoded visual properties required individual feature requests to make existing components compatible with custom design systems.
-
Allow layout, visibility, and keyboard handlers to run without naming the app state type #1993 and Let reusable components handle presses, wheel events, and pinch gestures without naming the app state type #2487 — Reusable event handlers: Components that owned their own state still needed to know the application's root state type for certain events, making reusable component libraries harder to build.
Many of these issues have subsequently been addressed. They are referenced here as examples of recurring architectural friction, rather than requests to implement those specific features again.
Source ownership and downstream development
The developer experience provided by shadcn/ui is another useful reference.
Developers can take ownership of individual components, modify them locally and continue depending on shared underlying primitives rather than maintaining a fork of the entire UI framework.
A similar approach in Rune Kit would be particularly valuable for AI-assisted development. An agent could inspect an existing component, adapt its implementation to an application's needs, and reuse the existing behaviour, accessibility, styling and interaction utilities.
This would also make it easier for third-party component libraries and design systems to develop independently of Rune Kit.
API stability and implementation scope
I understand that exposing additional APIs creates maintenance and compatibility obligations.
If useful, less mature extension APIs could be explicitly documented as experimental or unstable until their abstractions settle.
I'm not suggesting that every existing component needs to be immediately refactored, or that every private function should become public.
An incremental approach could establish these principles for new components and extract reusable functionality from existing components as they are developed or revisited.
The exact crate structure, API design and initial implementation scope are decisions I would leave to the maintainers.
Desired outcome
An application developer should be able to:
- Use an existing Rune Kit component unchanged.
- Customise it through theme tokens and configuration.
- Replace or compose individual parts while retaining existing behaviour.
- Copy its implementation into their own crate and modify it without recursively duplicating unrelated private dependencies.
- Build entirely new components using the same underlying behavioural and styling primitives.
A useful demonstration would be an external crate implementing a significantly customised dropdown or table while reusing Rune Kit's existing interaction logic, accessibility and theme utilities, without requiring a fork.
The broader goal is to make Rune Kit an extensible foundation for building component libraries, rather than only a collection of configurable, prebuilt components.
Would this align with Rune Kit's intended long-term architectural direction?
References
- https://ui.shadcn.com/
- https://www.radix-ui.com/primitives
- https://react-aria.adobe.com/
- https://base-ui.com/
Activity
opencodejr commentedon Nov 27, 2026
some of this direction has already landed piecemeal on
dev:rune-kitalready exposes state machines (ComboboxState,ToastStackState,LineSelection,TableState,TreeModel,PaneState,Reorder,ZoomPan), overlay/layout pieces (popover::{anchored, raised, fit_scroll, anchor_rect},scrim/scrim_tx,PopupList::build_list,Table::header,TableColumn::size_el),search::Fold,Kit::{interactive, elevate, alpha, on, selection}, andrune's state-independentEl::*_anyhandlers (#1993, #2487).the gap is still real for copy-and-modify and custom controls: shared internals like
Kit's visual-state/focus/disabled helpers (surface_state,hover_surface,overlay_state,focus_ring,focus_ring_state,disabled_dimincrates/rune-kit/src/tokens/kit.rs),list_nav(NavStep,NavAction,NavPolicy,TypeAhead,type_select),grip::Grip,Acts,over/press_over, andcontrols/actions.rs'sSkin/skin/paintarepub(crate)or private, and most controls (Select,Menu,Dialog,Checkbox,Switch,Slider, etc.) couple keyboard/a11y behaviour directly to their styled builders.two architectural questions before deciding scope or exposing new APIs:
rune-kitcommit to headless behavioural primitives plus public component-authoring utilities as an ongoing direction—and if so, should those live as modules insiderune-kit(for exampleprimitives/style/nav) or in a separate headless crate underneathrune-kit?Kitstate/focus/dim helpers,list_nav,grip, button surface helpers) or extract one headless control (such asSelect/Menu/Combobox) to establish the pattern?Vricken commentedon Nov 27, 2026
Thanks for the detailed assessment.
Direction and layout: Yes, I'd strongly favour headless behavioural primitives and public component-authoring utilities as an ongoing architectural direction. I don't have a strong preference regarding whether these live within
rune-kitor in a separate crate, and would leave that decision to the maintainers.Public surface and first slice: From a downstream developer's perspective, exposing the existing shared utilities would already provide considerable immediate value, particularly for copying and adapting existing components. Separating behaviour from presentation would also be valuable in the longer term.
However, I think the appropriate public API surface, implementation order and compatibility commitments are ultimately decisions best made by the maintainers.
My main interest is establishing extensibility and composability as ongoing design principles, so developers can build upon and adapt Rune Kit without needing to fork it or request upstream changes for every customisation.
opencodejr commentedon Nov 27, 2026
that priority order is clear: exposing the already-shared internal utilities first (
Kitvisual-state/focus/disabled helpers,list_nav,grip, button surface helpers) unlocks copy-and-adapt downstream work immediately, with headless behavioural primitives following incrementally.leaving this under
needs-designfor a maintainer call on the long-term direction, crate/module layout, and public api surface.Vricken commentedon Dec 2, 2026
@Hona Sorry for the ping, and thank you for implementing the animation sampling and date-time field requests!
I wanted to highlight this particular issue because, of all my outstanding requests, I consider it the most important for Rune's long-term extensibility.
Separating component behaviour from presentation and exposing shared component-authoring utilities would allow developers to build, adapt and extend components independently, without relying on upstream changes for every customisation or maintaining their own forks.
I also think this would significantly benefit the broader Rune ecosystem by enabling third-party component libraries and custom design systems, while potentially reducing the number of feature requests maintainers need to handle themselves.
As someone seriously considering migrating an existing desktop application to Rune, this architectural direction would be a significant factor in that decision.
I'd really appreciate your thoughts on this proposal. No pressure, of course, and thanks again for all the work going into Rune!
Hona commentedon Dec 2, 2026
Shipped in #3208 (
1dcbb2c30) ondev.Design decision: Added an additive
rune_kit::headlessmodule alongside public re-exports ofrune-kit's shared component-authoring utilities so downstream apps and custom design systems can reuse keyboard navigation, WAI-ARIA roles/states, focus management, disclosure state machines, and floating placement without adoptingrune-kit's default visual chrome—while keeping existing styled components 100% source- and behavior-compatible:rune_kit::headless):Button,Toggle,Switch,Checkbox,Disclosure(+DisclosureState),Listbox,Menu,Tabs(Automatic & Manual activation), andPopoverwrapping caller-suppliedElvisuals with zero default styling.RovingFocus/ListNav,FloatingPlacement,Dismiss(outside_dismiss,escape_dismiss,modal_dismissand*_txvariants), plus newly publiclist_nav,Grip,Acts,ButtonSkin,over,press_over,Placement::{split, from_parts, opposite_side}, andKitvisual-state/focus/disabled/motion helpers.Verified locally (Windows headless runtime):
cargo test -j 1 -p rune-kit --lib headless(10/10 passed),list_nav(7/7),grip(3/3),popover::tests(7/7)cargo check -j 1 -p rune-kit --all-featuresandcargo check -j 1 -p rune-kit --target wasm32-unknown-unknownscripts/file-size.sh(0 errors, 0 folder-shape issues)Not tested on real hardware: Interactive GUI windows, real macOS/Linux/Wayland/browser screen readers (VoiceOver/Orca/NVDA/DOM mirror), and GPU presentation were not run locally; please reopen if any edge case surfaces on real platforms.