Build faster with Premium Chakra UI Components 💎
Learn moreDecember 4, 2024
By default, Chakra UI uses the gray
color palette for various UI elements like
selection backgrounds and hover states. You can customize this default behavior
by modifying the global CSS configuration.
Use the createSystem
method to override the default color palette in your
theme configuration:
components/theme.ts
const config = defineConfig({
globalCss: {
html: {
colorPalette: "blue", // Change this to any color palette you prefer
},
},
})
export const system = createSystem(defaultConfig, config)
Next, add the new system
to your components/ui/provider.tsx
file:
"use client"
import { system } from "@/components/theme"
import { ChakraProvider } from "@chakra-ui/react"
export function Provider(props: ColorModeProviderProps) {
return (
<ChakraProvider value={system}>
<ColorModeProvider {...props} />
</ChakraProvider>
)
}
Changing the default color palette will affect various UI elements across your application, including:
You can use any of the built-in color palettes or your own custom color palette:
// Built-in color palettes
colorPalette: "blue"
colorPalette: "green"
colorPalette: "red"
// Custom color palette (if defined in your theme)
colorPalette: "brand"