Buttons

Use Pixel's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.

Bootstrap 4 documentation
Main buttons

Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.

                                                        
<button class="btn mb-2 mr-2 btn-primary" type="button">Primary</button>
<button class="btn mb-2 mr-2 btn-secondary" type="button">Secondary</button>
<button class="btn mb-2 mr-2 btn-tertiary" type="button">Tertiary</button>
<button class="btn mb-2 mr-2 btn-success" type="button">Success</button>
<button class="btn mb-2 mr-2 btn-warning" type="button">Warning</button>
<button class="btn mb-2 mr-2 btn-danger" type="button">Danger</button>
<button class="btn mb-2 mr-2 btn-info" type="button">Info</button>
<button class="btn mb-2 mr-2 btn-dark" type="button">Dark</button>
<button class="btn mb-2 mr-2 btn-gray" type="button">Gray</button>
<button class="btn mb-2 mr-2 btn-light" type="button">Light</button>
<button class="btn mb-2 mr-2 btn-white" type="button">White</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 (e.g, .btn-outline-primary) to remove all background images and colors on any button.

                                                        
<button class="btn mb-2 mr-2 btn-outline-primary" type="button">Primary</button>
<button class="btn mb-2 mr-2 btn-outline-secondary" type="button">Secondary</button>
<button class="btn mb-2 mr-2 btn-outline-tertiary" type="button">Tertiary</button>
<button class="btn mb-2 mr-2 btn-outline-success" type="button">Success</button>
<button class="btn mb-2 mr-2 btn-outline-warning" type="button">Warning</button>
<button class="btn mb-2 mr-2 btn-outline-danger" type="button">Danger</button>
<button class="btn mb-2 mr-2 btn-outline-info" type="button">Info</button>
<button class="btn mb-2 mr-2 btn-outline-dark" type="button">Dark</button>
<button class="btn mb-2 mr-2 btn-outline-gray" type="button">Gray</button>
<button class="btn mb-2 mr-2 btn-outline-light" type="button">Light</button>
<button class="btn mb-2 mr-2 btn-outline-white" type="button">White</button>
                                                        
                                                    
Pill buttons

If you like buttons more rounded (with a larger border-radius) use the .btn-pill modifier class.

                                                        
<button class="btn mb-2 mr-2 btn-pill btn-primary" type="button">Primary</button>
<button class="btn mb-2 mr-2 btn-pill btn-outline-primary" type="button">Primary</button>
                                                        
                                                    
Circle buttons

You can use the border utility class, like:.rounded-circle if you want circle button.

                                                        
<button class="btn mb-2 mr-2 btn-icon-only btn-primary" type="button">
    <span class="btn-inner-icon"><i class="far fa-heart"></i></span>
</button>
<button class="btn mb-2 mr-2 btn-icon-only rounded-circle btn-primary" type="button">
    <span class="btn-inner-icon"><i class="far fa-thumbs-up"></i></span>
</button>
                                                        
                                                    
With icons

In our product buttons with icons can be implemented using a combination of <button> and <span>

                                                        
<button class="btn mb-2 mr-2 btn-icon btn-primary" type="button">
    <span class="btn-inner-icon"><i class="fas fa-brain"></i></span>
    <span class="btn-inner-text">Icon Left</span>
</button>
<button class="btn mb-2 mr-2 btn-icon btn-primary" type="button">
    <span class="btn-inner-text">Icon Right</span>
    <span class="btn-inner-icon"><i class="fas fa-brain"></i></span>
</button>
<button class="btn mb-2 mr-2 btn-icon-only btn-primary" type="button">
    <span class="btn-inner-icon"><i class="far fa-heart"></i></span>
</button>
                                                        
                                                    
Animated buttons

Use animation modifier classes .animate-*-# (eg. .animate-up-1, .animate-down-3). You can use up, right, down and bottom and use a counter from 1 to 5 to specify the distance in pixels.

                                                            
<button class="btn mb-2 mr-2 btn-primary animate-up-2" type="button">Animate up</button>
<button class="btn mb-2 mr-2 btn-secondary animate-right-3" type="button">Animate right</button>
<button class="btn mb-2 mr-2 btn-tertiary animate-left-3" type="button">Animate left</button>
<button class="btn mb-2 mr-2 btn-success animate-down-2" type="button">Animate down</button>
                                                            
                                                        
Social buttons

Start using the buttons as you would normally do with the Bootstrap buttons that have an icon by adding the relevant class. For example:.btn-twitter

                                                        
<button class="btn mb-2 mr-2 btn-icon btn-twitter" type="button">
    <span class="btn-inner-icon"><i class="fab fa-twitter"></i></span>
    <span class="btn-inner-text">Login with Twitter</span>
</button>
<button class="btn mb-2 mr-2 btn-icon btn-pill btn-twitter" type="button">
    <span class="btn-inner-icon"><i class="fab fa-twitter"></i></span>
    <span class="btn-inner-text">Login with Twitter</span>
</button>
<button class="btn mb-2 mr-2 btn-icon-only btn-twitter" type="button">
    <span class="btn-inner-icon"><i class="fab fa-twitter"></i></span>
</button>
<button class="btn mb-2 mr-2 btn-icon-only btn-pill btn-twitter" type="button">
    <span class="btn-inner-icon"><i class="fab fa-twitter"></i></span>
</button>
<a href="#" class="btn mb-2 mr-2 btn-link btn-twitter">
    <i class="fab fa-twitter"></i>
</a>
                                                        
                                                    
Button tags

The .btn classes are designed to be used with the <button> element. However, you can also use these classes on <a> or <input> elements (though some browsers may apply a slightly different rendering).

When using button classes on <a> elements that are used to trigger in-page functionality (like collapsing content), rather than linking to new pages or sections within the current page, these links should be given a to appropriately convey their purpose to assistive technologies such as screen readers.

Link
                                                        
<a class="btn mb-2 mr-2 btn-primary" href="#" role="button">Link</a>
<button class="btn mb-2 mr-2 btn-primary" type="submit">Button</button>
<input class="btn mb-2 mr-2 btn-primary" type="button" value="Input">
<input class="btn mb-2 mr-2 btn-primary" type="submit" value="Submit">
<input class="btn mb-2 mr-2 btn-primary" type="reset" value="Reset">
                                                        
                                                    
Sizes

Fancy larger or smaller buttons? Add .btn-lg or .btn-sm for additional sizes.

                                                        
<button class="btn mb-2 mr-2 btn-sm btn-primary" type="button">Small</button>
<button class="btn mb-2 mr-2 btn-primary" type="button">Regular</button>
<button class="btn mb-2 mr-2 btn-lg btn-primary" type="button">Large Button</button>
                                                        
                                                    
Block level buttons

Create block level buttons—those that span the full width of a parent—by adding .btn-block.

                                                        
<button class="btn mb-2 mr-2 btn-sm btn-primary" type="button">Small</button>
<button class="btn mb-2 mr-2 btn-primary" type="button">Regular</button>
<button class="btn mb-2 mr-2 btn-lg btn-primary" type="button">Large Button</button>
                                                        
                                                    
Active state

Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. There’s no need to add a class to <button>s as they use a pseudo-class. However, you can still force the same active appearance with .active (and include the aria-pressed="true" attribute) should you need to replicate the state programmatically.

                                                        
<a href="#" class="btn mb-2 mr-2 btn-primary btn-lg active" role="button" aria-pressed="true">Primary link</a>
<a href="#" class="btn mb-2 mr-2 btn-secondary btn-lg active" role="button" aria-pressed="true">Link</a>
                                                        
                                                    
Disabled state

Make buttons look inactive by adding the disabled boolean attribute to any <button> element.

                                                        
<button type="button" class="btn mb-2 mr-2 btn-primary" disabled>Primary button</button>
<button type="button" class="btn mb-2 mr-2 btn-secondary" disabled>Button</button>
                                                        
                                                    

Disabled buttons using the <a> element behave a bit different:

  • <a>s don't support the disabled attribute, so you must add the .disabled class to make it visually appear disabled.
  • Some future-friendly styles are included to disable all pointer-events on anchor buttons. In browsers which support that property, you won't see the disabled cursor at all.
  • Disabled buttons should include the aria-disabled="true" attribute to indicate the state of the element to assistive technologies.
                                                
<a href="#" class="btn mb-2 mr-2 btn-primary disabled" tabindex="-1" role="button" aria-disabled="true">Primary link</a>
<a href="#" class="btn mb-2 mr-2 btn-secondary disabled" tabindex="-1" role="button" aria-disabled="true">Link</a>
                                                
                                            
Link functionality caveat

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. In addition, 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.

Button plugin

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 mb-2 mr-2 btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
    Single toggle
</button>
                                                    
                                                
Button plugin

Pixel and Bootstrap's .button styles can be applied to other elements, such as <label>s, to provide checkbox or radio style button toggling. Add data-toggle="buttons" to a .btn-group containing those modified buttons to enable their toggling behavior via JavaScript and add .btn-group-toggle to style the <input>s within your buttons. Note that you can create single input-powered buttons or groups of them.

The checked state for these buttons is only updated via click event on the button. If you use another method to update the input—e.g., with <input type="reset"> or by manually applying the input's checked property—you'll need to toggle .active on the <label> manually.

Note that pre-checked buttons require you to manually add the .active class to the input's <label>.

                                                    
<div class="btn-group-toggle" data-toggle="buttons">
    <label class="btn mb-2 mr-2 btn-secondary active">
        <input type="checkbox" checked autocomplete="off"> Checked
    </label>
</div>
                                                    
                                                
                                                    
<div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn mb-2 mr-2 btn-dark active">
        <input type="radio" name="options" id="option1" autocomplete="off" checked /> Active
    </label>
    <label class="btn mb-2 mr-2 btn-dark">
        <input type="radio" name="options" id="option2" autocomplete="off" /> Radio
    </label>
    <label class="btn mb-2 mr-2 btn-dark">
        <input type="radio" name="options" id="option3" autocomplete="off" /> Radio
    </label>
</div>