import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { Button } from './button';
import { ButtonBase } from '../button-base';
import { ButtonLink } from '../button-link';
# Button
The `Button` is used for user actions. It unifies `ButtonPrimary`, `ButtonSecondary` and `ButtonLink`.
## Props
The `Button` accepts all props below as well as all [ButtonPrimary](/docs/components-componentlibrary-buttonprimary--default-story), [ButtonSecondary](/docs/components-componentlibrary-buttonsecondary--default-story), [ButtonLink](/docs/components-componentlibrary-buttonlink--default-story), and [Box](/docs/components-ui-box--default-story#props) component props
The `Button` accepts all [ButtonBase](/docs/components-componentlibrary-buttonbase--default-story#props) component props
The `Button` accepts all [ButtonPrimary](/docs/components-componentlibrary-buttonprimary--default-story), [ButtonSecondary](/docs/components-componentlibrary-buttonsecondary--default-story), [ButtonLink](/docs/components-componentlibrary-buttonlink--default-story), and [Box](/docs/components-ui-box--default-story#props) component props
### Variant
Use the `variant` prop and the `BUTTON_VARIANT` object from `./button.constants.js` to change the `Button` variant.
Possible variants include:
- `BUTTON_VARIANT.PRIMARY`
- `BUTTON_VARIANT.SECONDARY`
- `BUTTON_VARIANT.LINK`
```jsx
import { Button, BUTTON_VARIANT } from '../ui/component-library/button';
```
### Size
Use the `size` prop and the `Size` object from `./ui/helpers/constants/design-system.js` to change the size of `Button`. Defaults to `Size.MD`
Optional: `BUTTON_SIZES` from `./button` object can be used instead of `Size`.
Possible sizes include:
- `Size.inherit` inherits the font-size of the parent element. For [ButtonLink](/docs/components-componentlibrary-buttonlink--default-story) uses only
- `Size.auto` inherits auto height, but keeps the same button font-size. For [ButtonLink](/docs/components-componentlibrary-buttonlink--default-story) uses only
- `Size.SM` 32px
- `Size.MD` 40px
- `Size.LG` 48px
```jsx
import { Size } from '../../../helpers/constants/design-system';
import { Button } from '../../component-library';
```
### Danger
Use the `danger` boolean prop to change the `Button` to danger color.
```jsx
import { Button } from '../../component-library';
```
### Href
When an `href` prop is passed it will change the element to an anchor(`a`) tag.
```jsx
import { Button } from '../../component-library';
;
```
### Block
Use boolean `block` prop to quickly enable a full width block button
```jsx
import { DISPLAY } from '../../../helpers/constants/design-system';
import { Button } from '../../component-library';
```
### As
Use the `as` box prop to change the element of `Button`. Defaults to `button`.
When an `href` prop is passed it will change the element to an anchor(`a`) tag.
Button `as` options:
- `button`
- `a`
```jsx
import { Button } from '../../component-library';
```
### Disabled
Use the boolean `disabled` prop to disable button
```jsx
import { Button } from '../../component-library';
;
```
### Loading
Use the boolean `loading` prop to set loading spinner
```jsx
import { Button } from '../../component-library';
;
```
### Icon Name
Use the `startIconName` and/or `endIconName` prop and the `IconName` enum from `./ui/components/component-library/icon` to select icon.
Use the [IconSearch](/story/components-componentlibrary-icon--default-story) story to find the icon you want to use.
```jsx
import { Button } from '../../component-library';
import { IconName } from '../icon';
;
```
```jsx
import { Button } from '../../component-library';
import { IconName } from '../icon';
;
```