import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; import { Button } from './button'; # 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](/ui-components-component-library-button-primary-button-primary-stories-js--default-story), [ButtonSecondary](/ui-components-component-library-button-secondary-button-secondary-stories-js--default-story), [ButtonLink](/ui-components-component-library-button-link-button-link-stories-js--default-story), and [Box](/docs/ui-components-ui-box-box-stories-js--default-story#props) component props ### Type Use the `type` prop and the `BUTTON_TYPES` object from `./button.constants.js` to change the `Button` type. Possible types include: - `BUTTON_TYPES.PRIMARY` - `BUTTON_TYPES.SECONDARY` - `BUTTON_TYPES.LINK` ```jsx import { Button, BUTTON_TYPES } from '../ui/component-library/button'; ``` ### Size Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-system.js` to change the size of `Button`. Defaults to `SIZES.MD` Optional: `BUTTON_SIZES` from `./button` object can be used instead of `SIZES`. Possible sizes include: - `SIZES.AUTO` inherits the font-size of the parent element. - `SIZES.SM` 32px - `SIZES.MD` 40px - `SIZES.LG` 48px ```jsx import { SIZES } from '../../../helpers/constants/design-system'; import { Button } from '../ui/component-library/button/button/button'; ``` ### Href When an `href` is passed the tag element will switch to an `anchor`(`a`) tag. ```jsx import { Button } from '../ui/component-library/button/button/button'; ; ``` ### Block Use boolean `block` prop to quickly enable a full width block button ```jsx import { DISPLAY } from '../../../helpers/constants/design-system'; import { Button } from '../ui/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 '../ui/component-library'; ``` ### Disabled Use the boolean `disabled` prop to disable button ```jsx import { Button } from '../ui/component-library'; ; ``` ### Loading Use the boolean `loading` prop to set loading spinner ```jsx import { Button } from '../ui/component-library'; ; ``` ### Icon Use the `icon` prop and the `ICON_NAMES` object from `./ui/components/component-library/icon` to select icon. ```jsx import { Button } from '../ui/component-library'; import { ICON_NAMES } from '../icon'; ; ```