@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>
);
};