You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/design-system-docs/docs/components/inputs/button.md
+64-18Lines changed: 64 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Button
2
2
3
-
_Buttons_allow users to take action with a single click or tap.
3
+
_Buttons_are the primary action triggers in EDS. They support direct actions (e.g., submit, confirm) and toggle selections, with variants to indicate hierarchy (contained, outlined, ghost) and intent (primary, secondary, danger). Always pair buttons with clear, action-oriented labels.
4
4
5
5
<iframe
6
6
class="sb-iframe"
@@ -18,51 +18,89 @@ _Buttons_ allow users to take action with a single click or tap.
18
18
19
19
Use a button for a direct, immediate user action (submit, confirm, start, cancel, toggle) rather than for pure navigation or passive information.
20
20
21
+
Use a button for **direct, immediate actions** (e.g., submit, confirm, cancel) or **toggle selections** (e.g., switching views). Avoid buttons for:
22
+
21
23
## Structure
22
24
23
-
- Contained
24
-
- Contained with icon
25
-
- Outlined
26
-
- Ghost
27
-
- Ghost with icon
25
+
All variants support:
26
+
27
+
-**Left/right icons** (paired with text).
28
+
-**Icon-only** (requires an `aria-label` for accessibility).
29
+
-**Text-only** (default).
30
+
31
+
**Toggle Buttons**
32
+
33
+
Group related actions in a **shared container** where only one option can be ctive at a time. Use for:
34
+
35
+
- Switching views (e.g., "List" vs "Grid").
36
+
- Mutually exclusive options (e.g., "Day" vs "Week" in a calendar).
37
+
38
+
**Density**
39
+
40
+
-**Default**: Standard padding and typography.
41
+
-**Compact**: Reduced padding for dense UIs (e.g., toolbars). **Must** provide a way to switch to default mode for accessibility [1].
28
42
29
43
## Hierarchy
30
44
31
-
### Buttons
45
+
Use variants to guide users to the most important action:
-**Secondary**: Less prominent (e.g., "Save as draft").
56
+
-**Danger**: Destructive actions (e.g., "Delete"). **Danger buttons must invert the order in button groups** (e.g., ["Cancel" (primary), "Delete" (danger)]) to prevent accidental activation.
38
57
39
58

40
59
41
-
#### Guidelines
42
-
43
-
There are `primary`, `secondary` and `danger` colour buttons available in the `contained`, `outlined` and `ghost` variations. All variations can have the following: an icon on the left, an icon on the right, an icon with no text and text only with no icon. When using an icon, it must be directly related to the action and label of the button.
60
+
All variations can have the following: an icon on the left, an icon on the right, an icon with no text and text only with no icon. When using an icon, it must be directly related to the action and label of the button.
44
61
45
62
#### Accessibility
46
63
47
64
The `aria-disabled` attribute makes it possible to semantically disable the `Button` without hiding it from assistive technologies, such as screen readers. In EDS, the `Button` will be visually styled as disabled, but it is up to the developer to actually disable the button.
48
65
66
+
**Standard Buttons**
67
+
68
+
-**Keyboard**: Supports `Tab` focus; activates with `Enter` or `Space`.
69
+
-**Disabled State**:
70
+
- Use `aria-disabled="true"` to **semantically disable** the button (visible to screen readers).
71
+
-**Developers must** prevent clicks via `onClick` logic (EDS styles the button visually but does not block interactions).
Toggle buttons group a set of related actions in one shared common container. Only one option in a group of toggle buttons can be selected and active at a time. Selecting one option deselects any other.
Button.Toggle sets `aria-pressed="bool"` according to the button state. You should provide an accessible label with `aria-label="label"`, `aria-labelledby="id"` or `<label>`.
- **Group Labeling**: Use `aria-label` or `aria-labelledby` to describe the group’s purpose (e.g., "View options").
99
+
- **State**: `aria-pressed="true/false"` reflects the toggle state.
62
100
63
101
#### Compact
64
102
65
-
Compact mode is toggled using EdsProvider.
103
+
Compact mode is toggled using `EdsProvider`.
66
104
67
105
:::note
68
106
The compact mode should come with the possibility to switch to normal mode for accessibility reasons.
@@ -85,6 +123,10 @@ The compact mode should come with the possibility to switch to normal mode for a
85
123
86
124
✅ You can use an icon to help clarify an action. Always use icons that clearly communicate their intended purpose
87
125
126
+
✅ Provide accessible names for icon-only buttons (`aria-label`).
127
+
128
+
✅ **Allow switching from compact to default mode** for accessibility.
129
+
88
130
❌ Do not apply the same colour to all the buttons in a group. Use variants (contained, outlined, ghost) to differentiate the hierarchy instead
89
131
90
132
❌ Do not use the same variant for all action buttons since the user needs to understand which call to action has the most emphasis
@@ -94,3 +136,7 @@ The compact mode should come with the possibility to switch to normal mode for a
94
136
❌ Do not assign the same order to danger buttons as the “positive” action button groups (primary + secondary), use the opposite (secondary + primary) instead
95
137
96
138
❌ Do not use an icon that can mislead the main action
139
+
140
+
❌ Do not rely on color alone to convey meaning (ensure text/icons are clear).
141
+
142
+
❌ Do not disable buttons without explanation (e.g., add a tooltip for "Why is this disabled?").
0 commit comments