8.76.2 • Published 9 days ago

@zendeskgarden/react-theming v8.76.2

Weekly downloads
14,771
License
Apache-2.0
Repository
github
Last release
9 days ago

@zendeskgarden/react-theming npm version Dependency Status

The Theming package includes several utility components relating to theming and RTL capabilities in the Garden Design System.

Installation

npm install @zendeskgarden/react-theming

# Peer Dependencies - Also Required
npm install react react-dom prop-types styled-components @zendeskgarden/react-theming

Usage

The ThemeProvider component can be used to apply granular theming to Garden (and custom) components as well as providing a RTL context.

It is intended to be used at the root of an application to provide a global context for RTL.

ThemeProvider components can be nested within each other for areas that require additional, custom theming.

Theming

All themes are auto-prefixed and has access to the props provided to the component.

import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Notification } from '@zendeskgarden/react-notifications';

const theme = {
  'notification': `
    color: red;

    :hover {
      color: blue;
    }
  `
}

<ThemeProvider styles={theme}>
  <Notification>
    This notification content will have custom styling.
  </Notification>
</ThemeProvider>

RTL

import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Notification } from '@zendeskgarden/react-notifications';

<ThemeProvider rtl>
  <Notification>This notification content will have custom styling.</Notification>
</ThemeProvider>;

The withTheme HOC utility allows any component to interact with its ThemeProvider.

import { withTheme } from '@zendeskgarden/react-theming';

const StyledDiv = ({ theme, children }) => (
  <div style={{ direction: theme.rtl ? 'rtl' : 'ltr' }}>{children}</div>
);

const LocalizedComponent = withTheme(StyledDiv);

<ThemeProvider rtl>
  <LocalizedComponent>RTL localizable</LocalizedComponent>
</ThemeProvider>;

Target

You can change the target location that style-components injects its CSS into e.g. if you're using an iframe or shadow DOM.

import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Notification } from '@zendeskgarden/react-notifications';

<ThemeProvider target={document.querySelector('.some-element')}>
  <Notification>This notification content will have custom styling.</Notification>
</ThemeProvider>;

WARNING

Theming is meant to be used for small, global changes to a component (i.e accent color, padding changes, etc.)

If you find yourself "skinning" a component, it may be much easier (and maintainable) if you were to create these presentation assets as standalone components and use them with our advanced Container abstractions.

8.76.2

9 days ago

9.0.0-next.10

9 days ago

9.0.0-next.9

16 days ago

8.76.1

23 days ago

9.0.0-next.8

29 days ago

8.76.0

29 days ago

9.0.0-next.7

1 month ago

8.75.1

1 month ago

9.0.0-next.6

1 month ago

8.75.0

1 month ago

9.0.0-next.5

2 months ago

9.0.0-next.4

2 months ago

8.74.3

2 months ago

9.0.0-next.3

2 months ago

9.0.0-next.2

3 months ago

8.74.2

3 months ago

9.0.0-next.1

3 months ago

8.74.1

3 months ago

9.0.0-next.0

3 months ago

8.74.0

4 months ago

8.73.4

5 months ago

8.69.9

9 months ago

8.69.7

9 months ago

8.69.8

9 months ago

8.69.5

10 months ago

8.69.6

9 months ago

8.72.0

7 months ago

8.73.2

6 months ago

8.73.3

6 months ago

8.73.0

7 months ago

8.73.1

7 months ago

8.69.3

10 months ago

8.69.4

10 months ago

8.69.1

11 months ago

8.69.2

10 months ago

8.70.1

8 months ago

8.70.0

8 months ago

8.71.0

8 months ago

8.69.10

8 months ago

8.69.11

8 months ago

8.68.0

11 months ago

8.69.0

11 months ago

8.67.0

1 year ago

8.64.0

1 year ago

8.65.0

1 year ago

8.66.0

1 year ago

8.57.1

2 years ago

8.57.0

2 years ago

8.53.3

2 years ago

8.53.2

2 years ago

8.53.1

2 years ago

8.53.0

2 years ago

8.49.2

2 years ago

8.49.1

2 years ago

8.60.0

2 years ago

8.58.0

2 years ago

8.54.3

2 years ago

8.54.2

2 years ago

8.54.1

2 years ago

8.54.0

2 years ago

8.50.1

2 years ago

8.50.0

2 years ago

8.61.0

1 year ago

8.59.1

2 years ago

8.59.0

2 years ago

8.55.0

2 years ago

8.51.0

2 years ago

8.62.2

1 year ago

8.62.1

1 year ago

8.62.0

1 year ago

8.49.4

2 years ago

8.49.3

2 years ago

8.56.0

2 years ago

8.52.0

2 years ago

8.63.2

1 year ago

8.63.1

1 year ago

8.63.0

1 year ago

8.49.0

2 years ago

8.45.0

2 years ago

8.46.0

2 years ago

8.47.2

2 years ago

8.47.1

2 years ago

8.47.0

2 years ago

8.48.2

2 years ago

8.48.1

2 years ago

8.48.0

2 years ago

8.44.2

2 years ago

8.44.1

3 years ago

8.44.0

3 years ago

8.43.0

3 years ago

8.42.2

3 years ago

8.42.1

3 years ago

8.42.0

3 years ago

8.41.0

3 years ago

8.40.1

3 years ago

8.40.0

3 years ago

8.39.1

3 years ago

8.39.0

3 years ago

8.38.0

3 years ago

8.36.2

3 years ago

8.37.0

3 years ago

8.37.1

3 years ago

8.36.0

3 years ago

8.36.1

3 years ago

8.35.0

3 years ago

8.34.0

3 years ago

8.33.0

3 years ago

8.32.2

3 years ago

8.32.1

3 years ago

8.32.0

3 years ago

8.31.1

3 years ago

8.31.0

3 years ago

8.30.0

3 years ago

8.29.3

3 years ago

8.29.2

3 years ago

8.29.1

3 years ago

8.29.0

3 years ago

8.28.2

3 years ago

8.28.1

3 years ago

8.28.0

3 years ago

8.27.0

3 years ago

8.26.0

3 years ago

8.25.2

4 years ago

8.25.1

4 years ago

8.25.0

4 years ago

8.24.2

4 years ago

8.24.1

4 years ago

8.24.0

4 years ago

8.23.0

4 years ago

8.23.1

4 years ago

8.22.0

4 years ago

8.21.2

4 years ago

8.21.1

4 years ago

8.21.0

4 years ago

8.20.0

4 years ago

8.19.0

4 years ago

8.18.0

4 years ago

8.17.1

4 years ago

8.17.0

4 years ago

8.16.0

4 years ago

8.15.1

4 years ago

8.15.0

4 years ago

8.14.1

4 years ago

8.14.0

4 years ago

8.13.0

4 years ago

8.12.0

4 years ago

8.11.0

4 years ago

8.10.0

4 years ago

8.9.0

4 years ago

8.8.0

4 years ago

8.7.0

4 years ago

8.6.0

4 years ago

8.5.0

4 years ago

8.4.1

4 years ago

8.4.0

4 years ago

8.3.0

4 years ago

8.2.0

4 years ago

8.1.1

4 years ago

8.0.1

4 years ago

8.0.0

4 years ago

8.0.1-next.0

4 years ago

8.0.0-next.0

4 years ago

7.1.4

4 years ago

7.0.0

5 years ago

6.5.0

5 years ago

6.2.0

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

3.2.3

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago