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/website/src/content/docs/components/mui/ToggleButton.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,3 +11,44 @@ links:
11
11
## StrataKit MUI modifications
12
12
13
13
- A `label` prop has been added. When specified, it is used as the **ToggleButton’s** accessible name and is also shown in a tooltip on hover and focus.
14
+
-**ToggleButtons** are styled to match the visual appearance of the [**IconButton**](/components/iconbutton) component. Borders are displayed only when the buttons are wrapped in a `ToggleButtonGroup`. [Standalone](#standalone)**ToggleButtons** do not have borders.
15
+
-**ToggleButtons** can now be rendered as regular [**Buttons**](/components/button) to [display text](#text).
16
+
17
+
## Examples
18
+
19
+
### Standalone
20
+
21
+
Use the [`selected`](https://mui.com/material-ui/api/toggle-button/#toggle-button-prop-selected) and [`onChange`](https://mui.com/material-ui/api/toggle-button/#toggle-button-prop-onChange) props to control the selected state of a standalone **ToggleButton** when it is not nested within a [`ToggleButtonGroup`](https://mui.com/material-ui/api/toggle-button-group/) component.
22
+
23
+
::example{src="mui/ToggleButton.standalone"}
24
+
25
+
### Sizes
26
+
27
+
-**Small:** Use in compact interfaces where space is limited.
28
+
-**Medium:** Default size, suitable for most use cases.
29
+
-**Large:** Use in spacious layouts where a more prominent button is needed.
30
+
31
+
::example{src="mui/ToggleButton.sizes"}
32
+
33
+
### Text
34
+
35
+
To display text within a **ToggleButton**, use the `render` prop to render a [**Button**](/components/button). Additionally, the `label` prop should be omitted, as the visible text already provides an accessible name.
36
+
37
+
::example{src="mui/ToggleButton.text"}
38
+
39
+
:::note[Exclusive selection]
40
+
41
+
In the example above, the [`exclusive`](https://mui.com/material-ui/api/toggle-button-group/#toggle-button-group-prop-exclusive) prop is set on the [`ToggleButtonGroup`](https://mui.com/material-ui/api/toggle-button-group/), which allows only one button to be selected at a time. Additionally, the handler used in the [`onChange`](https://mui.com/material-ui/api/toggle-button-group/#toggle-button-group-prop-onChange) prop enforces that at least one button is always selected.
42
+
43
+
:::
44
+
45
+
## ✅ Do
46
+
47
+
- Use **ToggleButton** for actions that have an on/off state.
48
+
- Use the `label` prop in icon-only **ToggleButtons** to provide a descriptive, accessible name.
49
+
- Use `ToggleButtonGroup` to group multiple related **ToggleButtons**.
50
+
51
+
## 🚫 Don’t
52
+
53
+
- Don’t use to replace buttons.
54
+
- Don’t mix text and icon-only **ToggleButtons** in the same group.
0 commit comments