, or element with the following code:
class
Description
Example
.btn
Adding basic styles to buttons
Try it
.btn-default
Default/standard button
Try it
.btn-primary
Original button style (not manipulated)
Try it
.btn-success
Indicates a successful action
Try it
.btn-info
This style can be used for buttons that pop up information
Try it
.btn-warning
Indicates a button that requires cautious action
Try it
.btn-danger
Indicates a button action for a dangerous action
Try it
.btn-link
Makes the button look like a link (while still retaining button behavior)
Try it
.btn-lg
Make a large button
Try it
.btn-sm
Make a small button
Try it
.btn-xs
Make an extra-small button
Try it
.btn-block
Block-level button (stretches to 100% of the parent element's width)
Try it
.active
Button is clicked
Try it
.disabled
Disabled button
Try it
The following example demonstrates all of the above button classes:
Example
<button type="button" class=">btn btn-default
"
Default button
button
<button type="button" class=">btn btn-primary
"
Original button
button
<button type="button" class=">btn btn-success
"
Success button
button
<button type="button" class=">btn btn-info
"
Info button
button
<button type="button" class=">btn btn-warning
"
Warning button
button
<button type="button" class=">btn btn-danger
"
Danger button
button
<button type="button" class=">btn btn-link
"
Link button
button
Try it »
The result is as follows:
Button sizes
The following table lists the classes for buttons of various sizes:
Class
Description
.btn-lg
This makes the button look larger.
.btn-sm
This makes the button look smaller.
.btn-xs
This makes the button look extra small.
.btn-block
This creates a block-level button that spans the full width of the parent element.
The following example demonstrates all of the above button classes:
Example
<p>
<button type="button" class=">btn btn-primary btn-lg
"
Large original button
button
<button type="button" class=">btn btn-default btn-lg
"
Large button
button
p
<p>
<button type="button" class=">btn btn-primary
"
Default-size original button
button
<button type="button" class=">btn btn-default
"
Default-size button
button
p
<p>
<button type="button" class=">btn btn-primary btn-sm
"
Small original button
button
<button type="button" class=">btn btn-default btn-sm
"
Small button
button
p
<p>
<button type="button" class=">btn btn-primary btn-xs
"
Extra-small original button
button
<button type="button" class=">btn btn-default btn-xs
"
Extra-small button
button
p
<p>
<button type="button" class=">btn btn-primary btn-lg btn-block
"
Block-level original button
button
<button type="button" class=">btn btn-default btn-lg btn-block
"
Block-level button
button
p
Try it »
The result is as follows:
Button states
Bootstrap provides classes for button states such as active and disabled, which will be explained in detail below.
Active state
When active, a button will appear pressed (darker background, darker border, inset shadow).
The following table lists the classes that make button elements and anchor elements appear active:
The following example demonstrates this:
Example
<p>
<button type="button" class=">btn btn-default btn-lg
"
Default button
button
<button type="button" class=">btn btn-default btn-lg active
"
Active button
button
p
<p>
<button type="button" class=">btn btn-primary btn-lg
"
Original button
button
<button type="button" class=">btn btn-primary btn-lg active
"
Active original button
button
p
Try it »
The result is as follows:
Disabled state
When you disable a button, its color becomes 50% lighter and it loses its gradient.
The following table lists the classes that make button elements and anchor elements appear disabled:
The following example demonstrates this:
Example
<p>
<button type="button" class=">btn btn-default btn-lg
"
Default button
button
<button type="button" class=">btn btn-default btn-lg
"
disabled
=
"
disabled
"
Disabled button
button
p
<p>
<button type="button" class=">btn btn-primary btn-lg
"
Original button
button
<button type="button" class=">btn btn-primary btn-lg
"
disabled
=
"
disabled
"
Disabled original button
button
p
<p>
<a href="" class=">btn btn-default btn-lg
"
role
=
"
button
"
link
a
<a href="" class=">btn btn-default btn-lg disabled
"
role
=
"
button
"
Disabled link
a
p
<p>
<a href="" class=">btn btn-primary btn-lg
"
role
=
"
button
"
Original link
a
<a href="" class=">btn btn-primary btn-lg disabled
"
role
=
"
button
"
Disabled original link
a
p
Try it »
The result is as follows:
Button tags
You can add 、
or element with button classes. However, it is recommended that you use button classes on elements to avoid cross-browser inconsistency issues.
The following example demonstrates this:
Example
<a class=">btn btn-default
"
href
=
"
"
role
=
"
button
"
link
a
<button class=">btn btn-default
"
type
=
"
submit
"
button
button
<input class=">btn btn-default
"
type
=
"
button
"
value
=
"
Input
"
<input class=">btn btn-default
"
type
=
"
submit
"
value
=
"
Submit
"
Try it »
The result is as follows:
Button group
Using .btn-group directly inside a div can create a button group:
Example
<div class="btn-group">
<button type="button" class=">btn btn-primary
"
Apple
button
<button type="button" class=">btn btn-primary
"
Samsung
button
<button type="button" class=">btn btn-primary
"
Sony
button
div
Try it »
Use .btn-group-lg|sm|xs to control the size of a button group:
Example
<div class=">btn-group btn-group-lg
"
<button type="button" class=">btn btn-primary
"
Apple
button
<button type="button" class=">btn btn-primary
"
Samsung
button
<button type="button" class=">btn btn-primary
"
Sony
button
div
Try it »
To set buttons in a vertical direction, you can use the .btn-group-vertical class:
Example
<div class="btn-group-vertical">
<button type="button" class=">btn btn-primary
"
Apple
button
<button type="button" class=">btn btn-primary
"
Samsung
button
<button type="button" class=">btn btn-primary
"
Sony
button
div
Try it »
Justified button group
You can set a justified button group via the .btn-group-justified class.
The following example uses the a tag to demonstrate:
Example
<div class=">btn-group btn-group-justified
"
<a href="" class=">btn btn-primary
"
Apple
a
<a href="" class=">btn btn-primary
"
Samsung
a
<a href="" class=">btn btn-primary
"
Sony
a
div
Try it »
Note: If it is element, you need to use the .btn-group class to wrap it:
Example
<div class=">btn-group btn-group-justified
"
<div class="btn-group">
<button type="button" class=">btn btn-primary
"
Apple
button
div
<div class="btn-group">
<button type="button" class=">btn btn-primary
"
Samsung
button
div
<div class="btn-group">
<button type="button" class=">btn btn-primary
"
Sony
button
div
div
Try it »
Button group with a nested dropdown
Buttons nested inside a button group can have dropdown menus, as shown in the following example:
Example
<div class="btn-group">
<button type="button" class=">btn btn-primary
"
Apple
button
<button type="button" class=">btn btn-primary
"
Samsung
button
<div class="btn-group">
<button type="button" class=">btn btn-primary dropdown-toggle
"
data-toggle
=
"
dropdown
"
Sony
<span class="caret" span button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="" Tablet a li>
<li>
<a href="" Smartphone a li ul div div>Try it »
Split button
Example
<div class="btn-group">
<button type="button" class=">btn btn-primary
"
Sony
button
<button type="button" class=">btn btn-primary dropdown-toggle
"
data-toggle
=
"
dropdown
"
<span class="caret" span button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="" Tablet a li>
<li>
<a href="" Smartphone a li ul div>Try it »