@@ -15,21 +15,23 @@ Use the standard—yet classy—`.btn` for form actions and primary page actions
15
15
When using a ` <button> ` element, ** always specify a ` type ` ** . When using a ` <a> ` element, ** always add ` role="button" ` for accessibility** .
16
16
17
17
``` html live
18
- <button class =" btn" type =" button" >Button button</button > <a class =" btn" href =" #url" role =" button" >Link button</a >
18
+ <button class =" btn mr-2" type =" button" >Button button</button >
19
+ <a class =" btn" href =" #url" role =" button" >Link button</a >
19
20
```
20
21
21
22
You can find them in two sizes: the default ` .btn ` and the smaller ` .btn-sm ` .
22
23
23
24
``` html live
24
- <button class =" btn" type =" button" >Button</button > <button class =" btn btn-sm" type =" button" >Small button</button >
25
+ <button class =" btn mr-2" type =" button" >Button</button >
26
+ <button class =" btn btn-sm" type =" button" >Small button</button >
25
27
```
26
28
27
29
## Primary button
28
30
29
31
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 ` .
30
32
31
33
``` html live
32
- <button class =" btn btn-primary" type =" button" >Primary button</button >
34
+ <button class =" btn btn-primary mr-2 " type =" button" >Primary button</button >
33
35
<button class =" btn btn-sm btn-primary" type =" button" >Small primary button</button >
34
36
```
35
37
@@ -38,7 +40,7 @@ Primary buttons are green and are used to indicate the _primary_ action on a pag
38
40
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 ` .
39
41
40
42
``` html live
41
- <button class =" btn btn-danger" type =" button" >Danger button</button >
43
+ <button class =" btn btn-danger mr-2 " type =" button" >Danger button</button >
42
44
<button class =" btn btn-sm btn-danger" type =" button" >Small danger button</button >
43
45
```
44
46
@@ -47,7 +49,7 @@ Danger buttons are red. They help reiterate that the intended action is importan
47
49
Outline buttons downplay an action as they appear like boxy links. Just add ` .btn-outline ` and go.
48
50
49
51
``` html live
50
- <button class =" btn btn-outline" type =" button" >Outline button</button >
52
+ <button class =" btn btn-outline mr-2 " type =" button" >Outline button</button >
51
53
<button class =" btn btn-sm btn-outline" type =" button" >Outline button</button >
52
54
```
53
55
@@ -58,44 +60,42 @@ Use `.btn-large` to increase the padding and border radius of a button. This is
58
60
[ 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.
59
61
60
62
``` html live
61
- <p >
62
- <a class =" btn btn-large" href =" #url" role =" button" >Large link button</a >
63
- <button class =" btn btn-large" type =" button" >Large button button</button >
64
- </p >
63
+ <button class =" btn btn-large mr-2" type =" button" >Large button</button >
64
+ <a class =" btn btn-large" href =" #url" role =" button" >Large link button</a >
65
65
```
66
66
67
67
Use ` .btn-large ` with a type scale utility to transform the text to a bigger size.
68
68
69
69
``` html live
70
- <p class =" f3" >
70
+ <div class =" f3" >
71
+ <button class =" btn btn-large btn-outline-blue mr-2" type =" button" >Large button button</button >
71
72
<a class =" btn btn-large" href =" #url" role =" button" >Large link button</a >
72
- <button class =" btn btn-large btn-outline-blue" type =" button" >Large button button</button >
73
- </p >
73
+ </div >
74
74
```
75
75
76
76
## Disabled state
77
77
78
78
Disable ` <button> ` elements with the boolean ` disabled ` attribute and ` <a> ` elements with the ` .disabled ` class.
79
79
80
80
``` html live
81
- <button class =" btn" type =" button" disabled >Disabled button</button >
81
+ <button class =" btn mr-2 " type =" button" disabled >Disabled button</button >
82
82
<a class =" btn disabled" href =" #url" role =" button" >Disabled button</a >
83
83
```
84
84
85
85
Similar styles are applied to primary, danger, and outline buttons:
86
86
87
87
``` html live
88
- <button class =" btn btn-primary" type =" button" disabled >Disabled button</button >
88
+ <button class =" btn btn-primary mr-2 " type =" button" disabled >Disabled button</button >
89
89
<a class =" btn btn-primary disabled" href =" #url" role =" button" >Disabled button</a >
90
90
```
91
91
92
92
``` html live
93
- <button class =" btn btn-danger" type =" button" disabled >Disabled button</button >
93
+ <button class =" btn btn-danger mr-2 " type =" button" disabled >Disabled button</button >
94
94
<a class =" btn btn-danger disabled" href =" #url" role =" button" >Disabled button</a >
95
95
```
96
96
97
97
``` html live
98
- <button class =" btn btn-outline" type =" button" disabled >Disabled button</button >
98
+ <button class =" btn btn-outline mr-2 " type =" button" disabled >Disabled button</button >
99
99
<a class =" btn btn-outline disabled" href =" #url" role =" button" >Disabled button</a >
100
100
```
101
101
@@ -104,8 +104,8 @@ Similar styles are applied to primary, danger, and outline buttons:
104
104
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.
105
105
106
106
``` html live
107
- <p >< button class =" btn btn-block" type =" button" >Block button</button ></ p >
108
- <p >< button class =" btn btn-sm btn-block" type =" button" >Small block button</button ></ p >
107
+ <button class =" btn btn-block mb-2 " type =" button" >Block button</button >
108
+ <button class =" btn btn-sm btn-block" type =" button" >Small block button</button >
109
109
```
110
110
111
111
## Link button
@@ -115,7 +115,55 @@ Create a button that looks like a link with `.btn-link`. Rather than using an `<
115
115
** The ` .btn-link ` class is not designed to be used with ` .btn ` ; the overlapping styles are not compatible.**
116
116
117
117
``` html live
118
- <p ><button class =" btn-link" type =" button" >Link button</button ></p >
118
+ <button class =" btn-link" type =" button" >Link button</button >
119
+ ```
120
+
121
+ ## Invisible button
122
+
123
+ When you want a link, but you want it padded and line heighted like a button best for "cancel" actions on forms.
124
+
125
+ ``` html live
126
+ <button class =" btn btn-invisible" type =" button" >Cancel</button >
127
+ <button class =" btn" type =" button" >Submit</button >
128
+ ```
129
+
130
+ ## Octicon button
131
+
132
+ Icon-only buttons that turn blue on hover. Use ` .btn-octicon-danger ` to turn an icon red on hover.
133
+
134
+ ``` html live
135
+ <button class =" btn-octicon" type =" button" aria-label =" Desktop icon" >
136
+ <!-- <%= octicon "device-desktop" %> -->
137
+ <svg class =" octicon octicon-device-desktop" viewBox =" 0 0 16 16" version =" 1.1" width =" 16" height =" 16" aria-hidden =" true" ><path fill-rule =" evenodd" d =" M15 2H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5.34c-.25.61-.86 1.39-2.34 2h8c-1.48-.61-2.09-1.39-2.34-2H15c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 9H1V3h14v8z" ></path ></svg >
138
+ </button >
139
+
140
+ <button class =" btn-octicon" type =" button" aria-label =" Pencil icon" >
141
+ <!-- <%= octicon "pencil" %> -->
142
+ <svg class =" octicon octicon-pencil" viewBox =" 0 0 14 16" version =" 1.1" width =" 14" height =" 16" aria-hidden =" true" ><path fill-rule =" evenodd" d =" M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 011.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z" ></path ></svg >
143
+ </button >
144
+
145
+ <button class =" btn-octicon btn-octicon-danger" type =" button" aria-label =" Trashcan icon" >
146
+ <!-- <%= octicon "trashcan" %> -->
147
+ <svg class =" octicon octicon-trashcan" viewBox =" 0 0 12 16" version =" 1.1" width =" 12" height =" 16" aria-hidden =" true" ><path fill-rule =" evenodd" d =" M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z" ></path ></svg >
148
+ </button >
149
+
150
+ <button class =" btn-octicon" type =" button" aria-label =" Trashcan icon" >
151
+ <!-- <%= octicon "kebab-horizontal" %> -->
152
+ <svg class =" octicon octicon-kebab-horizontal" viewBox =" 0 0 13 16" version =" 1.1" width =" 13" height =" 16" aria-hidden =" true" ><path fill-rule =" evenodd" d =" M1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm5 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM13 7.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z" ></path ></svg >
153
+ </button >
154
+ ```
155
+
156
+
157
+
158
+ ## Close button
159
+
160
+ When using the ` octicon-x ` icon for a close button, add ` .close-button ` to remove the default button styles.
161
+
162
+ ``` html live
163
+ <button class =" close-button" type =" button" >
164
+ <!-- <%= octicon "x" %> -->
165
+ <svg width =" 12" height =" 16" viewBox =" 0 0 12 16" class =" octicon octicon-x" aria-hidden =" true" ><path fill-rule =" evenodd" d =" M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z" /></svg >
166
+ </button >
119
167
```
120
168
121
169
## Button with counts
@@ -138,24 +186,20 @@ You can easily append a count to a **small button**. Add the `.with-count` class
138
186
You can also use the [ counter] ( ./labels#counters ) component within buttons:
139
187
140
188
``` html live
141
- <button class =" btn" type =" button" >
142
- Button
143
- <span class =" Counter" >12</span >
189
+ <button class =" btn mr-2" type =" button" >
190
+ Button <span class =" Counter" >12</span >
144
191
</button >
145
192
146
- <button class =" btn btn-primary" type =" button" >
147
- Button
148
- <span class =" Counter" >12</span >
193
+ <button class =" btn btn-primary mr-2" type =" button" >
194
+ Button <span class =" Counter" >12</span >
149
195
</button >
150
196
151
- <button class =" btn btn-danger" type =" button" >
152
- Button
153
- <span class =" Counter" >12</span >
197
+ <button class =" btn btn-danger mr-2" type =" button" >
198
+ Button <span class =" Counter" >12</span >
154
199
</button >
155
200
156
201
<button class =" btn btn-outline" type =" button" >
157
- Button
158
- <span class =" Counter" >12</span >
202
+ Button <span class =" Counter" >12</span >
159
203
</button >
160
204
```
161
205
@@ -207,21 +251,3 @@ Use `.hidden-text-expander` to indicate and toggle hidden text.
207
251
```
208
252
209
253
You can also make the expander appear inline by adding ` .inline ` .
210
-
211
- ## Using button styles with the details summary element
212
-
213
- You can add ` .btn ` and ` .btn-* ` classes to any
214
- [ ` <summary> ` ] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary )
215
- element so that it gains the appearance of a button, and
216
- selected/active styles when the parent
217
- [ ` <details> ` ] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details )
218
- element is open.
219
-
220
- ``` html live
221
- <details >
222
- <summary class =" btn btn-block btn-primary" >Toggle the content</summary >
223
- <p class =" mt-2" >
224
- This content will be toggled.
225
- </p >
226
- </details >
227
- ```
0 commit comments