Buttons are used to trigger specific actions or functions. For example, you can use a "Submit" button in a form to send user input to a server, or a "Save" button to save changes in an application.
Item | Name | Description | Optional |
---|---|---|---|
1 | Text label | A button's text label acts as a concise but powerful message, informing users of the action triggered by a click or tap. It serves as the button's voice, delivering clarity and guidance in a few well-chosen words. | yes |
2 | Container | The container of a button is its home, providing structure and placement within the user interface. It ensures the button is visually pleasing, strategically positioned, and accessible to users. | no |
3 | Icon | The icon of a button is like a visual cue, conveying meaning and enhancing user understanding. It's a compact symbol that complements the button's text, adding an extra layer of context or functionality. | yes |
Take a look at our button options designed for different user needs and situations. They enhance user experiences for everyday actions and critical decisions. Check out our default, primary, success, warning, and danger button variants in our overview.
This table provides guidance on when to use each button variant (Solid, Outline, Ghost, and Link) for different button types, considering their specific characteristics and purposes in user interface design.
Variants | Solid | Outline | Ghost | Link |
---|---|---|---|---|
Primary | Used to move forward in a primary (the most important) user flow. | For secondary actions related to the primary user flow. | To give suggestive actions related to the primary user flow. | To give information related to the primary user flow. |
Default | Used to move forward in a secondary user flow or when there is no specific user flow. | For secondary actions related to the secondary user flow. | To give suggestive actions related to the secondary user flow. | To give information related to the secondary user flow |
Success | For actions confirming successful operations. | For secondary actions related to the successful operation. | To give suggestive actions related to the successful operation. | To give information related to the successful operation. |
Warning | For actions requiring caution or user confirmation. | For secondary actions related to the warning. | To give suggestions related to the warning. | To give information related to the warning user flow. |
Danger | For actions confirming potentially negative consequences. | For secondary actions related to potentially negative consequences. | To give suggestions related to potentially negative consequences. | To give information related to potentially negative consequences. |
Here's an example that explains which button to use in different scenarios:
With these options you can tweak the appearance of the button in Figma. They are available in the Design Panel so you can compose the button to exactly fit the user experience need for the uses case you are working on.
Item | Options | Description |
---|---|---|
Type | solid outline ghost link | There are four button types to choose from so you can differentiate between buttons, depending on how essential they are. More info about button types |
Variant | default primary success warning danger info | Indicates the variant of the button. More info about button variants |
Size | small medium large | The button is available in three sizes. If not specified the default value is medium . |
Icon | start end | Indictes the position of the icon. |
Label | text | Value of the button. |
Icon only | boolean | Indicates if it is an icon only button. |
Users can activate a button by clicking anywhere within the button container.
When the button label is concealed, a tooltip appears on hover, revealing the label text and, when applicable, a keyboard shortcut.
Hover and Active State Transitions: When users hover over a button or the button is in an active state, the background color and/or border color smoothly transition to provide visual feedback.
<sl-button fill="solid" size="md">Default</sl-button>
<sl-button fill="solid" size="md" variant="primary">Primary</sl-button>
<sl-button fill="solid" size="md" variant="success">Success</sl-button>
<sl-button fill="solid" size="md" variant="warning">Warning</sl-button>
<sl-button fill="solid" size="md" variant="danger">Danger</sl-button>
The SL Design System button can be used to replace the default HTML button. We've tried our best to mimic all the behaviours and options you get when using a standard button. But this one looks a lot nicer!
Name | Attribute | Type | Default | Description |
---|---|---|---|---|
disabled | disabled | boolean | undefined | Whether the button is disabled; when set no interaction is possible. | |
fill | fill | 'solid' | 'outline' | 'link' | 'ghost' | 'solid' | The fill of the button. |
size | size | 'sm' | 'md' | 'lg' | 'md' | The size of the button. |
type | type | 'button' | 'reset' | 'submit' | 'button' | The type of the button. Can be used to mimic the functionality of submit and reset buttons in native HTML buttons. |
variant | variant | 'default' | 'primary' | 'success' | 'info' | 'warning' | 'danger' | 'default' | The variant of the button. |
Name | Description |
---|---|
default | Text label of the button. Optionally an <code>sl-icon</code> can be added |
Having an accessible application is not only achieved by writing good code, but also (maybe even MORE so) by writing good copy. To make sure buttons and their actions are clear for all users make sure to keep these points in mind:
Button text should be brief, ideally 1 or 2 words, and at most 4 words with fewer than 20 characters, spaces included. Avoid punctuation like periods or exclamation points.
Buttons should express actions, using verbs in their labels and a bare infinitive conjunction. This approach enhances clarity and user orientation.
The button's label should unmistakably convey the action's result, mirroring the wording elsewhere in the experience.
Always use sentence case for button text; capitalization should not be used for emphasis.
Buttons serve a functional purpose, so emojis and exclamation points should be left behind. Keep labels as plain text, free from extra punctuation or embellishments.
When the button has focus:
WAI-ARIA Roles, States, and Properties for a button provide essential information to assistive technologies and screen readers. They convey the button's role, state (enabled or disabled), and additional properties to ensure accessibility and a better user experience for individuals using assistive technology.
Attribute | Value | Description | User supplied |
---|---|---|---|
role | 'button' | Makes it clear that our custom component is a button | no |
aria-labelledby | string | When different element serves as the label, for example in the case of an icon-only button that has a label outside the button, this property can be set to the id of that element | yes |
aria-label | string | To be used when the button is icon-only | yes |
aria-describedby | string | When the button needs extra explanation or description you can reference this element here by the id . See [Note 1] below for more explanation. | yes |
aria-disabled | boolean | Announces the button as disabled with a screenreader. See [Note 2] below for more explanation | yes |
aria-pressed | boolean | When the button is used as a toggle and is toggled on, the value of this state is true, and when toggled off, the state is false. | yes |
Notes:
There is a subtle difference between aria-labelledby
and aria-describedby
; a label should be concise, where a description is intended to provide more verbose information. A description can for example be "Items in the trash will be permanently removed after 30 days." to explain what (delayed) effect a "Move to trash" button has.
The aria-disabled
should not be used as a one-for-one replacement for the disabled
attribute because they have different functionalities:
disabled
dims the button visually, takes it out of the tab-focus sequence, prevents actions (click, enter) on it and anounces it as 'dimmed' or 'disabled' in a screenreader.
aria-disabled
only does the latter. You will need to disable the functionality yourself. This might be useful for scenario's where you don't want to take the button out of the navigation flow.
When disabled
is added to a button there is no need to also add aria-disabled
; Everything aria-disabled
does, disabled
does as well.
You can read more on the difference and in which scenarios which option might be preferable on the MDN page about aria-disabled