Skip to content

Commit 00b5483

Browse files
authored
Merge pull request #382 from JasonEtco/btn-link-fixes
Update Button docs
2 parents 82fd962 + 603dee4 commit 00b5483

File tree

2 files changed

+27
-44
lines changed

2 files changed

+27
-44
lines changed

modules/primer-buttons/README.md

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,41 +42,9 @@ status: Stable
4242

4343
Buttons are used for **actions**, like in forms, while textual hyperlinks are used for **destinations**, or moving from one page to another.
4444

45-
#### Buttons
45+
{:toc}
4646

47-
```html
48-
<button class="m-1 btn" type="button">Close</button>
49-
<button class="m-1 btn btn-primary" type="button">Comment</button>
50-
<button class="m-1 btn btn-danger" type="button">Rename repository</button>
51-
<button class="m-1 btn btn-blue" type="button">Sign up for free</button>
52-
<button class="m-1 btn btn-purple" type="button">Try if for free</button>
53-
<br>
54-
<button class="m-1 btn hover" type="button">Close</button>
55-
<button class="m-1 btn btn-primary hover" type="button">Comment</button>
56-
<button class="m-1 btn btn-danger hover" type="button">Rename repository</button>
57-
<button class="m-1 btn btn-blue hover" type="button">Sign up for free</button>
58-
<button class="m-1 btn btn-purple hover" type="button">Try if for free</button>
59-
<br>
60-
<button class="m-1 btn focus" type="button">Close</button>
61-
<button class="m-1 btn btn-primary focus" type="button">Comment</button>
62-
<button class="m-1 btn btn-danger focus" type="button">Rename repository</button>
63-
<button class="m-1 btn btn-blue focus" type="button">Sign up for free</button>
64-
<button class="m-1 btn btn-purple focus" type="button">Try if for free</button>
65-
<br>
66-
<button class="m-1 btn selected" type="button">Close</button>
67-
<button class="m-1 btn btn-primary selected" type="button">Comment</button>
68-
<button class="m-1 btn btn-danger selected" type="button">Rename repository</button>
69-
<button class="m-1 btn btn-blue selected" type="button">Sign up for free</button>
70-
<button class="m-1 btn btn-purple selected" type="button">Try if for free</button>
71-
<br>
72-
<button class="m-1 btn disabled" type="button">Close</button>
73-
<button class="m-1 btn btn-primary disabled" type="button">Comment</button>
74-
<button class="m-1 btn btn-danger disabled" type="button">Rename repository</button>
75-
<button class="m-1 btn btn-blue disabled" type="button">Sign up for free</button>
76-
<button class="m-1 btn btn-purple disabled" type="button">Try if for free</button>
77-
```
78-
79-
#### Default buttons
47+
## Default button
8048

8149
Use the standard—yet classy—`.btn` for form actions and primary page actions. These are used extensively around the site.
8250

@@ -94,7 +62,7 @@ You can find them in two sizes: the default `.btn` and the smaller `.btn-sm`.
9462
<button class="btn btn-sm" type="button">Small button</button>
9563
```
9664

97-
#### Primary
65+
## Primary button
9866

9967
Primary buttons are green and are used to indicate the *primary* action on a page. When you need your buttons to stand out, use `.btn.btn-primary`. You can use it with both button sizes—just add `.btn-primary`.
10068

@@ -103,7 +71,7 @@ Primary buttons are green and are used to indicate the *primary* action on a pag
10371
<button class="btn btn-sm btn-primary" type="button">Small primary button</button>
10472
```
10573

106-
#### Danger
74+
## Danger button
10775

10876
Danger buttons are red. They help reiterate that the intended action is important or potentially dangerous (e.g., deleting a repo or transferring ownership). Similar to the primary buttons, just add `.btn-danger`.
10977

@@ -112,7 +80,7 @@ Danger buttons are red. They help reiterate that the intended action is importan
11280
<button class="btn btn-sm btn-danger" type="button">Small danger button</button>
11381
```
11482

115-
#### Outline
83+
## Outline button
11684

11785
Outline buttons downplay an action as they appear like boxy links. Just add `.btn-outline` and go.
11886

@@ -121,7 +89,7 @@ Outline buttons downplay an action as they appear like boxy links. Just add `.bt
12189
<button class="btn btn-sm btn-outline" type="button">Outline button</button>
12290
```
12391

124-
#### Large button
92+
## Large button
12593
Use `.btn-large` to increase the padding and border radius of a button. This is useful for prominent calls to action in hero sections.
12694

12795
[Type scale utilities](https://styleguide.github.com/primer/utilities/typography/#type-scale-utilities) can be used to alter the font-size if needed. Padding is applied in em's so that it scales proportionally with the font-size.
@@ -146,7 +114,7 @@ Use `.btn-large` with a type scale utility to transform the text to a bigger siz
146114

147115
```
148116

149-
#### Disabled state
117+
## Disabled state
150118

151119
Disable `<button>` elements with the boolean `disabled` attribute and `<a>` elements with the `.disabled` class.
152120

@@ -172,7 +140,7 @@ Similar styles are applied to primary, danger, and outline buttons:
172140
<a class="btn btn-outline disabled" href="#url" role="button">Disabled button</a>
173141
```
174142

175-
#### Block buttons
143+
## Block button
176144

177145
Make any button full-width by adding `.btn-block`. It adds `width: 100%;`, changes the `display` from `inline-block` to `block`, and centers the button text.
178146

@@ -181,7 +149,17 @@ Make any button full-width by adding `.btn-block`. It adds `width: 100%;`, chang
181149
<p><button class="btn btn-sm btn-block" type="button">Small block button</button></p>
182150
```
183151

184-
#### With counts
152+
## Link button
153+
154+
Create a button that looks like a link with `.btn-link`. Rather than using an `<a>` to trigger JS, this style on a `<button>` should be used for better accessibility.
155+
156+
**The `.btn-link` class is not designed to be used with `.btn`; the overlapping styles are not compatible.**
157+
158+
```html
159+
<p><button class="btn-link" type="button">Link button</button></p>
160+
```
161+
162+
## Button with counts
185163

186164
You can easily append a count to a **small button**. Add the `.with-count` class to the `.btn-sm` and then add the `.social-count` after the button.
187165

@@ -221,7 +199,7 @@ You can also use the [counter](../../product/components/labels) component within
221199
</button>
222200
```
223201

224-
#### Button groups
202+
## Button groups
225203

226204
Have a hankering for a series of buttons that are attached to one another? Wrap them in a `.BtnGroup` and the buttons will be rounded and spaced automatically.
227205

@@ -258,7 +236,7 @@ Add `.BtnGroup-form` to `<form>`s within `.BtnGroup`s for proper spacing and rou
258236
</div>
259237
```
260238

261-
#### Hidden text button
239+
## Hidden text button
262240

263241
Use `.hidden-text-expander` to indicate and toggle hidden text.
264242

@@ -271,7 +249,7 @@ Use `.hidden-text-expander` to indicate and toggle hidden text.
271249
You can also make the expander appear inline by adding `.inline`.
272250

273251

274-
#### Using button styles with the details summary element
252+
## Using button styles with the details summary element
275253

276254
You can add `.btn` and `.btn-*` classes to any
277255
[`<summary>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary)

modules/primer-buttons/stories.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ storiesOf('Button', module)
6565
<button className="btn btn-large btn-outline-blue" type="button">Large button button</button>
6666
</div>
6767
))
68+
.add('btn-link', () => (
69+
<div className='p-4 d-flex flex-justify-between'>
70+
<button className='btn-link'>Button</button>
71+
</div
72+
))

0 commit comments

Comments
 (0)