Button
When to use it
The Button component can be used on all buttons and, in navigational cases, links (see more below).
Variants
Add e.g. .c-button--small, .c-button--round, .c-button--positive, .c-button--ghost for other variations. Some work together while others don't – use common sense here (don't add both --positive and --negative modifiers on the same button e.g.)
Use .c-button--text-link when an inline action should look like a normal text link.
Icons
Place the SVG directly inside the button, before or after the label. The same sizing applies to inline SVG, SVG with .c-icon, and the Vue Icon component.
The default icon box is 1.55em square and scales with the button's font size. In standard and small buttons, the icon sits closer to its adjacent edge and the button matches the height of a single-line text button. Set width or height on a plain SVG, or size on the Vue component, to make the icon smaller or narrower. Each dimension is capped by the button variant's default. Use a viewBox for inline artwork or reference a symbol from the framework's SVG sprite.
Use .c-button--options for the vertical ellipsis in a menu trigger. Its icon box is 0.25rem by 1.125rem. An icon in a .c-button--text-link uses a 1em box and follows the inline label.
TIP
To override the default border radius, set --button-radius to a different value.
What it looks like
Code examples
<button type="button" class="c-button">Normal</button>
<button type="button" class="c-button c-button--small">Small button</button>
<button type="button" class="c-button c-button--large">Large button</button>
<button type="button" class="c-button c-button--disabled" disabled>Disabled button</button><input class="c-button c-button--primary" type="submit" value="Save" />
<a href="#button" class="c-button c-button--secondary">Cancel</a>
<button type="button" class="c-button c-button--primary c-button--disabled" disabled>Disabled primary button</button><button type="button" class="c-button c-button--positive">Add</button>
<button type="button" class="c-button c-button--negative">Remove</button><button type="button" class="c-button">
<svg aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#back-arrow"></use>
</svg>
With icon
</button>
<button type="button" class="c-button c-toggle" aria-expanded="false">
<svg aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#search"></use>
</svg>
With icon, toggle
</button>
<button type="button" class="c-button c-button--ghost">
<svg width="24" height="24" aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#check"></use>
</svg>
With icon, ghost
</button>
<button type="button" class="c-button c-button--small">
<svg width="16" height="16" aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#tray-arrow-down"></use>
</svg>
With icon, small
</button>
<button type="button" class="c-button c-button--small">
With icon last, small
<svg aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#forward-arrow"></use>
</svg>
</button>
<button type="button" class="c-button c-button--small c-button--ghost">
<svg width="24" height="24" aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#check"></use>
</svg>
With icon, small, ghost
</button><button type="button" class="c-button">Normal</button>
<button type="button" class="c-button">
<svg class="c-icon" aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#check"></use>
</svg>
Standard icon
</button>
<button type="button" class="c-button">
<svg class="c-icon" width="16" height="16" aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#check"></use>
</svg>
Smaller icon
</button><button type="button" class="c-button c-button--options" aria-label="More options">
<svg class="c-icon" aria-hidden="true">
<use href="/assets/vendor/ui-framework/symbol/svg/sprite.symbol.svg#dots-vertical"></use>
</svg>
</button><button type="button" class="c-button c-button--round">Round button</button>
<button type="button" class="c-button c-button--ghost">Ghost button</button>
<button type="button" class="c-button c-button--ghost c-button--primary">Ghost button, primary</button>
<button type="button" class="c-button c-button--ghost c-button--secondary">Ghost button, secondary</button>
<button type="button" class="c-button c-button--ghost c-button--positive">Ghost button, positive</button>
<button type="button" class="c-button c-button--ghost c-button--negative">Ghost button, negative</button>
<button type="button" class="c-button c-button--primary c-button--spinner">
<span>Spinner button (not loading)</span>
<div class="c-spinner"><span></span><span></span><span></span><span></span></div>
</button>
<button type="button" class="c-button c-button--primary c-button--spinner is-loading">
<span>Spinner button (is loading)</span>
<div class="c-spinner"><span></span><span></span><span></span><span></span></div>
</button><div class="c-form-control c-form-control--group">
<button type="button" class="c-button c-button--small">One</button>
<button type="button" class="c-button c-button--small c-button--selected">Two</button>
<button type="button" class="c-button c-button--small">Three</button>
</div><p>
Show details in a dialog by clicking
<button type="button" class="c-button c-button--text-link">terms and conditions</button>.
</p>Accessibility notes
Always use the <button> element for clickable actions instead of using <div> or <span> with click event listeners. This ensures that the button is recognized as an interactive element by assistive technologies. Even <a> elements with href="#" should be avoided (but do use links when the href value is valid and the "button" acts as a navigation element that leads to a new location)
Also, ensure that the text within the button clearly describes its action. Avoid using vague labels like "Click here" or "Submit". Instead, use descriptive labels like "Add to Cart" or "Search".
The <button> element is natively focusable and can be activated with the Enter or Space key. Make sure you don't disable this or make the focus indication invisible to the eye.
Sometimes ARIA (Accessible Rich Internet Applications) attributes can be necessary to provide additional context. For example, use aria-pressed="true" or aria-pressed="false" for toggle buttons to indicate their state.