Theme API
Declared by <huxerui/theme.h>.
Theme tokens
Section titled “Theme tokens”ColorScheme: primary/secondary roles, containers, background/surface levels, on-colors, outline, inverse roles, scrim, and error.TypographyScheme: body large/medium/small, label large, title large, and headline small sizes.ShapeScheme: extra-small through extra-large plus full radius.SpacingScheme: extra-small through extra-large spacing.ElevationScheme: low, medium, and high elevation.MotionScheme: fast/normal/slow durations andreduced_motion.InteractionScheme: defaultIndication,FocusRing, and disabled opacity.ThemeSpec: aggregates all schemes and providesDefault().
Component styles
Section titled “Component styles”The component-level style structures are equality-comparable and provide Default(); TextFieldVariantStyle is an embedded value configured through TextFieldStyle:
ButtonStyle: background/label/disabled colors, padding, minimum geometry, radius, indication.IconButtonStyle: foreground, icon and interactive geometry, radius, indication.ChipStyle: normal/selected/disabled surfaces, labels, borders, icon geometry, indication.DividerStyle: color and thickness.SegmentedButtonStyle: segment surfaces, labels, borders, padding, geometry, indication.TabsStyle: labels, indicator/divider geometry, item geometry, expansion, indication, and animation duration;TabIndicatorSizingisItemorContent.TextFieldVariantStyleandTextFieldStyle: standard/filled/outlined surfaces and borders, typography, icons, selection/caret/composition, geometry, timing, and validation treatment.CheckboxStyle,RadioButtonStyle, andSwitchStyle: state colors and control geometry.ProgressCircleStyle;ProgressCircleIndeterminateMotionisSweeporPulsingArc.ProgressBarStyle;ProgressBarIndeterminateMotionisSweeporSegmented.SelectStyle,ComboBoxStyle,DatePickerStyle, andTimePickerStyle: field/popup appearance without changing controlled value contracts.TreeViewStyle: fixed row/disclosure/selection geometry;RefreshBoxStyle: pull-to-refresh appearance.SliderStyle: track, thumb, tick, disabled, focus, and animation values.
Navigation styles (TopAppBarStyle, NavigationBarStyle, NavigationPaneStyle, DrawerStyle) are declared by navigation.h; presentation styles by presentation.h.
Definitions and providers
Section titled “Definitions and providers”ThemeDefinition(ThemeSpec)andSet(EnvironmentValue)build typed overrides.UseTheme()returns the nearestThemeSpec.Theme(definition, content)provides a definition.FlatLightThemeSpec,FlatDarkThemeSpec,MaterialLightThemeSpec, andMaterialDarkThemeSpeccreate token sets.FlatThemeDefinition,FlatDarkThemeDefinition,MaterialThemeDefinition, andMaterialDarkThemeDefinitioncreate complete component definitions.FlatTheme,FlatDarkTheme,MaterialTheme, andMaterialDarkThemeaccept declarative child content; light-family overloads also accept a customThemeSpec.
Use MaterialTheme {Content()} or Theme(definition, Content()) in codegen-enabled source. Providers are ordinary View declarations; do not add a factory lambda around child content.
Complete theme and indication example
Section titled “Complete theme and indication example”#include <huxerui/huxerui.h>
using namespace huxerui;
View DestructiveAction() { Indication feedback { .hover = IndicationLayer { .fill = VisualFill(Color::Rgb(255, 255, 255, 0.10F)), .placement = IndicationPlacement::AboveContent, }, .press = IndicationLayer { .fill = VisualFill(Color::Rgb(255, 255, 255, 0.18F)), .placement = IndicationPlacement::AboveContent, }, .ripple = RippleEffect {.color = Color::Rgb(255, 255, 255, 0.24F)}, }; return Button("Delete").OnClick([] {}).With(feedback);}
View ThemedPanel() { return MaterialTheme {DestructiveAction()};}The theme supplies the normal component style; the explicit Indication replaces interaction feedback only for this node.
Reusable surface values
Section titled “Reusable surface values”Where a component style exposes a surface, use its current typed VisualFill, Border, and CornerRadii fields rather than parallel color/width/radius values from older snippets. Not every numeric corner field was replaced: indicator/thumb geometry still follows the owning control’s contract. Material and Flat also resolve SnackBarStyle alongside existing presentation styles.
Override one component style
Section titled “Override one component style”Copy the nearest style to preserve its existing theme family, change the fields you own, then provide the override to a child subtree:
#include <huxerui/huxerui.h>
using namespace huxerui;
[[huxerui::composable]]View CompactActions() { ButtonStyle button = UseEnvironment<ButtonStyle>(); button.padding = EdgeInsets::Symmetric(12.0F, 6.0F); button.minimum_height = 32.0F; ThemeDefinition overrides; overrides.Set(button); return Theme(overrides, Row { Button("Preview").OnClick([] {}), Button("Export").OnClick([] {}), }.With(Spacing(8.0F)));}ThemeDefinition() starts with no overrides. Set(value) replaces that type’s whole value and returns ThemeDefinition& for chaining; it does not merge individual struct fields. Unspecified types inherit from the surrounding environment. ThemeDefinition(spec) supplies a ThemeSpec, but does not derive a complete Material/Flat component family from changed colors by itself. Use MaterialThemeDefinition(spec) or FlatThemeDefinition(spec) when deriving a complete family.
Component pages document the fields of their corresponding Style. Numbers in those fields are logical pixels except where named as fractions or durations. Defaults in a struct declaration describe a fallback, while an installed theme definition may override them. Reading UseEnvironment<Style>() obtains the effective style at the caller, before any provider returned by that caller.
Choose the lifetime of an override
Section titled “Choose the lifetime of an override”Create a family definition at the application theme boundary. Place local overrides around related controls; they continue to participate in normal environment subscriptions. Do not retain a reference returned by UseTheme or UseEnvironment in a delayed callback: copy the small configuration value if the callback needs a snapshot.
Use component value/configuration methods for behavior and Theme for shared appearance. For example, Slider::Step changes accepted proposals while SliderStyle::tick_size only changes their marks. TextField::LineLimits enables multiline editing while a taller theme minimum height does not.

