2022-10-14 00:39:22 +02:00
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { ButtonLink } from './button-link';
2023-01-26 19:32:11 +01:00
import { ButtonBase } from '../button-base';
2022-10-14 00:39:22 +02:00
# ButtonLink
2023-01-26 19:32:11 +01:00
The `ButtonLink` is an extension of `ButtonBase` to support link styles
2022-10-14 00:39:22 +02:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-buttonlink--default-story" />
2022-10-14 00:39:22 +02:00
</Canvas>
## Props
2023-01-20 20:27:46 +01:00
The `ButtonLink` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) and [ButtonBase](/docs/components-componentlibrary-buttonbase--default-story#props) component props
2022-10-14 00:39:22 +02:00
<ArgsTable of={ButtonLink} />
2023-01-26 19:32:11 +01:00
The `ButtonLink` accepts all [ButtonBase](/docs/components-componentlibrary-buttonbase--default-story#props) component props
<ArgsTable of={ButtonBase} />
2022-10-14 00:39:22 +02:00
### Size
2023-02-14 18:33:04 +01:00
Use the `size` prop and the `Size` object from `./ui/helpers/constants/design-system.js` to change the size of `ButtonLink`. Defaults to `Size.auto`.
2022-10-14 00:39:22 +02:00
2023-02-14 18:33:04 +01:00
Optional: `BUTTON_LINK_SIZES` from `../../component-library` object can be used instead of `Size`
2022-10-14 00:39:22 +02:00
Possible sizes include:
2023-02-02 21:15:26 +01:00
- `Size.auto` sets the height to auto but retains `ButtonLink` font-size
- `Size.SM` 32px
- `Size.MD` 40px
- `Size.LG` 48px
- `Size.inherit` inherits the font-size of the parent element. Used for inline links in paragraphs.
2022-10-14 00:39:22 +02:00
<Canvas>
2023-02-14 18:33:04 +01:00
<Story id="components-componentlibrary-buttonlink--size-story" />
2022-10-14 00:39:22 +02:00
</Canvas>
```jsx
2023-02-02 21:15:26 +01:00
import { Size } from '../../../helpers/constants/design-system';
import { ButtonLink, Text, TextVariant } from '../../component-library';
2023-01-26 19:32:11 +01:00
2023-02-02 21:15:26 +01:00
<ButtonLink size={Size.auto}>
2023-01-26 19:32:11 +01:00
Auto (default)
</ButtonLink>
2023-02-02 21:15:26 +01:00
<ButtonLink size={Size.SM}>
2023-01-26 19:32:11 +01:00
Small
</ButtonLink>
2023-02-02 21:15:26 +01:00
<ButtonLink size={Size.MD}>
2023-01-26 19:32:11 +01:00
Medium
</ButtonLink>
2023-02-02 21:15:26 +01:00
<ButtonLink size={Size.LG}>
2023-01-26 19:32:11 +01:00
Large
</ButtonLink>
2023-02-02 21:15:26 +01:00
<Text variant={TextVariant.bodyLgMedium}>
2023-02-14 18:33:04 +01:00
Inherits the font-size of the parent element. <ButtonLink size={Size.inherit}>Learn more</ButtonLink>
2023-01-26 19:32:11 +01:00
</Text>
2023-02-02 21:15:26 +01:00
<Text variant={TextVariant.bodyMd}>
2023-02-14 18:33:04 +01:00
Inherits the font-size of the parent element. <ButtonLink size={Size.inherit}>Learn more</ButtonLink>
2023-01-26 19:32:11 +01:00
</Text>
2023-02-02 21:15:26 +01:00
<Text variant={TextVariant.bodySm}>
2023-02-14 18:33:04 +01:00
Inherits the font-size of the parent element. <ButtonLink size={Size.inherit}>Learn more</ButtonLink>
2023-01-26 19:32:11 +01:00
</Text>
2023-02-02 21:15:26 +01:00
<Text variant={TextVariant.bodyXs}>
Inherits the font-size of the parent element and example with textProps override for a success color.
2023-02-14 18:33:04 +01:00
<ButtonLink size={Size.inherit}>Learn more</ButtonLink>
2023-01-26 19:32:11 +01:00
</Text>
2022-10-14 00:39:22 +02:00
```
2022-11-09 22:55:13 +01:00
### Danger
2022-10-14 00:39:22 +02:00
2022-11-18 21:36:33 +01:00
Use the `danger` boolean prop to change the `ButtonLink` to danger color.
2022-10-14 00:39:22 +02:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-buttonlink--danger" />
2022-10-14 00:39:22 +02:00
</Canvas>
```jsx
2023-01-13 22:58:09 +01:00
import { ButtonLink } from '../../component-library';
2022-10-14 00:39:22 +02:00
<ButtonLink>Normal</ButtonLink>
<ButtonLink danger>Danger</ButtonLink>
```
### Href
2023-01-13 22:58:09 +01:00
When an `href` prop is passed it will change the element to an anchor(`a`) tag.
2022-10-14 00:39:22 +02:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-buttonlink--href" />
2022-10-14 00:39:22 +02:00
</Canvas>
```jsx
2023-01-13 22:58:09 +01:00
import { ButtonLink } from '../../component-library';
2022-10-14 00:39:22 +02:00
2023-01-26 19:32:11 +01:00
<ButtonLink href="/">Href example</ButtonLink>;
```
### Hit area
2023-02-14 18:33:04 +01:00
The default hit area for `ButtonLink` is the width of the text and height based on the `size` prop which is set to `Size.auto` by default. There may be times when you want to increase the hit area of the `ButtonLink`. To do this you can use the `Box` props `paddingLeft` and `paddingRight`. Or alternatively you can use the `block` prop which sets the width to 100%.
2023-01-26 19:32:11 +01:00
<Canvas>
<Story id="components-componentlibrary-buttonlink--hit-area" />
</Canvas>
```jsx
import { ButtonLink } from '../../component-library';
<ButtonLink paddingLeft={4} paddingRight={4}>
Auto (default)
</ButtonLink>
2023-02-14 18:33:04 +01:00
<ButtonLink size={Size.SM} paddingLeft={4} paddingRight={4}>
2023-01-26 19:32:11 +01:00
Small
</ButtonLink>
2023-02-14 18:33:04 +01:00
<ButtonLink size={Size.MD} paddingLeft={4} paddingRight={4}>
2023-01-26 19:32:11 +01:00
Medium
</ButtonLink>
2023-02-14 18:33:04 +01:00
<ButtonLink size={Size.LG} paddingLeft={4} paddingRight={4}>
2023-01-26 19:32:11 +01:00
Large
</ButtonLink>
2023-02-14 18:33:04 +01:00
<ButtonLink size={Size.LG} block>
2023-01-26 19:32:11 +01:00
Large block
</ButtonLink>
2022-10-14 00:39:22 +02:00
```