import { createThemeBuilder } from '@tamagui/theme-builder'
import { createTokens } from '@tamagui/core'
// 1. Define palettes
const palettes = {
light: ['#fff', '#fafafa', '#f5f5f5', '#e5e5e5', '#d4d4d4', '#a3a3a3', '#737373', '#525252', '#404040', '#262626', '#171717', '#000'],
dark: ['#000', '#171717', '#262626', '#404040', '#525252', '#737373', '#a3a3a3', '#d4d4d4', '#e5e5e5', '#f5f5f5', '#fafafa', '#fff'],
blue: ['#eff6ff', '#dbeafe', '#bfdbfe', '#93c5fd', '#60a5fa', '#3b82f6', '#2563eb', '#1d4ed8', '#1e40af', '#1e3a8a', '#172554', '#0f1729'],
}
// 2. Define templates
const templates = {
base: {
background: 0,
backgroundHover: 1,
backgroundPress: 2,
backgroundFocus: 3,
borderColor: 4,
borderColorHover: 5,
borderColorPress: 6,
borderColorFocus: 7,
color: 11,
colorHover: 10,
colorPress: 11,
colorFocus: 11,
},
}
// 3. Build themes
const builder = createThemeBuilder()
.addPalettes(palettes)
.addTemplates(templates)
.addThemes({
light: { template: 'base', palette: 'light' },
dark: { template: 'base', palette: 'dark' },
})
.addChildThemes({
blue: { template: 'base', palette: 'blue' },
})
.getTheme(({ theme, scheme }) => ({
...theme,
// Add custom properties
shadowColor: scheme === 'light' ? 'rgba(0,0,0,0.1)' : 'rgba(0,0,0,0.5)',
}))
const themes = builder.build()
// 4. Use in config
export default createTamagui({
themes,
tokens: createTokens({
color: palettes.light,
// ...
}),
})