Buttons
Examples of building button components for actions in forms, dialogs, and more with support for multiple sizes, states, and more
Whilst all of the following buttons can be built with utility classes, Elements ships with some pre-designed button styles to make working with these frequently used components easier.
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.
Disable text wrapping
If you don’t want the button text to wrap, you can add the .whitespace-nowrap
class to the button.
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 role=“button” to appropriately convey their purpose to assistive technologies such as screen readers.
Sizes
Add.btn-xs
, .btn-sm
, .btn-md
, .btn-lg
or .btn-xl
for additional sizes. Omitting the size modifier will use .btn-md
as the default size.
Create block level buttons—those that span the full width of a parent—by adding .btn-block.
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.
Disabled state
Make buttons look inactive by adding the disabled boolean attribute to any <button>
element.
Buttons with icons
The button components use SVG’s for icons. .btn-{xs,sm,md,lg,xl}
classes automatically set the default icon size. It can be modified using the .icon-*
utility classes, check out the Icon Size documentation.
When spacing button content use .inline-xs
for .btn-xs
& .btn-sm
, and .inline-sm
for btn
, ..btn-md
, .btn-lg
& .btn-xl
.
Buttons Styles
There are four types of buttons that come baked into Elements CSS, .btn
, .btn-square
, .btn-rounded
and .btn-link
.
On this Page
v1.13.5