Theme system for Maz-UI with TypeScript support and CSS variables
npm install @maz-ui/themesHigh-performance and typed theme system for Maz-UI.
- 🎨 HSL CSS Variables - Uses HSL CSS variables for maximum flexibility
- 🌓 Automatic dark mode - Native dark mode support with prefers-color-scheme
- 🚀 Automatic generation - Automatically generates color variants (50-950)
- ⚡ Flexible strategies - Runtime, build-time or hybrid
- 🛡️ Strict TypeScript - Complete types for optimal DX
- 🎯 Zero FOUC - Critical CSS injected inline
- 🔧 Configurable presets - Ready-to-use and customizable presets
``bash`
npm install @maz-ui/themes
`typescript
// main.ts
import { MazUiTheme } from '@maz-ui/themes/plugin'
import { mazUi } from '@maz-ui/themes/presets/mazUi'
import { createApp } from 'vue'
const app = createApp(App)
app.use(MazUiTheme, {
preset: mazUi,
strategy: 'hybrid',
darkModeStrategy: 'class'
})
`
`vue
class="maz-bg-primary maz-text-primary-foreground maz-rounded-[var(--radius)]"
@click="toggleDarkMode"
>
Toggle Dark Mode
`
`typescript`
import { mazUi } from '@maz-ui/themes/presets/mazUi'
`typescript`
import { pristine } from '@maz-ui/themes/presets/pristine'
`typescript`
import { ocean } from '@maz-ui/themes/presets/ocean'
`typescript`
import { obsidian } from '@maz-ui/themes/presets/obsidian'
`typescript
import { definePreset, mazUi } from '@maz-ui/themes'
const myPreset = definePreset({
base: mazUi,
overrides: {
name: 'my-theme',
radius: '0.75rem',
colors: {
light: {
primary: '220 100% 50%',
secondary: '210 40% 96%'
},
dark: {
primary: '220 100% 70%',
secondary: '210 40% 15%'
}
}
}
})
`
`typescript
import { useTheme } from '@maz-ui/themes'
const {
preset, // ComputedRef
presetName, // ComputedRef
colorMode, // Ref<'light' | 'dark' | 'auto'>
isDark, // ComputedRef
strategy, // ComputedRef<'runtime' | 'build' | 'hybrid'>
updateTheme, // (preset: ThemePreset | ThemePresetName | ThemePresetOverrides) => void
setColorMode, // (mode: 'light' | 'dark' | 'auto') => void
toggleDarkMode, // () => void
} = useTheme()
`
CSS generated and injected dynamically on the client side.
CSS generated at build-time and included in the bundle.
Critical CSS injected inline, complete CSS loaded asynchronously.
The system automatically generates:
- Base color variables: --primary, --secondary, etc.--primary-50
- Color scales: to --primary-950--radius
- Design variables: , --font-family.dark
- Dark mode support via or @media (prefers-color-scheme: dark)
`typescript
import { buildThemeCSS, generateThemeBundle } from '@maz-ui/themes'
// CSS for a preset
const css = buildThemeCSS({
preset: myPreset,
darkModeStrategy: 'class',
critical: true
})
// Bundle for multiple presets
const bundle = generateThemeBundle([mazUi, darkPreset], {
darkModeStrategy: 'class'
})
``