Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add JSDocs for the default-exported component
  • Loading branch information
ciampo committed Oct 12, 2022
commit ba1668cc327e0f19f87510bffe200f6303122145
22 changes: 22 additions & 0 deletions packages/components/src/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ import { Wrapper } from './styles';

extend( [ namesPlugin, a11yPlugin ] );

/**
* `Theme` allows defining theme variables for components in the `@wordpress/components` package.
*
* Multiple `Theme` components can be nested in order to override specific theme variables.
*
*
* @example
* ```jsx
* import { __experimentalTheme as Theme } from '@wordpress/components';
*
* const Example = () => {
* return (
* <Theme accent="red">
* <Button variant="primary">I'm red</Button>
* <Theme accent="blue">
* <Button variant="primary">I'm blue</Button>
* </Theme>
* </Theme>
* );
* };
* ```
*/
function Theme( props: WordPressComponentProps< ThemeProps, 'div', true > ) {
const { accent } = props;
if ( accent && ! colord( accent ).isValid() ) {
Expand Down