The button is a core interface element — it’s the primary way to indicate interactivity, so it comes in many shapes and sizes. Buttons in a17t are inline flex, so you can fit as much into them as you’d like (and they’ll automatically look nice).
The example buttons on this page are
<span> elements, but the
.button selector can be applied to essentially any type of element. If a button’s element is interactive (e.g., an
<a> with a valid
href attribute), the
:focus state will by default be identical to the
Navigation — Avoid using buttons for navigation. Buttons should generally only be used to perform actions. While that may sometimes mean navigating to a new page (as is the case with a sign-up button), it usually doesn’t. In cases of regular navigation, consider using a portal instead.
Forms — When using a button inside forms, it can sometimes be helpful to make the button look more like a field input. If this is what you want, you can apply the field selector (e.g.,
<button class="button field">) on top of the button.
Buttons have full tone and priority support.
Button Field (normal priority)
To make a block button, simply set the
100% and the flex behavior to
Be mindful of all possible states. Not everyone interacts with a button by moving the mouse to click on it. Some use the tab key to select a button visually, and others use non-graphical interfaces entirely. When customizing buttons, remember that the
:hover state does not apply to all cases in which a button is selected.
Don't use color to communicate. Instead, use color to support information you communicate through text. When this isn't possible, be sure to use a
Be mindful of contrast. What looks good to you may not be readable for others. Text contrast is a good thing!
Support all navigation modes. Some people will interact with your interface using assitive technologies and/or a keyboard. Build your interface with these different modes in mind (for example, by setting the `tab-index` attribute on all interactive elements that aren't interactive by default).
||color||—||sets background color|
||color||—||sets text color|
||sets line height|
||sets select animation speed|
||sets the brightness filter on hover + focus|
You can also customize this element by simply overriding any of its CSS attributes, listed
here. Contextual variable defaults (e.g.,
--color-content) and global
--family-primary) are defined here.