![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@zendeskgarden/react-theming
Advanced tools
Theming utilities and components within the Garden Design System
@zendeskgarden/react-theming is a package that provides theming capabilities for React applications. It allows developers to define and apply consistent design themes across their applications, ensuring a cohesive look and feel. The package is part of the Zendesk Garden design system, which offers a collection of React components and utilities for building user interfaces.
ThemeProvider
The ThemeProvider component is used to apply a theme to a React application. It wraps the application or specific components, providing them with access to the theme properties defined in the theme object.
import { ThemeProvider } from '@zendeskgarden/react-theming';
const App = () => (
<ThemeProvider theme={{ colors: { primaryHue: 'blue' } }}>
<YourComponent />
</ThemeProvider>
);
Theming with Styled Components
This feature demonstrates how to use styled-components with @zendeskgarden/react-theming. By using styled-components, you can create styled React components that automatically receive theme properties, allowing for dynamic styling based on the theme.
import styled from 'styled-components';
import { ThemeProvider } from '@zendeskgarden/react-theming';
const StyledButton = styled.button`
background-color: ${props => props.theme.colors.primaryHue};
`;
const App = () => (
<ThemeProvider theme={{ colors: { primaryHue: 'blue' } }}>
<StyledButton>Click me</StyledButton>
</ThemeProvider>
);
styled-components is a popular library for styling React applications using tagged template literals. It allows for CSS-in-JS styling and supports theming through its ThemeProvider. Compared to @zendeskgarden/react-theming, styled-components is more focused on styling and does not provide a design system like Zendesk Garden.
Emotion is a library designed for writing CSS styles with JavaScript. It offers powerful and flexible theming capabilities similar to styled-components. Emotion provides a ThemeProvider for managing themes, making it comparable to @zendeskgarden/react-theming in terms of theming functionality, but it does not include a design system.
Material-UI (now MUI) is a popular React UI framework that includes a comprehensive theming solution. It provides a ThemeProvider and a wide range of pre-designed components. While it offers similar theming capabilities, Material-UI is more extensive in terms of component offerings compared to @zendeskgarden/react-theming.
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 styled-components
The ThemeProvider
component can be used to apply granular theming to Garden
(and custom) components. It is intended to be used at the root of an
application to provide a global context for RTL. ThemeProvider
components
can be nested for areas that require additional, custom theming.
Garden provides several levels of customization, listed here from simple to complex, depending on your needs:
theme
prop passed to ThemeProvider
. Garden gives you access to
many of the font, pixel, and color values used to style individual
components. By modifying the theme
you have the ability to customize whole
aspects of the design system with minimal effort. Example: use theme
to
customize component primary accents with your brand color.theme.components
object within the theme
prop. Using
COMPONENT_ID
keys, you can target precise CSS properties for
customization. Example: use theme.components
to override the 20px
bottom margin of tabs.tablist
.react-containers
(outside the scope of this component). At some point, the flexibility
provided by theme
and theme.components
has diminishing returns. If you
find yourself fully re-skinning a component, then you should check out
Garden's container abstractions. Example: retain the accessible keyboard
behavior and RTL layout of Garden's tabs component with an alternate visual
design (i.e. closer to the look of browser tabs).import { ThemeProvider, DEFAULT_THEME } from '@zendeskgarden/react-theming';
import { Notification } from '@zendeskgarden/react-notifications';
<ThemeProvider theme={{ ...DEFAULT_THEME, rtl: true }}>
<Notification>This notification content will render with RTL layout.</Notification>
</ThemeProvider>;
The withTheme
HOC
utility allows any component to interact with its ThemeProvider
.
import { withTheme } from '@zendeskgarden/react-theming';
const Div = ({ theme, children }) => (
<div style={{ direction: theme.rtl ? 'rtl' : 'ltr' }}>{children}</div>
);
const LocalizedComponent = withTheme(Div);
<ThemeProvider theme={{ ...DEFAULT_THEME, rtl: true }}>
<LocalizedComponent>RTL localizable</LocalizedComponent>
</ThemeProvider>;
FAQs
Theming utilities and components within the Garden Design System
The npm package @zendeskgarden/react-theming receives a total of 7,968 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.