Expand description
HeroUI design tokens and theming for GPUI.
This crate is a faithful port of HeroUI v3’s packages/styles: the semantic
OKLCH color tokens for the light and dark appearances, the layout tokens
(radius, border width, shadows), and a global ThemeProvider with an
ActiveTheme accessor trait.
Modules§
- presets
- Built-in preset themes, shipped as
ThemeDocumentJSON undercrates/herogpui-theme/themes/. They are HeroGPUI’s own palettes over v3’s light and dark bases, not HeroUI themes.
Structs§
- Button
Style - Button recipes can combine semantic colors with a sparse GPUI root style.
Instance
sxis refined over this style; instance builders retain precedence. - Color
Pair - A background / foreground pair, matching the two-argument builder methods.
- Component
Theme - Application-wide defaults plus named overlays for one component family.
- Component
Themes - Typed theme-owned defaults. No entry changes stock behavior until configured.
- Field
Colors - Form-field tokens. v3 keeps these separate from buttons so inputs can be styled independently.
- Layout
Theme - Spacing, radius, border and shadow tokens shared by all components.
- Menu
Style - Menu panel and row presentation; also inherited by submenus.
- Role
Color - A semantic color role (
accent,default,success,warning,danger). - Role
Override - One role’s base colour and its on-colour foreground.
- Roles
- The five role slots
ThemeBuilder::roleaccepts. - Select
Style - Select trigger and detached option-panel presentation.
- Slider
Style - Slider perimeter radius, including both thumb layers and edge caps.
- Surface
Color - A layered container color:
surface,overlayorsegment. - Surface
Levels --surface-secondaryand--surface-tertiary.- Switch
Style - Switch track and thumb radius.
- Text
Field Style - Shared Input/TextField/SearchField presentation. Glyph hit testing uses the same text size; the stock 20px line advance remains unchanged.
- Theme
- A complete HeroUI v3 theme: semantic colors plus layout tokens.
- Theme
Builder - Builder for custom themes.
- Theme
Colors - All semantic tokens of one appearance.
- Theme
Document - A sparse override document for a
Theme. - Theme
Provider - Holds the active theme, any registered custom themes, and the opt-in “follow the OS appearance” mode.
- Unknown
Theme Error - The error
use_themeandThemeProvider::set_activereturn for an id that no registered theme carries (ids are case-sensitive:"Dark"is not"dark").
Enums§
- Appearance
- Visual appearance of a theme (
color-scheme). - Component
Color - A color resolved from the active palette, or an application-defined literal.
- Skeleton
Animation - How a
Skeletonanimates by default (--skeleton-animation). - Soft
Foreground - How a role resolves
--role-soft-foreground. - Theme
Document Error - Why a document could not become a
Theme. - Theme
Load Error - Why
load_themes_dirorregister_theme_jsonfailed.
Constants§
- THEME_
SCHEMA - The JSON Schema (draft 2020-12) for a
ThemeDocumentfile.
Traits§
- Active
Theme - Convenience extension trait giving every GPUI context access to the theme.
- Component
Style - Sparse overlay semantics for a typed component style.
Functions§
- black
--black: oklch(0% 0 0)- eclipse
--eclipse: oklch(0.2103 0.0059 285.89)- follow_
system_ appearance - Follows the OS light/dark appearance for as long as
windowstays open, activating the registered"light"or"dark"theme to match. - load_
themes_ dir - Registers every
*.jsonfile indir(not recursive) as a theme, without activating any. Files load in name order, so the result is deterministic; the first invalid file aborts the load with its path, and the files before it stay registered. Returns the registered ids. - register_
theme_ json - Parses one JSON
ThemeDocumentand registers it without activating it. Returns the theme id. A theme with the same id is replaced. - set_
reduce_ motion - Sets the app-level reduced-motion preference — the equivalent of putting
data-reduce-motion="true"on the document element — and schedules every open window to repaint. Every animated component honours it without opt-in, and so does every plaingpui::Animation: the value is stored in GPUI’s own global, which its animation elements consult themselves. - set_
theme - Sets the global theme and schedules every open window to repaint.
- snow
--snow: oklch(0.9911 0 0)- stop_
following_ system_ appearance - Stops following the OS appearance, leaving the active theme as it is.
- toggle_
light_ dark - Switches between the light and dark defaults.
- toggle_
reduce_ motion - Flips the reduced-motion preference.
- use_
theme - Activates one of the registered themes by id (
"light","dark", custom) and schedules every open window to repaint. - white
--white: oklch(100% 0 0)