Skip to content

Commit bf390b4

Browse files
aduthnerradtyxla
authored
Theme: Fix ThemeProvider documentation for accurate color prop (#72943)
* theme: Fix ThemeProvider documentation for accurate color prop * Expand on what ThemeProvider actually does Co-authored-by: aduth <[email protected]> Co-authored-by: nerrad <[email protected]> Co-authored-by: tyxla <[email protected]>
1 parent b1caf52 commit bf390b4

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

packages/theme/README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,41 @@ The design system defines color tokens using the following naming scheme:
6363

6464
## Theme Provider
6565

66-
The `ThemeProvider` is a React component that should wrap your application to provide design tokens and theme context to the child UI components.
66+
The `ThemeProvider` is a React component that should wrap your application to provide design tokens and theme context to the child UI components. It accepts a set of customizable seed values and automatically generates a set of design tokens, which are exposed as CSS custom properties for use throughout the application.
6767

6868
```tsx
6969
import { ThemeProvider } from '@wordpress/theme';
7070

7171
function App() {
7272
return (
73-
<ThemeProvider color={ { scheme: 'light', accent: 'blue' } }>
73+
<ThemeProvider color={ { primary: 'blue' } }>
7474
{ /* Your app content */ }
7575
</ThemeProvider>
7676
);
7777
}
7878
```
7979

80+
The `color` prop accepts an object with the following optional properties:
81+
82+
- `primary`: The primary/accent seed color (default: `'#3858e9'`)
83+
- `bg`: The background seed color (default: `'#f8f8f8'`)
84+
85+
Both properties accept any valid CSS color value. The theme system automatically generates appropriate color ramps and determines light/dark mode based on these seed colors.
86+
87+
### Nesting Providers
88+
8089
The provider can be used recursively to override or modify the theme for a specific subtree.
8190

8291
```tsx
83-
<ThemeProvider>
84-
{ /* system-themed UI components */ }
85-
<ThemeProvider color={ { scheme: 'dark' } }>
92+
<ThemeProvider color={ { bg: 'white' } }>
93+
{ /* light-themed UI components */ }
94+
<ThemeProvider color={ { bg: '#1e1e1e' } }>
8695
{ /* dark-themed UI components */ }
87-
<ThemeProvider color={ { scheme: 'light' } }>
88-
{ /* light-themed UI components */ }
96+
<ThemeProvider color={ { primary: 'red' } }>
97+
{ /* dark-themed with red accent */ }
8998
</ThemeProvider>
90-
{ /* dark-themed UI components */ }
9199
</ThemeProvider>
92-
{ /* system-themed UI components */ }
100+
{ /* light-themed UI components */ }
93101
</ThemeProvider>
94102
```
95103

0 commit comments

Comments
 (0)