Skip to content

Extras: write their look as Defaults-layer sheet rules through an extension hook #494

Not planned

Description

@samitbasu

Follow-up to #482.

#482 moved every core widget's look into the style sheet. When the style is built, core writes each widget's plain-egui look once as Defaults-layer rules (the XDefaults writers). The shadcn preset's generated sheets then replace those rules, and App rules come last. The style structs keep only what the sheet doesn't cover (text roles, gaps and so on).

Extras can't do this yet. Extension::derive only gets &Style, and there is no hook into Style::from_egui. So each extra still builds its look from its public style struct every time it is drawn, and passes it to part_over(part, keys, Defaults(own), call_site). That works like a Defaults rule for that one node, but the look lives in two places: the struct and the sheet. App rules and the sheet inspector don't see an extra's defaults as rules.

Proposal

Add a core hook through which an extension writes its Defaults-layer rules once, as core's XDefaults do. For example, Extension::write_defaults(&mut Sheet, &Tokens), called from Style::from_egui (and again on a theme or preset change), before the Preset layer.

Then move the extras' looks out of their structs:

  • Scope: 19 public style structs across 11 extras, about 150 fields. The largest are FormStyle (17), NotifyStyle (15 + 6 + 8), MarkdownStyle (13 + nested), Dialog, Badge and Disclosure (about 10 each).
  • Struct fields: look fields leave the structs. Behaviour and layout fields stay.
  • Defaults: each extra writes its plain-egui look through the hook.
  • Dead preset writes: delete them. These are writes to parts the generated sheets already replace.
  • Live preset writes: turn them into Preset-layer rules on the extra's parts. These are writes to parts no generated sheet covers: markdown, disclosure's own parts, some notify and form parts.

Design questions for the hook

  • When it runs, and in what order relative to core's defaults and other extensions.
  • Whether it runs again on a theme, preset or spacing change.
  • Whether one extension can read or override another's rules, or only its own parts.
  • Whether third-party extensions get the hook too. That would be public API.

Guard

  • Every golden is unchanged.
  • A before/after dump of each extras style (Vega and Lyra, light and dark) is identical.
  • Mutation checks on the moved rules.

Breaking: the look fields come off the extras' public style structs.

Activity

  1. samitbasu commented on Nov 24, 2026

    @samitbasu
    OwnerAuthor

    Superseded by the shadcn-only decision (#496). The extras' no-preset looks are deleted rather than moved into Defaults-layer rules, so the install hook isn't needed. The local branch's useful pieces (the badge's chip code losing its hand-made look, the preset_dump/compare cuts) are carried into the removal epic.

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