Skip to content

M4b review follow-ups: preset gaps, accent colour, semantic tokens #18

Closed

Description

@samitbasu

These came out of reviewing the before/after renders on #17. All of them are going into M4b (#1). #17 stays a draft until they land and the user approves fresh renders.

Preset gaps found by the examples

  • 1. Primary buttons. egui has no primary button variant, so Save and Submit render in the pale secondary colour, and a disabled Save is nearly invisible. Add primary() (and possibly destructive(), outline(), ghost()) to widget::Button, drawn from the tokens.
  • 2. Unchecked checkbox/radio contrast. The #e5e5e5 fill barely shows on white. Map them to shadcn's look: a background-filled box with an input-coloured border.
  • 3. Hover tokens. muted, accent and secondary are the same colour, so hover on a muted surface is invisible, and hovered and selected need different tokens. Add alpha variants such as accent/50.
  • 4. Segmented sizing. SegmentedClasses stretches across the row; shadcn uses w-fit. It also can't wrap with many options. Make it fit its content and add a wrapping variant.
  • 5. Shadow under a box with no background. It shows through inside the box, but CSS clips box-shadow to outside the border box. Clip it in the library.
  • 6. Select popup height. It scrolls after about 5 items, because rows are 36 pt and combo_height is 200. Raise the popup height in the preset.
  • 7. Selected-text / focus-border colour. egui uses one colour (selection.stroke) for both. Decision: use the foreground colour, which gives a strong focus border and readable selected text (the user picked option (b)).
  • 8. Shadcn::of(ctx). Removes the token plumbing duplicated in examples/common and chat_shell.

Colour

  • 9. Accent choice. Shadcn::light().accent(Accent::Blue) and similar use shadcn's theme colours to re-tint primary, ring and primary-foreground. Neutral stays the default.
  • 10. Semantic tokens. Add success, warning and info alongside destructive, in light and dark.
  • 11. Use them in chat_shell.
    • The accent colours the context meter, the send button, the selected-recent marker and "Running".
    • Green and red colour the +N -M change counts.
    • The forms keep neutral chrome, with an accent primary button and focus.

Renders for the user

  • chat_shell and form in light and dark, with several accent candidates side by side (neutral, blue, violet, green, plus one or two more of shadcn's theme colours), so the user can pick the example accent. Regenerate the before/after comparisons with everything above applied.

Found while reviewing the follow-ups (decisions for the user)

  • 12. Dark accents are dim. Decided: yes, dark-mode accent fills move to the brighter shade. shadcn's dark primary is the 700/800 shade, so on near-black the send button, the meter and the avatar have low contrast. chat_shell's Tok::AccentText uses the ring (500) shade for text. Should dark fills move up to a brighter shade too?

  • 13. Selection background. Decided: keep primary at 30% opacity. Selected text uses the foreground colour (item 7), so selection.bg_fill became primary at 30% alpha to keep it readable. Confirm.

  • 14. Button variants in controls_gallery. Decided: add them. Add cells showing primary, secondary, destructive, outline and ghost, enabled and disabled.

  • 15. hyperlink_color Decided: use the ring shade. is still primary, which is dim in dark with an accent. Use the ring shade?

  • 16. Example accent. Decided: Blue. The user picks one from the contact sheets.

  • 17. Examples follow the OS theme from startup, and every example has a System / Light / Dark toggle. Decided.

Found while reviewing 12–17 (decisions for the user)

  • 18. Examples with hard-coded light palettes Decided: retheme them through the tokens. (button, todo, kaolin, known_gaps) are only partly dark under the dark theme: the chrome follows, the content doesn't. Retheme them through the tokens? Their goldens would change.
  • 19. Neutral links are weak. Decided: links use primary, as shadcn's link button variant does (text-primary underline-offset-4 hover:underline). This reverses item 15, which was only needed while dark primary was dim. The ring shade is #a1a1a1 on white (about 2.6:1) and #737373 on #0a0a0a (about 4.1:1). Accent links read well.
  • 20. controls_gallery has no accent Decided: use Blue., so its Primary cells are black in light and grey in dark. Give it Blue like form?

Found by the user while trying M4b

  • 21. kaolin sidebar rows overlap. Decided: fix the examples and use the recommended pattern. No library guard: we can't prevent misuse of the layout system; the examples should model the right pattern. Each row was a fixed h_px(26.0) div_id adding a stock Button::selectable with ui.add_sized, so the library never measured it. Under the preset, egui's minimum button height (interact_size.y = 36) made each button spill over the next row. Rows become b.widget(.., Button..) sized by the library. Check every other example for hand-sized leaves holding stock widgets.
  • 22. Slider thumb. Decided: match shadcn's thumb. egui 0.37 defaults to HandleShape::Rect { aspect_ratio: 0.75 }, a rounded rect, and paints the handle with the generic widget bg_fill and fg_stroke. In dark, bg_fill is input, which is white at 15%, so the handle is translucent. shadcn's thumb is size-4 rounded-full border border-primary bg-background shadow-sm: a circle, an opaque background fill and a primary border. The track is bg-muted h-1.5 rounded-full with the range in bg-primary. Set this through the preset (handle_shape: Circle, trailing fill on) and scope the thumb's fill and stroke inside widget::Slider's own Ui, so other widgets' visuals don't change. Audit the other egui widgets that paint with bg_fill for dark-mode translucency.
  • 23. A selectable button is shadcn's Toggle. Decided. Resting is transparent, hover is bg-muted / text-muted-foreground, and selected is bg-accent / text-accent-foreground, so selected keeps the highlight background as the button's fill. Apply this to widget::Button's selectable form, with visuals scoped inside its own Ui. egui otherwise paints selected buttons with the global selection.bg_fill, which also colours text selection. Apply it to the button example's selectable demo as well. Separately, rename the Accent enum (e.g. ThemeColor) in M4c (M4c: split the shadcn preset into its own crate behind a style contract #19), because shadcn's accent token is the subtle hover background and not the theme colour.

Found while doing 19 and 21–23 (decisions for the user)

  • 24. kaolin's selected row is invisible in neutral. Decided: (a), the sidebar uses the background surface, as shadcn's sidebar block does. The selected row is shadcn Toggle accent, which in neutral is the same colour as the sidebar's muted background. Options: give the sidebar a different surface (e.g. background), or give selection a look that differs from the surface.
  • 25. Violet links in dark are 4.498:1 against the background Decided: nudge violet's dark link shade lighter so it reaches 4.5:1, and remove the test exception., just under 4.5. The test has a named exception for it. Options: nudge the colour, or accept it.
  • Note: item 22 fixes the thumb fill by editing the circle shape egui emits, because egui paints rail and thumb from the same inactive.bg_fill. Tests guard it, but it's a hack. If the slider becomes a bullseye-owned widget in M4c, the hack goes away. The rail is still egui's 8 pt; shadcn's is 6 pt.

Requested by the user while reviewing

  • 26. chat_shell details panel as a grouped form (like a macOS settings form, or shadcn's Card with divide-y). Each section (Environment, Context, Changes, Background tasks) becomes a rounded, bordered container whose rows are separated by hairlines (divide_y in border), with the label left-aligned and the value right-aligned. Built from existing classes, with no library change. HTML: <div class="rounded-lg border divide-y"><div class="flex justify-between px-3 py-2">…</div></div>.
  • 27. Some light goldens don't paint the page. controls_gallery_* and port_button (light) show black wherever the app draws nothing. The live window paints its themed panel there, so these goldens don't show what the user sees. Dark goldens already use the harness's themed Page; light goldens should as well, so every golden matches the running app. Expect those goldens to change, but only in the unpainted area.
  • Final renders for the user. Approved by the user on try-out. target/m4b-final/overview.png (not committed). The PR stays a draft until the user approves.

Activity

  1. added 19 commits that reference this issue on Nov 8, 2026
  2. samitbasu commented on Nov 8, 2026

    @samitbasu
    OwnerAuthor

    Everything here landed in #17 (merged, tagged v0.1.0-m4b). The Accent rename moves to M4c (#19).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions