Overview
ScopedTheme lets you apply a theme to a specific subtree without changing the global app theme. This is useful for previews, isolated surfaces (cards, modals, panels), and mixed-theme layouts where multiple themes need to exist on screen at the same time.
The nearest ScopedTheme wins, so nested scopes work naturally.
ScopedTheme is a runtime theme boundary. Components, hooks, and withUniwind wrapped components inside the boundary resolve styles against the scoped theme.Usage
Basic Example
Common Patterns
Side-by-Side Theme Previews
Nested Scoped Themes
Hooks and withUniwind in a Scoped Theme
Hooks and HOCs resolve against the closest ScopedTheme boundary.
useUniwind()returns the scoped theme nameuseResolveClassNames()resolves class names using scoped theme variablesuseCSSVariable()reads CSS variables from the scoped themewithUniwind()mappings use values resolved from the scoped theme
Example
API Reference
Component Signature
Props
Theme name to apply to this subtree. The theme must exist in your configured Uniwind theme definitions (for example,
light, dark, or a custom theme like coffee).React children rendered inside the scoped theme boundary.
Behavior Notes
ScopedThemeaffects only its descendants- It does not change the global app theme
- Nested scopes override parent scopes for their own subtree
- Multiple scopes can render side by side on the same screen
Related
Theming Basics
Learn how to set up themes in Uniwind
Custom Themes
Define custom themes like
coffeeuseUniwind
Read the current theme and adaptive theme state
useCSSVariable
Read theme variables directly in JavaScript
useResolveClassNames
Resolve class names into style objects at runtime
withUniwind
Add className support to third-party components