dioxus-theme-core
Serializable custom theme configuration for no-reload Dioxus theme switching.
This crate is part of the Dioxus SSR package workspace. The APIs are pre-1.0 and may change between releases while the package family stabilizes.
Install
[]
= "0.1.0-alpha.1"
What It Provides
- Theme registries with overrideable defaults.
- Serializable theme tokens for SSR and lazy runtimes.
- Animation, storage, target, and reduced-motion policy configuration.
- Built-in animation presets:
fade,cross-fade,slide,radial-wipe, andmasked-wave. - Validation for route-safe selectors, storage keys, registered defaults, and CSS token values.
- Token-name constants such as
THEME_TOKEN_BG,THEME_TOKEN_FG, andTHEME_TOKEN_ACCENT.
Example
use ;
let brand = new
.with_token;
let config = default
.with_registry
.with_default_theme
.with_animation_preset
.with_animation_speed
.with_animation_storage_key
.with_animation_speed_storage_key;
let report = config.validate;
assert!;
Animation Timing
ThemeAnimationMode controls capability and fallback behavior:
ViewTransition: use the View Transition API when available.CssOnly: use CSS variable transitions only.None: apply changes immediately.
ThemeAnimationPreset controls the visual preset independently, and animation_speed is a percentage from 25 to 300. The default easing is ease-in-out; call with_easing("linear") or another easing string to override it.
Theme View Transitions isolate route-level view-transition-name elements by default so package theme switches animate the root snapshot without reordering named route content. Call with_view_transition_name_isolation(false) only when child named View Transition elements should participate in theme switches.
ViewTX Interop
Enable the optional viewtx feature to copy timing and reduced-motion policy from dioxus-viewtx-core:
= { = "0.1.0-alpha.1", = ["viewtx"] }
let theme_config = default.with_viewtx_timing;
License
Licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
Repository: https://github.com/Collin-Budrick/dioxus_template