What is @zendeskgarden/react-buttons?
@zendeskgarden/react-buttons is a package that provides a set of accessible and customizable button components for React applications. It is part of the Zendesk Garden design system, which aims to offer a consistent and cohesive set of UI components.
What are @zendeskgarden/react-buttons's main functionalities?
Basic Button
This is a basic button component that can be used to trigger actions in a React application. It is styled according to the Zendesk Garden design system.
<Button>Click me</Button>
Button Sizes
The package provides buttons in different sizes, allowing developers to choose the appropriate size for their UI needs.
<Button size="small">Small Button</Button>
<Button size="large">Large Button</Button>
Button Variants
Different button variants are available, such as primary and danger, to convey different actions or states to the user.
<Button isPrimary>Primary Button</Button>
<Button isDanger>Danger Button</Button>
Icon Buttons
Icon buttons are available for actions that can be represented with an icon, providing a more compact and visually appealing option.
<IconButton aria-label="Settings"><SettingsIcon /></IconButton>
Other packages similar to @zendeskgarden/react-buttons
react-bootstrap
React-Bootstrap is a popular library that provides Bootstrap components as React components. It offers a wide range of button styles and sizes similar to @zendeskgarden/react-buttons, but with the Bootstrap design system.
material-ui
Material-UI (now MUI) is a comprehensive library of React components that implement Google's Material Design. It offers a variety of button components with extensive customization options, similar to @zendeskgarden/react-buttons, but follows the Material Design guidelines.
chakra-ui
Chakra UI is a modern React component library that provides a set of accessible and composable components, including buttons. It offers similar functionality to @zendeskgarden/react-buttons with a focus on simplicity and ease of use.
@zendeskgarden/react-buttons
This package includes components relating to buttons in the
Garden Design System.
Installation
npm install @zendeskgarden/react-buttons
npm install react react-dom styled-components @zendeskgarden/react-theming
Usage
Button
import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Button } from '@zendeskgarden/react-buttons';
<ThemeProvider>
<>
<Button onClick={() => alert('clicked')}>Default</Button>
<Button isPrimary isDanger>
Primary danger button
</Button>
</>
</ThemeProvider>;
Media button
import React, { useState } from 'react';
import { Button } from '@zendeskgarden/react-buttons';
import StartIcon from '@zendeskgarden/icons/src/16/shield-stroke.svg';
import EndIcon from '@zendeskgarden/icons/src/16/chevron-down-stroke.svg';
const MediaButton = ({ children, ...props }) => {
const [isRotated, setRotated] = useState(false);
return (
<Button onClick={() => setRotated(!isRotated)} {...props}>
<Button.StartIcon>
<StartIcon />
</Button.StartIcon>
{children}
<Button.EndIcon isRotated={isRotated}>
<EndIcon />
</Button.EndIcon>
</Button>
);
};