Repository navigation
Description
Decided with the user after reviewing M4b (#17). This is its own PR, after M4b merges and before M5.
Why
bullseye::style mixes design-system content into core. Core widgets read shadcn data back out:
- the
TextEdit/ComboBoxsize estimates use the preset'sinput_padding, stored in the context; - the switch reads the preset's colours;
- button variants are styled by
Shadcn::style_button.
The dependency should run the other way: core defines what its widgets need, and presets provide it.
Goals (from the user)
- The style can be truly customised. An app can replace or adjust every value core widgets draw with, without forking a preset.
- Other design systems can be added later without changing core. A future Fluent 2 or Material 3 preset would be a new crate that fills the contract;
bullseyeitself would not change.
No second preset now: only shadcn is implemented. But the contract is reviewed against the axes where Fluent 2 and Material 3 differ from shadcn, so it doesn't close the door on them. It doesn't have to implement them. For each axis, the contract either supports it or the PR explains how a future preset would express it without a core change:
- Button variants: core must not own a closed, shadcn-named enum. The style decides which variants exist; for example, a variant key maps to a palette. shadcn's five become the preset's own names. (Material has filled/tonal/outlined/text/elevated; Fluent has primary/secondary/outline/subtle/transparent.)
- Per-state colours: the palette holds explicit colours for each state (rest, hover, pressed, selected, disabled), not a base colour plus an alpha rule. shadcn's alpha steps are computed by the preset when it fills the contract.
- Control sizes: metrics are per size (e.g. small/medium/large), not one global height, even if shadcn fills only one size at first.
- Focus indicator: described by the style (rings or strokes, widths, colours, offsets), not hard-coded as one ring.
- Input appearance: a border and focus treatment the style chooses, which can express an underline-only input.
- Switch: separate off and on drawing parameters (fill or outline, thumb size per state), not just colours.
Anything here that needs speculative machinery today is left out and noted in the PR instead.
Design (decided with the user, 2026-11-08)
bullseye::Style enumerates every widget's look, and bullseye applies it per widget.
-
One struct in core named
bullseye::Style(decided) lists, for each widget kind bullseye draws or hosts, all of its colours, strokes, radii and metrics, per state:- widget kinds: button (with style-defined variants), toggle/selectable, checkbox, radio, switch, slider (track, range, thumb), text input, select/combo, drag value, segmented, focus indicator;
- states: rest, hover, pressed, focused, selected, disabled.
It's plain data. Every field is public and has a neutral default, so an app can construct it, edit it, or take a preset's version and change parts of it.
-
Applied per widget, scoped to that widget's node
Ui. Before egui draws a stock widget, bullseye writes that widget's entries into the nodeUi's egui visuals and spacing:WidgetVisualsfor inactive/hovered/active/open,selection,handle_shape, padding,interact_sizeand so on. egui's globalVisualsno longer decide how bullseye widgets look, and two widgets that egui would colour from the same global slot (a selected button and a text selection, a slider thumb and a button fill) can differ.- The conversion from
bullseye::Styleto egui visuals for each widget kind is written once, in core. - bullseye's own primitives (switch, segmented) read the struct directly.
- The conversion from
-
One source for size and look. Metrics live in the struct (button padding, input padding, control heights per size, thumb diameter, …), and the size estimates read the same values that are written into the widget's
Ui. Estimate and drawing can't drift apart, and the drift guards test against the struct. -
Stored in the egui context (with a
Builder/ctxaccessor), so it can change per frame (light and dark) and per subtree if ever needed. -
Presets only construct it.
bullseye-shadcnbuilds abullseye::Stylefrom shadcn's tokens and parameters (theme colour, light or dark, radius, …). A future Fluent or Material preset would build the same struct from its own parameters, with no change to core. Presets may also offer to write matching egui global visuals, for egui widgets an app draws outside bullseye trees; core doesn't require it. -
Items 22 and 23 of M4b review follow-ups: preset gaps, accent colour, semantic tokens #18 (slider thumb, toggle look, both scoped to the widget's
Ui) are the first instances of this pattern. M4c generalises them into the struct.
Owned versus wrapped widgets (decided: spike first)
Simple controls are mostly paint. bullseye's node system (sense, variants, focus, transitions, inert) already draws that well. Text input is mostly behaviour (IME, selection, clipboard, undo), which egui does well. Planned split:
- Owned (built from bullseye nodes, styled straight from
bullseye::Style, measured by taffy, so no size estimates): button (with variants), toggle/selectable, checkbox, radio, switch, slider, segmented, and the select trigger. After M6, the select's popup list as a bullseye overlay. - Wrapped egui, with the scoped
Stylemapping and size estimates:TextEditonly, plus the select popup until M6. - Dropped from the supported set:
DragValue. It is an egui-ism with no web or shadcn equivalent, and it can still go in a leaf with the generic mapping.signup_form's Age moves to a text field or slider. - Owned widgets set their accessibility role and label themselves (
widget_infoon the node response) and keep kittest's accessibility check passing. Keyboard: Space/Enter through focus; arrow keys inside a radio group.
Spike before committing to it. Rebuild Button (all variants plus the toggle) and Checkbox as bullseye-owned widgets next to the wrapped versions, and compare:
- styling fidelity against shadcn (disabled colours, focus ring);
- accessibility (kittest's check);
- keyboard behaviour;
- lines of code.
The user is concerned about bullseye's size, so the spike reports LOC before and after for src/ (code only, without tests, docs or blank lines), per module. If the spike shows owning costs more code than it removes, the split gets revisited.
shadcn's eight styles (decided with the user, 2026-11-08)
shadcn ships eight styles (apps/v4/registry/styles/style-{vega,nova,maia,lyra,mira,luma,rhea,sera}.css). They share the same ~440 component rules and the same colour tokens; colour is a separate choice. They differ in a handful of parameters:
- a radius scale (
rounded-nonetorounded-4xl); - control height and padding (button h-7 to h-10);
- text size (xs or sm);
- font weight (medium; sera uses semibold);
- focus-ring width (1 to 3 px);
- shadow level;
- a few per-component quirks (sera's square switch, pill inputs in maia and luma).
The point, in the user's words: we must be able to handle style changes smoothly at the contract to the bullseye layer. A shadcn style is a parameter set that fills bullseye::Style; changing style is changing data, with no core change and no per-style widget code.
- In M4c: our current preset is shadcn's vega, which matches what we built from new-york (h-9, rounded-md, 3 px ring, shadow-xs). Name it that. Add lyra (square, compact, xs text, 1 px ring), the most different, as the contract test. Both go through the same
bullseye::Styleconstructor. - Every example should switch between vega and lyra with no layout code changes, and the size drift guards (for wrapped
TextEdit) pass under both. - Post-0.1: the other six styles, by hand or generated by an
xtaskthat reads the CSS (Twspeaks Tailwind; watch for selectors likehas-data-[…]). - Known blockers for exact fidelity: font weights (Font weights (font-medium / font-semibold) have no faces; headings fall back to Regular #13), negative-spread shadows (Shadows with negative spread (Tailwind shadow-md/-lg/-xl) can't be expressed #12), and focus-ring width on wrapped
TextEdit.
Press feedback (found by the user)
shadcn's current styles (vega, nova, maia, lyra, mira, luma, rhea, sera in apps/v4/registry/styles/style-*.css) give buttons active:not-aria-[haspopup]:translate-y-px with transition-all: while pressed, the button shifts down 1 px, easing in and out. Buttons that open a popup are excluded, and nothing scales. new-york-v4, which our tokens came from, doesn't have it. Plan:
- Add a paint-only translate to
Paint(e.g.p.translate_y(1.0)), usable in variants. Like CSS transforms, it moves the node's and its subtree's painting, not its layout or its hit rect, and it animates withtransition. Implement it by offsetting the shapes the subtree emits. - Owned buttons use
active(|p| p.translate_y(1.0)), except buttons marked as opening a popup (select trigger, menu buttons). - Tests: the pressed button's shapes are 1 pt lower, layout rects are unchanged, and the press eases in and out with a transition.
- Also check which shadcn style the preset should track. The site has moved from new-york to these styles, so recheck the token values and radii against the style the user prefers when the preset moves crates.
Size (lines of code)
At M4b head, src/ is 7,660 lines in total, or about 4,700 lines of code without unit tests, comments or blanks. It was 6,252 total at v0.1.0-m4. The largest modules:
| Module | Lines | Notes |
|---|---|---|
style.rs |
989 | Moves to bullseye-shadcn in M4c |
widget.rs + sizing.rs |
about 1,030 | Stock-widget wrapping and size estimates; owning simple widgets should shrink these to TextEdit only |
tw/layout.rs |
766 | |
draw.rs |
757 |
M4c reports core's LOC before and after in its PR. A cargo xtask loc target (code lines per module, tests and docs excluded) makes this repeatable, and each milestone PR quotes it.
Risks to handle (reviewed with the user)
- Popups.
ComboBoxlists, tooltips and menus open in separate eguiAreas and may take the context's global style rather than the opening widget's scoped style. Verify first. If so, either the preset also writes matching global egui visuals, or bullseye styles popup content itself (M6 overlays). - Bounded by egui. Stock widgets are painted from egui's fixed
WidgetVisualsslots (five states; fill, weak fill, border, foreground stroke, radius, expansion). Disabled is an opacity multiply, focus exists only on text edits, and checkmark and rail geometry are hard-coded. EachStylefield documents whether it is exact or approximated on stock widgets. Where exact control is needed, bullseye draws the widget itself, as with the switch. - egui widgets bullseye doesn't know. Every node
Uigets a generic mapping fromStyle, soui.add(..)of an arbitrary egui widget inside a bullseye tree still matches. The preset may optionally write egui's global visuals for egui drawn outside bullseye. - Struct growth.
Styleis nested per widget (style.button,style.slider.thumb, …) and#[non_exhaustive]withDefault, so new fields don't break presets or apps. - Costs. There is a copy-on-write
Styleclone per widgetUi(check it in the M8 virtual-list benchmark). OneStyleper context; a scoped per-subtree override can come later if needed.
Plan
-
Style contract in core. A struct (working name
WidgetStyle) kept in the egui context, holding exactly the knobs core widgets read today that egui'sVisuals/Spacingdon't already cover:- input padding, separate from button padding;
- switch track and thumb colours per state;
- a per-variant button palette (primary, secondary, destructive, outline, ghost: fill, text, border, hover, active, disabled).
It must also include anything else found by searching core for preset reads. Core reads only this struct and egui's own style. It has a neutral default derived from egui's visuals, so core works with no preset at all.
-
New workspace crate
bullseye-shadcn. It takesTokens,Shadcn,Accent, the semantic colours,SegmentedClasses, and the eguiVisuals/Spacingmapping. It fills the contract. It depends onbullseyeandegui;bullseyedoesn't depend on it. -
Tests.
- Core's size drift guards run against the contract, using the default style and a deliberately unusual test style.
bullseye-shadcnruns the same guards under light and dark, with an accent.- Preset tests move with the preset.
-
Examples depend on both crates, unchanged in look: goldens must not change, and any that do get explained.
-
Docs. Core's crate guide documents the contract as the way to theme widgets, and the preset crate documents shadcn usage. The reference shell can provide its own style.
Done when
- core has no shadcn names or values;
- every example looks the same as at the M4b tag;
cargo xtask cicovers both crates, including the publish-readiness checks the user wants before crates.io.
Activity
samitbasu commentedon Nov 8, 2026
Decided by the user after the spike (#38): the full owned split.
TextEditonly.Delivery in two PRs:
M4c-1, on the
m4c-spikebranch (M4c-1: bullseye::Style contract, owned widgets, paint translate, selectable text #38):bullseye::Stylecontract, with open variant keys, per-state colours, per-size metrics, caching, and nothing panicking on an unknown key;TextEdit;The shadcn preset stays in core temporarily, filling the contract.
M4c-2:
bullseye-shadcncrate (preset,Accentrenamed toThemeColor, vega and lyra);TextEditscoped mapping;Core Style contract, paint translate and the owned widget set (#19)
Regenerate goldens for the owned widget set (#19)
Owned slider, select trigger and stepper (#19, #22)
Radio group as one Tab stop; switch track eases and thumb stays put (#19
Gallery and signup form use the new owned widgets; regenerate goldens (…
Remove the wrapped egui widgets; examples and tests use the owned set (…
Fold the owned controls' shared wiring into helpers; drop the dead Li…
Round the slider range and make disabled colours opaque blends (#19, #40
Split the gallery's owned controls into sections; document the CSS di…
Stepper: one bordered group so the focus ring no longer overlaps the …
controls_gallery: one-row Section control, cell controls only for the…
Pair-level layout: on/off looks can no longer differ in size (#19)
Ease transitions along Tailwind's timing functions (#19)
Time-based transitions with CSS reversal semantics
Switch transition tests: drive by real click at 16ms frames
samitbasu commentedon Nov 14, 2026
Done in #38 (Style contract, owned widgets, translate) and #45 (eggshell-ui-shadcn with Vega and Lyra). The other six styles are tracked in #26.