@zendeskgarden/react-theming package is the foundation for all Garden component styling. It provides ThemeProvider, the DEFAULT_THEME object, color scheme management, and RTL layout support.
ThemeProvider
Place a singleThemeProvider at the root of your app. Every Garden component must be rendered inside one.
ThemeProvider accepts an optional theme prop. Without it, components render using DEFAULT_THEME.
A theme object or a function that receives the parent theme and returns a modified theme. Defaults to
DEFAULT_THEME.Nested ThemeProviders
ThemeProvider can be nested to scope theme overrides to a subtree of your app:
DEFAULT_THEME
DEFAULT_THEME is a full IGardenTheme object exported from @zendeskgarden/react-theming. It defines all default values used by Garden components.
DEFAULT_THEME are:
| Key | Type | Description |
|---|---|---|
colors | object | Color hues, base (light/dark), and semantic color variables |
fonts | object | system and mono font stacks |
fontSizes | object | Named font sizes from xs (10px) to xxxl (36px) |
fontWeights | object | Named weights from thin (100) to black (900) |
lineHeights | object | Named line heights from sm (16px) to xxxl (44px) |
space | object | Spacing scale with a 4px base unit |
borders | object | sm and md border shorthand strings |
borderRadii | object | sm (2px), md (4px), lg (8px) |
borderWidths | object | sm (1px), md (3px) |
breakpoints | object | Responsive breakpoints xs through xl |
iconSizes | object | sm (12px), md (16px), lg (26px) |
shadows | object | Shadow factory functions |
shadowWidths | object | xs (1px), sm (2px), md (3px) |
opacity | object | Opacity scale from 100 (0.08) to 1200 (0.96) |
palette | object | Full color palette (grey, blue, red, yellow, green, kale, and more) |
rtl | boolean | Right-to-left layout toggle (default: false) |
components | object | Per-component CSS overrides keyed by component ID |
Customizing the theme
Garden provides three levels of customization, ordered from simple to complex.- Theme prop
- theme.components
- react-containers
Customizing via the theme prop
Pass a modified theme object toThemeProvider to adjust colors, fonts, spacing, and other design tokens across all components at once.The most common customization is changing colors.primaryHue to match your brand. primaryHue must be a key from DEFAULT_THEME.palette (e.g. 'blue', 'green', 'royal', 'azure') or a custom hue object.dangerHue, warningHue, successHue, neutralHue, and chromeHue:Customizing fonts
Overridefonts.system to use a custom typeface:Customizing spacing
The spacing scale is based on a 4pxbase unit. Increase it to make all components proportionally larger:Color scheme (light / dark / system)
ColorSchemeProvider and the useColorScheme hook let users persist a preferred color scheme. The supported values are 'light', 'dark', and 'system' (which follows the OS preference).
Setup
Wrap your app inColorSchemeProvider, then use useColorScheme inside it to read the current scheme and pass it to ThemeProvider:
ColorSchemeProvider props
Sets the initial color scheme. A user’s stored preference in
localStorage overrides this value.The
localStorage key used to persist the user’s preference. Set to null to disable persistence.useColorScheme return value
The resolved color scheme — always
'light' or 'dark', never 'system'.true when the color scheme is determined by the OS preference.Updates the active color scheme and persists it to
localStorage.Letting users switch color schemes
RTL support
Settheme.rtl = true to flip all Garden component layouts for right-to-left languages such as Arabic or Hebrew:
DEFAULT_THEME reference
colors
The active color scheme. Change this to
'dark' to enable dark mode.The primary accent color. Must be a key in
palette (e.g. 'blue', 'green', 'royal') or a custom hue object.The color hue used for destructive or error states.
The color hue used for warning states.
The color hue used for success states.
The color hue used for neutral / muted elements.
The color hue used for the Chrome navigation shell.
fonts
The system sans-serif font stack used for body text and UI labels. Defaults to
system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ....The monospace font stack. Defaults to
SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace.space
The spacing scale uses abase of 4 (pixels). All named values are multiples of base:
| Key | Value |
|---|---|
base | 4 (number) |
xxs | 4px |
xs | 8px |
sm | 12px |
md | 20px |
lg | 32px |
xl | 40px |
xxl | 48px |
fontSizes
| Key | Value |
|---|---|
xs | 10px |
sm | 12px |
md | 14px |
lg | 18px |
xl | 22px |
xxl | 26px |
xxxl | 36px |
palette
DEFAULT_THEME.palette contains the full Garden color palette. Primary hues are:
| Key | Description |
|---|---|
grey | Neutral grey (100–1200) |
blue | Primary blue (100–1200) |
red | Danger red (100–1200) |
yellow | Warning yellow (100–1200) |
green | Success green (100–1200) |
kale | Chrome teal-green (100–1200) |
fuschia, pink, crimson, orange, lemon, lime, mint, teal, azure, royal, purple.
Special values: palette.black (#000) and palette.white (#fff).
TypeScript
DEFAULT_THEME is typed as IGardenTheme, exported from @zendeskgarden/react-theming: