CoreUI includes a bunch of predefined buttons components, each serving its own semantic purpose. Buttons show what action will happen when the user clicks or touches it. CoreUI buttons are used to initialize operations, both in the background or foreground of an experience.
You can combine button with our CoreUI Icons.
The <CButton> component are designed for
<button> , <a> or
<input>
elements (though some browsers may apply a slightly different
rendering).
If you're using <CButton> component as
<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.
If you need a button, but without the strong background colors. Set
variant="outline" prop to remove all background
colors.
If you need a ghost variant of button, set
variant="ghost" prop to remove all background
colors.
Larger or smaller buttons? Add size="lg" or
size="sm" for additional sizes.
Add the disabled boolean prop to any
<CButton>
component to make buttons look inactive. Disabled button has
pointer-events: none applied to, disabling hover and
active states from triggering.
Disabled buttons using the <a> component act a
little different:
<a>s don'tsupport the
disabled attribute, so CoreUI has to add
.disabled class to make buttons look inactive. CoreUI
also has to add to the disabled button component
aria-disabled="true" attribute to show the
state of the component to assistive technologies.
Create buttons that span the full width of a parent—by using utilities.
Here we create a responsive variation, starting with vertically
stacked buttons until the md breakpoint, where
.d-md-block replaces the .d-grid class,
thus nullifying the gap-2 utility. Resize your browser
to see them change.
You can adjust the width of your block buttons with grid column
width classes. For example, for a half-width "block button",
use .col-6. Center it horizontally with
.mx-auto, too.
Additional utilities can be used to adjust the alignment of buttons when horizontal. Here we've taken our previous responsive example and added some flex utilities and a margin utility on the button to right align the buttons when they're no longer stacked.