Customize themes, density modes, and text directions through data attributes.
Theme Switching
Switch between themes using the data-theme attribute:
Using ThemeProvider
For React applications, persist theme choice (e.g. localStorage) and set data-theme on the root element. This portal includes a simple implementation:
1234567891011121314151617181920
Density Modes
Control the spacing and sizing of components:
Density Effects
- Compact: 75% spacing, smaller fonts - perfect for data tables and dashboards
- Normal: Standard spacing - default for most interfaces
- Comfortable: 125% spacing, larger fonts - ideal for touch devices and accessibility
RTL (Right-to-Left) Support
Enable RTL mode for languages like Arabic, Hebrew, and Urdu:
Using Logical Properties
Components automatically adapt to RTL when using logical properties:
Combined Usage
You can combine multiple attributes:
Motion Modes
Disable motion with data-motion="reduced" (tokens also respect prefers-reduced-motion by default):
Best Practices
- Theme: Set at the root level for consistent theming across the app
- Density: Can be set per-page or per-section for different contexts
- Direction: Should match the primary language of your content
- Logical Properties: Always use logical properties (start/end) instead of left/right