Buttons
Use Bootstrap’s custom button styles for actions in forms, dialogs, and more with support for multiple sizes,
states, and more.
Example
Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras
thrown in for more control.
Primary
Secondary
Success
Danger
Warning
Info
Light
Link
Copy
<button type= "button" class= "btn btn-primary" > Primary</button>
<button type= "button" class= "btn btn-secondary" > Secondary</button>
<button type= "button" class= "btn btn-success" > Success</button>
<button type= "button" class= "btn btn-danger" > Danger</button>
<button type= "button" class= "btn btn-warning" > Warning</button>
<button type= "button" class= "btn btn-info" > Info</button>
<button type= "button" class= "btn btn-light" > Light</button>
<button type= "button" class= "btn btn-link" > Link</button>
Outline buttons
In need of a button, but not the hefty background colors they bring? Replace the default modifier classes with the .btn-outline-*
ones to remove all background images and colors on any button.
Primary
Secondary
Success
Danger
Warning
Info
Light
Copy
<button type= "button" class= "btn btn-outline-primary" > Primary</button>
<button type= "button" class= "btn btn-outline-secondary" > Secondary</button>
<button type= "button" class= "btn btn-outline-success" > Success</button>
<button type= "button" class= "btn btn-outline-danger" > Danger</button>
<button type= "button" class= "btn btn-outline-warning" > Warning</button>
<button type= "button" class= "btn btn-outline-info" > Info</button>
<button type= "button" class= "btn btn-outline-light" > Light</button>
Sizes
Fancy larger or smaller buttons? Add .btn-lg
or .btn-sm
for additional sizes.
Large button
Large button
Copy
<button type= "button" class= "btn btn-primary btn-lg" > Large button</button>
<button type= "button" class= "btn btn-secondary btn-lg" > Large button</button>
Medium button
Medium button
Copy
<button type= "button" class= "btn btn-primary btn-md" > Medium button</button>
<button type= "button" class= "btn btn-secondary btn-md" > Medium button</button>
Note
Medium button is consider as Default sizes you can write class name "btn" or "btn-md" for same
Small button
Small button
Copy
<button type= "button" class= "btn btn-primary btn-sm" > Small button</button>
<button type= "button" class= "btn btn-secondary btn-sm" > Small button</button>
Disabled State
Make buttons look inactive by adding the disabled
boolean attribute to any <button>
element.
Primary button
Secondary button
Copy
<button type= "button" class= "btn btn-primary disabled" > Primary button</button>
<button type= "button" class= "btn btn-secondary disabled" > Secondary button</button>
Toggle Button
Bootstrap button styles apply to Checkbox and radio buttons. Add data-toggle="button"
to toggle a button’s active
state. If you’re pre-toggling a button, you must manually add the .active
class and aria-pressed="true"
to the <button>
.
Copy
<div class= "btn-group btn-group-toggle" data-toggle= "buttons" >
<label class= "btn btn-secondary active" >
<input type= "radio" name= "options" id= "option1" autocomplete= "off" checked > Active
</label>
<label class= "btn btn-secondary" >
<input type= "radio" name= "options" id= "option2" autocomplete= "off" > Radio
</label>
<label class= "btn btn-secondary" >
<input type= "radio" name= "options" id= "option3" autocomplete= "off" > Radio
</label>
</div>
Copy
<div class= "btn-group btn-group-toggle" data-toggle= "buttons" >
<label class= "btn btn-light active" >
<input type= "radio" name= "options" id= "option1" autocomplete= "off" checked > Active
</label>
<label class= "btn btn-light" >
<input type= "radio" name= "options" id= "option2" autocomplete= "off" > Radio
</label>
<label class= "btn btn-light" >
<input type= "radio" name= "options" id= "option3" autocomplete= "off" > Radio
</label>
</div>
Yes/No or On/Off
Copy
<div class= "btn-group btn-group-toggle" data-toggle= "buttons" >
<label class= "btn btn-secondary active" >
<input type= "radio" name= "options" id= "option1" autocomplete= "off" checked > Yes
</label>
<label class= "btn btn-secondary" >
<input type= "radio" name= "options" id= "option2" autocomplete= "off" > No
</label>
</div>
Dropdown Button
Any single .btn
can be turned into a dropdown toggle with some markup changes. Here’s how you can put them to work with either <button>
elements:
Copy
<div class= "dropdown" >
<button class= "btn btn-secondary dropdown-toggle" type= "button" id= "dropdownMenuButton" data-toggle= "dropdown" aria-haspopup= "true" aria-expanded= "false" >
Dropdown button
</button>
<div class= "dropdown-menu" aria-labelledby= "dropdownMenuButton" >
<a class= "dropdown-item" href= "#" > Action</a>
<a class= "dropdown-item" href= "#" > Another action</a>
<a class= "dropdown-item" href= "#" > Something else here</a>
</div>
</div>
And with Split button dropdowns but with the addition of .dropdown-toggle-split
for proper spacing around the dropdown caret.
Copy
<div class= "btn-group" >
<button type= "button" class= "btn btn-success" > Action</button>
<button type= "button" class= "btn btn-success dropdown-toggle dropdown-toggle-split" data-toggle= "dropdown" aria-haspopup= "true" aria-expanded= "false" >
<span class= "sr-only" > Toggle Dropdown</span>
</button>
<div class= "dropdown-menu dropdown-menu-right" >
<a class= "dropdown-item" href= "#" > Action</a>
<a class= "dropdown-item" href= "#" > Another action</a>
<a class= "dropdown-item" href= "#" > Something else here</a>
<div class= "dropdown-divider" ></div>
<a class= "dropdown-item" href= "#" > Separated link</a>
</div>
</div>
Using icon only Options button
Copy
<div class= "dropdown" >
<button class= "btn btn-secondary dropdown-toggle no-after px-3" type= "button" id= "dropdownMenuButton" data-toggle= "dropdown" aria-haspopup= "true" aria-expanded= "false" >
<img class= "img-fluid" src= "..." alt= "Icon" >
</button>
<div class= "dropdown-menu" aria-labelledby= "dropdownMenuButton" >
<a class= "dropdown-item" href= "#" > Action</a>
<a class= "dropdown-item" href= "#" > Another action</a>
<a class= "dropdown-item" href= "#" > Something else here</a>
</div>
</div>
Floating Button
Custom Floating button
Copy