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 and render prop containers relating to
buttons within the Garden Design System.
Installation
npm install @zendeskgarden/react-buttons
npm install react react-dom prop-types styled-components @zendeskgarden/react-theming
Usage
General Buttons
import '@zendeskgarden/react-buttons/dist/styles.css';
import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Button } from '@zendeskgarden/react-buttons';
<ThemeProvider>
<Button onClick={() => alert('clicked')}>Default</Button>
<Button primary disabled>
Disabled Primary button
</Button>
</ThemeProvider>;
Button Group
initialState = {
selectedKey: 'item-1'
};
<ButtonGroup selectedKey={state.selectedKey} onStateChange={setState}>
<Button key="item-1">Item 1</Button>
<Button key="item-2">Item 2</Button>
<Button key="item-3">Item 3</Button>
</ButtonGroup>;