Customize MattersUI to match your brand and create beautiful, consistent user interfaces.
MattersUI comes with a built-in ThemeProvider component that enables light and dark mode support.
Wrap your application with the ThemeProvider:
import React from 'react';import { ThemeProvider } from 'mattersui';function App() {return (<ThemeProvider defaultMode="light"><YourApp /></ThemeProvider>);}
Access and modify the current theme using the useTheme hook:
import React from 'react';import { useTheme, Button } from 'mattersui';function ThemeToggle() {const { mode, setMode, toggleMode } = useTheme();return (<div><p>Current theme: {mode}</p><Button onClick={toggleMode}>Toggle Theme</Button><Button onClick={() => setMode('light')}>Light Mode</Button><Button onClick={() => setMode('dark')}>Dark Mode</Button></div>);}
MattersUI uses Tailwind CSS for styling. You can customize colors by extending your Tailwind configuration.
Extend your tailwind.config.js file to customize the color palette:
// tailwind.config.jsmodule.exports = {content: ['./src/**/*.{js,jsx,ts,tsx}',// Include MattersUI components'./node_modules/mattersui/**/*.js',],theme: {extend: {colors: {// Customize primary colorprimary: {50: '#f0f9ff',100: '#e0f2fe',200: '#bae6fd',300: '#7dd3fc',400: '#38bdf8',500: '#0ea5e9',600: '#0284c7',700: '#0369a1',800: '#075985',900: '#0c4a6e',},// Customize secondary colorsecondary: {50: '#f5f3ff',100: '#ede9fe',200: '#ddd6fe',300: '#c4b5fd',400: '#a78bfa',500: '#8b5cf6',600: '#7c3aed',700: '#6d28d9',800: '#5b21b6',900: '#4c1d95',},// Add other custom colors as needed},},},plugins: [],}
MattersUI components will automatically use these customized colors.
MattersUI supports dark mode out of the box. The ThemeProvider handles theme switching and persistence.
By default, MattersUI detects the user's system preference for dark/light mode. You can override this with the defaultMode prop:
<ThemeProvider defaultMode="dark">{/* Your app */}</ThemeProvider>
For custom components, use Tailwind's dark mode variant:
<div className="bg-white text-black dark:bg-slate-900 dark:text-white">This div adapts to the current theme</div>
Most MattersUI components accept a className prop for custom styling.
import { Button } from 'mattersui';// Apply custom styles<Buttonvariant="primary"className="px-8 py-3 rounded-full shadow-lg">Custom Styled Button</Button>
Your custom classes will be merged with MattersUI's default styles.
For more advanced theming needs, you can extend the MattersUI theme system.
Add custom CSS variables to your global stylesheet:
:root {--mui-border-radius: 0.375rem;--mui-font-sans: 'Inter', sans-serif;--mui-transition-duration: 150ms;}.dark {--mui-border-radius: 0.5rem;}
Then use these variables in your Tailwind configuration:
// tailwind.config.jsmodule.exports = {theme: {extend: {borderRadius: {DEFAULT: 'var(--mui-border-radius)',},fontFamily: {sans: ['var(--mui-font-sans)'],},transitionDuration: {DEFAULT: 'var(--mui-transition-duration)',},},},}