Change log
Components
Button
- Overview
- Usage
- Accessibility
Overview
When to use
Use buttons when a user might need to perform an action, such as:
- Submitting a form
- Specify a next or previous step in a process
- Begin a new task
When not to use
In general, don't use a <button> in place of a link (<a>) or a link in place of a button. HTML buttons and links are treated differently by assistive technologies such as screen readers, so using the wrong one can make experiences harder to use for some people.
Button vs Linkβ
Button styling can be applied to either <button> or <a> elements.
Buttons are for actions that affect something on the current page, such as submitting a form, playing media, or closing a modal.
Links navigate to a new page or anchor location, changing the URL.
Variantsβ
Primaryβ
Primary buttons are used for the most important actions, for example saving, sending, submitting, registering etc. Try to use only one per section or screen.
Secondaryβ
Secondary buttons are used for less important actions. You may use several per section or screen. They can be used independently or in a group with primary and/or tertiary buttons.
Tertiaryβ
Tertiary buttons are used whenever an action doesnβt need to stand out (for example, cancel and dismiss functionalities). You may use several per section or screen. They can be used independently or in a group with primary and/or secondary buttons.
Neutralβ
Secondary and tertiary buttons have a neutral style option. This can be used for example in complex dashboards or data tables where less attention is called for. It is also the recommended option for pairing with danger button.
Dangerβ
Danger buttons are used for emphasizing actions that can be destructive or have negative consequences if taken (for example, delete or remove). Use it sparingly.
Iconβ
Icon buttons are used for well-known and simple actions such as close, edit, delete etc and it should always have a tooltip. Icon buttons have color and neutral variant.
Touch dimensionsβ
Icon buttons have at least 32 pixel touch dimensions to ensure ease of use and accessibility across different devices. When implementing icon buttons make sure there is enough space between the buttons and other elements to decrease the chance of accidentally pressing an incorrect target.
Sizeβ
Buttons are available in regular and compact size. Regular size should be used in most cases. Compact size can be used in tight spaces (for example, large data tables).
Loading stateβ
Buttons can indicate that a quick progress action is taking place (e.g., saving settings on a server). In this case, the label and optional icon disappear and a progress circle appears. The progress circle always shows an indeterminate progress.
Use the loading state for a button sparingly. It should be reserved only for when the progress is supposed to be quick (taking 5 seconds or less), and when there is no better way to communicate as such.
Use the attribute is-loading or [loading] to enable the loading state.
Disabled stateβ
Use the disabled state of a button when a user can't perform an action at the time of their experience.
They should be used sparingly and only for actions that they are unable to take.
The user shouldn't have to guess why a button is disabled.
It should be immediately obvious as to why the button might be disabled (e.g., an item can't be downloaded due to access). Otherwise, show the button in its default state, then provide helpful error text after it's been clicked.
To use disabled state for a button, add is-disabled or [disabled] attribute.
Usage guidelines
Button text should describe what it doesβ
Be specific about what the button does, while keeping it short and concise. Aim for a maximum of 3 words or 20 characters. Avoid unnecessary words and donβt include punctuation in button text.
Do
Don't
Use sentence caseβ
Only capitalize the first letter of the button and any proper nouns.
Do
Don't
Use one primary call to actionβ
Only include one primary button in a page or section. Having multiple primary buttons in one area can be confusing or visually overwhelming.
Do
Don't
Keyboardβ
Buttons are native button type="button" elements: Tab focuses them, and Enter or Space activate them.
Screen readersβ
A button is announced as "button" followed by its visible text, which is its name. Decorative left and right icons are aria-hidden="true" and focusable="false".
- Icon-only buttons (
tds-button--icon) have no visible text, so they get anaria-labelfromiconAriaLabel. It defaults to "Sulge". - Disabled buttons (
is-disabled) usearia-disabled="true"instead of the nativedisabledattribute. They stay focusable and are announced as unavailable, so keyboard and screen reader users can still find them. - Loading buttons (
is-loading) getaria-busy="true"and the name "Laadimine, palun oodake".
Using the exampleβ
- Always set
iconAriaLabelto what the icon button does ("Muuda", "Kustuta"). The "Sulge" default is only right for close buttons. - Because
aria-disableddoes not block clicks, your handler must ignore activation while the button hasis-disabledoris-loading. - Use a button for actions and a link for navigation.
- Use
type="submit"in your copy for the button that submits a form; the template always renderstype="button". - On a page in another language, pass
iconAriaLabelin that language, or wrap Estonian UI inlang="et".
Known limitsβ
While loading, the fixed aria-label replaces the button's visible text, so a screen reader hears "Laadimine, palun oodake" instead of, for example, "Salvesta". The label is always Estonian. On other pages, or where the action name matters, change it in your copy, for example to "Salvesta, laadimine".