Skip to main content

Crate herogpui_theme

Crate herogpui_theme 

Source
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 ThemeDocument JSON under crates/herogpui-theme/themes/. They are HeroGPUI’s own palettes over v3’s light and dark bases, not HeroUI themes.

Structs§

ButtonStyle
Button recipes can combine semantic colors with a sparse GPUI root style. Instance sx is refined over this style; instance builders retain precedence.
ColorPair
A background / foreground pair, matching the two-argument builder methods.
ComponentTheme
Application-wide defaults plus named overlays for one component family.
ComponentThemes
Typed theme-owned defaults. No entry changes stock behavior until configured.
FieldColors
Form-field tokens. v3 keeps these separate from buttons so inputs can be styled independently.
LayoutTheme
Spacing, radius, border and shadow tokens shared by all components.
MenuStyle
Menu panel and row presentation; also inherited by submenus.
RoleColor
A semantic color role (accent, default, success, warning, danger).
RoleOverride
One role’s base colour and its on-colour foreground.
Roles
The five role slots ThemeBuilder::role accepts.
SelectStyle
Select trigger and detached option-panel presentation.
SliderStyle
Slider perimeter radius, including both thumb layers and edge caps.
SurfaceColor
A layered container color: surface, overlay or segment.
SurfaceLevels
--surface-secondary and --surface-tertiary.
SwitchStyle
Switch track and thumb radius.
TextFieldStyle
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.
ThemeBuilder
Builder for custom themes.
ThemeColors
All semantic tokens of one appearance.
ThemeDocument
A sparse override document for a Theme.
ThemeProvider
Holds the active theme, any registered custom themes, and the opt-in “follow the OS appearance” mode.
UnknownThemeError
The error use_theme and ThemeProvider::set_active return 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).
ComponentColor
A color resolved from the active palette, or an application-defined literal.
SkeletonAnimation
How a Skeleton animates by default (--skeleton-animation).
SoftForeground
How a role resolves --role-soft-foreground.
ThemeDocumentError
Why a document could not become a Theme.
ThemeLoadError
Why load_themes_dir or register_theme_json failed.

Constants§

THEME_SCHEMA
The JSON Schema (draft 2020-12) for a ThemeDocument file.

Traits§

ActiveTheme
Convenience extension trait giving every GPUI context access to the theme.
ComponentStyle
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 window stays open, activating the registered "light" or "dark" theme to match.
load_themes_dir
Registers every *.json file in dir (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 ThemeDocument and 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 plain gpui::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)