Overview
TheTheme.Provider component uses React Context to make the selected theme available throughout your component tree. It handles:
- Applying design tokens to components
- Managing global styles and fonts
- Supporting multiple theme variants
- Handling animations and reduced motion
- Custom breakpoints for responsive design
Basic Usage
Wrap your application with the Theme Provider to apply the default Paste theme:Available Themes
Paste provides several pre-built theme variants:Default Theme
The standard Paste theme designed for Twilio products:Dark Theme
Optimized for dark mode interfaces:Twilio Theme
Official Twilio brand theme:Twilio Dark
Dark variant of the Twilio theme:Other Themes
Props
theme
- Type:
'default' | 'dark' | 'twilio' | 'twilio-dark' | 'sendgrid' | 'evergreen' - Default:
'default'
customBreakpoints
- Type:
string[] - Default:
['400px', '1024px', '1280px']
disableAnimations
- Type:
boolean - Default:
false
- Visual regression testing
- Performance optimization
- Accessibility preferences
prefers-reduced-motion setting.
cacheProviderProps
- Type:
CreateCacheOptions
style
- Type:
React.CSSProperties
Using CSS Variables
For maximum flexibility, you can use CSS variables instead of static values:Accessing the Theme
Use theuseTheme hook to access theme values in your components:
Multiple Theme Providers
You can nest Theme Providers to apply different themes to sections of your app:Best Practices
- Place at the root: Wrap your entire application with Theme Provider at the highest level possible
- Single provider: Use one provider per application unless you need multiple themes
- Avoid recreating: Don’t create new Theme Provider instances on every render
- Use hooks: Prefer
useThemehook over Theme Consumer for accessing theme values
Common Patterns
Theme Switching
Implement a theme toggle:Respecting User Preferences
Next Steps
- Learn about CustomizationProvider for advanced theme customization
- Explore Design Tokens to understand the theming system
- Create Custom Themes for your brand