Bootstrap buttons component for actions in tables, forms, cards, and more. Bootstrap 4 provides various styles, states, and size. Ready to use and easy to customize.
On this page:CoreUI includes a bunch of predefined Bootstrap buttons, each serving its own semantic purpose. CoreUI also offers some unique buttons styles.
Buttons show what action will happen when the user clicks or touches it. Bootstrap buttons are used to initialize operations, both in the background or foreground of an experience.
<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-dark">Dark</button>
<button type="button" class="btn btn-link">Link</button>
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only
class.
You can combine Bootstrap buttons with our CoreUI Icons.
<button type="button" class="btn btn-primary"><span class="cil-contrast btn-icon mr-2"></span> Primary</button>
<button type="button" class="btn btn-secondary"><span class="cil-contrast btn-icon mr-2"></span> Secondary</button>
<button type="button" class="btn btn-success"><span class="cil-contrast btn-icon mr-2"></span> Success</button>
<button type="button" class="btn btn-danger"><span class="cil-contrast btn-icon mr-2"></span> Danger</button>
<button type="button" class="btn btn-warning"><span class="cil-contrast btn-icon mr-2"></span> Warning</button>
<button type="button" class="btn btn-info"><span class="cil-contrast btn-icon mr-2"></span> Info</button>
<button type="button" class="btn btn-light"><span class="cil-contrast btn-icon mr-2"></span> Light</button>
<button type="button" class="btn btn-dark"><span class="cil-contrast btn-icon mr-2"></span> Dark</button>
<button type="button" class="btn btn-link">Link</button>
You can also combine Bootstrap buttons with Brand Icons.
<button type="button" class="btn btn-behance"><span class="cib-behance btn-icon mr-2"></span> Behance</button>
<button type="button" class="btn btn-dribbble"><span class="cib-dribbble btn-icon mr-2"></span> Dribbble</button>
<button type="button" class="btn btn-facebook"><span class="cib-facebook btn-icon mr-2"></span> Facebook</button>
<button type="button" class="btn btn-flickr"><span class="cib-flickr btn-icon mr-2"></span> Flickr</button>
<button type="button" class="btn btn-github"><span class="cib-github btn-icon mr-2"></span> Github</button>
<button type="button" class="btn btn-instagram"><span class="cib-instagram btn-icon mr-2"></span> Instagram</button>
<button type="button" class="btn btn-linkedin"><span class="cib-linkedin btn-icon mr-2"></span> Linkedin</button>
<button type="button" class="btn btn-pinterest"><span class="cib-pinterest btn-icon mr-2"></span> Pinterest</button>
<button type="button" class="btn btn-reddit"><span class="cib-reddit btn-icon mr-2"></span> Reddit</button>
<button type="button" class="btn btn-tumblr"><span class="cib-tumblr btn-icon mr-2"></span> Tumblr</button>
<button type="button" class="btn btn-twitter"><span class="cib-twitter btn-icon mr-2"></span> Twitter</button>
<button type="button" class="btn btn-vimeo"><span class="cib-vimeo btn-icon mr-2"></span> Vimeo</button>
<button type="button" class="btn btn-vk"><span class="cib-vk btn-icon mr-2"></span> Vk</button>
<button type="button" class="btn btn-xing"><span class="cib-xing btn-icon mr-2"></span> Xing</button>
<button type="button" class="btn btn-yahoo"><span class="cib-yahoo btn-icon mr-2"></span> Yahoo</button>
<button type="button" class="btn btn-youtube"><span class="cib-youtube btn-icon mr-2"></span> Youtube</button>
The .btn
classes are designed for <button>
, <a>
or <input>
elements (though some browsers may apply a slightly different rendering).
If you’re using .btn
classes on <a>
elements that are used to trigger functionality ex. collapsing content, these links should be given a role="button"
to adequately communicate their meaning to assistive technologies such as screen readers.
<a class="btn btn-primary" href="#" role="button">Link</a>
<button class="btn btn-primary" type="submit">Button</button>
<input class="btn btn-primary" type="button" value="Input">
<input class="btn btn-primary" type="submit" value="Submit">
<input class="btn btn-primary" type="reset" value="Reset">
CoreUI is delivered with bunch of Bootstrap’s button styles.
<button type="button" class="btn btn-pill btn-primary">Primary</button>
<button type="button" class="btn btn-pill btn-secondary">Secondary</button>
<button type="button" class="btn btn-pill btn-success">Success</button>
<button type="button" class="btn btn-pill btn-danger">Danger</button>
<button type="button" class="btn btn-pill btn-warning">Warning</button>
<button type="button" class="btn btn-pill btn-info">Info</button>
<button type="button" class="btn btn-pill btn-light">Light</button>
<button type="button" class="btn btn-pill btn-dark">Dark</button>
<button type="button" class="btn btn-square btn-primary">Primary</button>
<button type="button" class="btn btn-square btn-secondary">Secondary</button>
<button type="button" class="btn btn-square btn-success">Success</button>
<button type="button" class="btn btn-square btn-danger">Danger</button>
<button type="button" class="btn btn-square btn-warning">Warning</button>
<button type="button" class="btn btn-square btn-info">Info</button>
<button type="button" class="btn btn-square btn-light">Light</button>
<button type="button" class="btn btn-square btn-dark">Dark</button>
If you need a button, but without the strong background colors. Replace the default modifier classes with the .btn-outline-*
ones to remove all background colors on any element with .btn
class.
<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>
<button type="button" class="btn btn-outline-dark">Dark</button>
Use .btn-ghost-*
class for ghost buttons.
<button type="button" class="btn btn-ghost-primary">Primary</button>
<button type="button" class="btn btn-ghost-secondary">Secondary</button>
<button type="button" class="btn btn-ghost-success">Success</button>
<button type="button" class="btn btn-ghost-danger">Danger</button>
<button type="button" class="btn btn-ghost-warning">Warning</button>
<button type="button" class="btn btn-ghost-info">Info</button>
<button type="button" class="btn btn-ghost-light">Light</button>
<button type="button" class="btn btn-ghost-dark">Dark</button>
Larger or smaller buttons? Add .btn-lg
or .btn-sm
for additional sizes.
<button type="button" class="btn btn-primary btn-lg">Large button</button>
<button type="button" class="btn btn-secondary btn-lg">Large button</button>
<button type="button" class="btn btn-primary btn-sm">Small button</button>
<button type="button" class="btn btn-secondary btn-sm">Small button</button>
Create buttons that span the full width of a parent—by adding .btn-block
.
<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>
<button type="button" class="btn btn-secondary btn-lg btn-block">Block level button</button>
Buttons will appear pressed when active. There’s no requirement to attach a class to <button>
s as they use a pseudo-class. Nevertheless, you can apply the same active appearance by adding the .active
class and including the aria-pressed=“true”
attribute.
<a href="#" class="btn btn-primary btn-lg active" role="button" aria-pressed="true">Primary link</a>
<a href="#" class="btn btn-secondary btn-lg active" role="button" aria-pressed="true">Link</a>
Add the disabled
boolean attribute to any <button>
element to make buttons look inactive.
<button type="button" class="btn btn-lg btn-primary" disabled>Primary button</button>
<button type="button" class="btn btn-secondary btn-lg" disabled>Button</button>
Disabled buttons using the <a>
element behave a bit different:
<a>
s don’t support the disabled
attribute, so you have to add .disabled
class to make buttons look inactive. The disabled bootstrap button must have the aria-disabled="true"
attribute to show the state of the element to assistive technologies.
<a href="#" class="btn btn-primary btn-lg disabled" tabindex="-1" role="button" aria-disabled="true">Primary link</a>
<a href="#" class="btn btn-secondary btn-lg disabled" tabindex="-1" role="button" aria-disabled="true">Link</a>
The .disabled
class uses pointer-events: none
to try to disable the link functionality of <a>
s, but that CSS property is not yet standardized. Besides, even in browsers that do support pointer-events: none
, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, add a tabindex="-1"
attribute on these links (to prevent them from receiving keyboard focus) and use custom JavaScript to disable their functionality.
Make bootstrap buttons more powerful. Control button states or creates groups of buttons for extra elements like toolbars.
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>
.
<button type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
Single toggle
</button>
Bootstrap button styles can be connected to other elements, such as <label>
s, to render radio style button toggling. Add data-toggle="buttons"
to a .btn-group
including those changed buttons to enable their toggling behavior via JavaScript and add .btn-group-toggle
to style the <input>
s within your buttons.
<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>
Bootstrap’s button styles can be connected to other elements, such as <label>
s, to render checkbox or radio style button toggling. Add data-toggle="buttons"
to a .btn-group
including those changed buttons to enable their toggling behavior via JavaScript and add .btn-group-toggle
to style the <input>
s within your buttons.
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="checkbox" checked autocomplete="off"> Checked
</label>
</div>
You can create a button instance with the button constructor, for example:
var button = document.getElementById('myButton')
var bsButton = new coreui.Button(button)
Method | Description |
---|---|
toggle |
Toggles push state. Gives the button the appearance that it has been activated. |
dispose |
Destroys an element’s button. |
For example, to toggle all buttons
var buttons = document.querySelectorAll('.btn')
buttons.forEach(function (button) {
var button = new coreui.Button(button)
button.toggle()
})
Method | Description |
---|---|
$().button('toggle') |
Toggles push state. Gives the button the appearance that it has been activated. |
$().button('dispose') |
Destroys an element’s button. |