
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@zendeskgarden/react-theming
Advanced tools
Theming utilities and components within the Garden Design System
The Theming package includes several utility components relating to theming and RTL capabilities in the Garden Design System.
npm install @zendeskgarden/react-theming
# Peer Dependencies - Also Required
npm install react react-dom prop-types styled-components @zendeskgarden/react-theming
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.
All themes are auto-prefixed and has access to the props
provided to the component.
import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Notification, Title, Paragraph } from '@zendeskgarden/react-notifications';
const theme = {
'notifications.title': `
&& {
color: red;
:hover {
color: blue;
}
}
`,
'notifications.paragraph': props => (props.purple ? 'color: purple' : '')
};
<ThemeProvider theme={theme}>
<Notification>
<Title>Themed Title (hover as well)</Title>
<Paragraph purple>Custom theme triggered by prop</Paragraph>
</Notification>
</ThemeProvider>;
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>;
If you need to compose from other theme overrides e.g. you find yourself overriding the same properties in several components or you're using props to alter your overrides then please see the following code example.
import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Notification, Title, Paragraph } from '@zendeskgarden/react-notifications';
import { css } from 'styled-components';
const commonOverrides = `
&&:hover {
color: blue;
}
`;
const theme = {
'notifications.title': css`
${commonOverrides} && {
color: red;
}
`,
'notifications.paragraph': css`
${commonOverrides} ${props => (props.purple ? 'color: purple' : '')};
`
};
<ThemeProvider theme={theme}>
<Notification>
<Title>Themed Title (hover as well)</Title>
<Paragraph purple>Custom theme triggered by prop</Paragraph>
</Notification>
</ThemeProvider>;
The main difference here is the usage of the css
helper
from styled-components. This will correctly pass down the props from the component so you can conditionally
apply styles based on props or compose from other template literals.
Each component has a COMPONENT_ID
applied so you can target it in your own theme
file to override the default look and feel. This table contains all the ids and which
package they apply to.
<CIDTable />
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.
FAQs
Theming utilities and components within the Garden Design System
The npm package @zendeskgarden/react-theming receives a total of 50,544 weekly downloads. As such, @zendeskgarden/react-theming popularity was classified as popular.
We found that @zendeskgarden/react-theming demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.