|
| 1 | +import { Canvas, Meta, Subtitle } from '@storybook/blocks'; |
| 2 | + |
| 3 | +import * as ButtonStories from './button.stories'; |
| 4 | + |
| 5 | +<Meta of={ButtonStories} title="Docs" /> |
| 6 | + |
| 7 | +# Button |
| 8 | + |
| 9 | +<Subtitle>Buttons allow users to perform an action or to navigate to another page. They have |
| 10 | +multiple styles for various needs, and are ideal for calling attention to where a user needs to |
| 11 | +do something in order to move forward in a flow.</Subtitle> |
| 12 | + |
| 13 | +## Variants |
| 14 | + |
| 15 | +There are four available variants that are used for different levels of emphasis and different |
| 16 | +types of actions. By default, a button uses the fill style with a solid background. The primary |
| 17 | +and secondary variants also have an outline option. |
| 18 | + |
| 19 | +### Accent |
| 20 | + |
| 21 | +The call to action button communicates strong emphasis and is reserved for encouraging critical |
| 22 | +actions. In general, only use the emphasized option for the most important action on the page. |
| 23 | + |
| 24 | +<Canvas of={ButtonStories.Accent} /> |
| 25 | + |
| 26 | +### Primary |
| 27 | + |
| 28 | +The primary button is for medium emphasis. Use it in place of a call to action button when the |
| 29 | +action requires less prominence, or if there are multiple primary actions of the same importance |
| 30 | +in the same view. Both the fill (default) and outline styles are demonstrated below: |
| 31 | + |
| 32 | +<Canvas of={ButtonStories.Primary} /> |
| 33 | + |
| 34 | +### Secondary |
| 35 | + |
| 36 | +The secondary button is for low emphasis. It’s paired with other button types to surface less |
| 37 | +prominent actions, and should never be the only button in a group. Both the fill (default) and |
| 38 | +outline styles are demonstrated below: |
| 39 | + |
| 40 | +<Canvas of={ButtonStories.Secondary} /> |
| 41 | + |
| 42 | +### Negative |
| 43 | + |
| 44 | +The negative button is for emphasizing actions that can be destructive or have negative |
| 45 | +consequences if taken. Use it sparingly. |
| 46 | + |
| 47 | +<Canvas of={ButtonStories.Negative} /> |
| 48 | + |
| 49 | +## Static color |
| 50 | + |
| 51 | +When a button needs to be placed on top of a color background or a visual, use the static color |
| 52 | +option. Static color buttons do not change shades or values depending upon the color theme. |
| 53 | + |
| 54 | +### Static white - primary |
| 55 | + |
| 56 | +<Canvas of={ButtonStories.StaticWhitePrimary} /> |
| 57 | + |
| 58 | +### Static white - secondary |
| 59 | + |
| 60 | +<Canvas of={ButtonStories.StaticWhiteSecondary} /> |
| 61 | + |
| 62 | +### Static black - primary |
| 63 | + |
| 64 | +<Canvas of={ButtonStories.StaticBlackPrimary} /> |
| 65 | + |
| 66 | +### Static black - secondary |
| 67 | + |
| 68 | +<Canvas of={ButtonStories.StaticBlackSecondary} /> |
| 69 | + |
| 70 | +## Sizing |
| 71 | + |
| 72 | +Buttons come in four different sizes: small, medium, large, and extra large. The medium size is |
| 73 | +the default and most frequently used option. Use the other sizes sparingly; they should be used |
| 74 | +to create a hierarchy of importance within the page. |
| 75 | + |
| 76 | +<Canvas of={ButtonStories.Sizing} /> |
| 77 | + |
| 78 | +## Pending state |
| 79 | + |
| 80 | +The pending button is for indicating that a quick progress action is taking place. In this case, the |
| 81 | +label and optional icon disappear and a progress circle appears. The progress circle always shows an |
| 82 | +indeterminate progress. We recommend the use of the `.is-pending` class on the component’s parent |
| 83 | +container, but there is also an option to use an attribute of `pending` instead. Buttons should have |
| 84 | +the disabled attribute when the pending state is applied. |
| 85 | + |
| 86 | +<Canvas of={ButtonStories.Pending} /> |
| 87 | + |
| 88 | +## Disabled state |
| 89 | + |
| 90 | +A button in a disabled state shows that an action exists, but is not available in that circumstance. |
| 91 | +This state can be used to maintain layout continuity and to communicate that an action may become |
| 92 | +available later. |
| 93 | + |
| 94 | +<Canvas of={ButtonStories.Disabled} /> |
| 95 | + |
| 96 | +## Text overflow behavior |
| 97 | + |
| 98 | +When the button text is too long for the horizontal space available, it wraps to form another line. |
| 99 | +When there is no icon present, the text is aligned center. When there is an icon present, the text is |
| 100 | +aligned `start` (left with a writing direction of left-to-right) and the icon remains vertically aligned |
| 101 | +at the top. |
| 102 | + |
| 103 | +<Canvas of={ButtonStories.WithWrapping} /> |
0 commit comments