Skip to content

Commit 495f4f1

Browse files
author
saad-mo
committed
Update toggle documentation
1 parent 3f93ad2 commit 495f4f1

1 file changed

Lines changed: 59 additions & 35 deletions

File tree

docs/pages/components/toggle.md

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,72 @@ permalink: components/toggle.html
88
folder: components
99
---
1010

11-
The toggle/swtich component is used to activate or deactivate an element. Uses a visual metaphor that is know to the user with visible differences between on and off state.
11+
The toggle/switch is meant to resemble a physical switch and allow a user to turn a setting “on” or “off”. It should be used to switch between two states/modes: active or inactive.
1212
{: .docs-intro}
1313

14-
It is recommended to always display the toggle with a label above it as well as the label of the selected state. For example, the label above would be Active, the toggle state would be "on" and the selected state label displayed to the right of the toggle would be "Yes".
14+
It is recommended to always display the toggle with a label above it as well as the label of the selected state. For example, the label above would be Active, the toggle state would be “on” and the selected state label displayed to the right of the toggle would be Yes.
1515

16-
<br>
1716

18-
## Toggle Options
19-
In addition to the default option, there are two additional modifiers avialable:
20-
- `fd-toggle--label`: renders `off` and `on` labels inside the toggle switch
21-
- `fd-toggle--semantic`: renders semnatic colors and icons inside the toggle switch
22-
23-
> Note: `fd-toggle--label` modifier only supports up to three characters by default. The width of the component will not increase to accomodate longer labels and will need to be a css override, for example - `<span class="fd-toggle" style="width: 70px">`
17+
## Toggle with Label on top
18+
To clarify the meaning of the toggle, use a label above it (ex. Live).
2419

2520
{% capture default %}
26-
<label>
27-
<span class="fd-toggle">
28-
<input type="checkbox" name="" value="" id="y21YO391">
29-
<span class="fd-toggle__switch" role="presentation"></span>
30-
</span>
31-
</label>
21+
<div class="fd-form__set">
22+
<div class="fd-form__item">
23+
<label class="fd-form__label" for="y21YO391">Live:</label>
24+
<label>
25+
<span class="fd-toggle">
26+
<input type="checkbox" name="" value="" id="y21YO391">
27+
<span class="fd-toggle__switch" role="presentation"></span>
28+
</span>
29+
</label>
30+
</div>
31+
</div>
32+
{% endcapture %}
33+
{% include display-component.html component=default %}
3234

33-
<label>
34-
<span class="fd-toggle fd-toggle--label">
35-
<input type="checkbox" name="" value="" id="eKVll635">
36-
<span class="fd-toggle__switch" role="presentation">
37-
<span class="fd-toggle__label--on">ON</span>
38-
<span class="fd-toggle__label--off">OFF</span>
35+
## Toggle with label on the side
36+
When the value of the toggle requires translation, it is suggested to display the text value (ex. On/Off) outside and to the right of of the toggle to allow for longer translations. (ex. French translation of “On” is “Allumez”)
37+
38+
{% capture default %}
39+
<div class="fd-form__item fd-form__item--check">
40+
<label class="fd-form__label" for="y21YO3911">
41+
<span class="fd-toggle fd-form__control">
42+
<input type="checkbox" name="" value="" id="y21YO3911">
43+
<span class="fd-toggle__switch" role="presentation"></span>
3944
</span>
40-
</span>
41-
</label>
45+
Allumez
46+
</label>
47+
</div>
4248

49+
{% endcapture %}
50+
{% include display-component.html component=default %}
51+
52+
53+
To clarify the current state, display the text value to the right of the toggle (ex. On or Off).
54+
55+
{% capture default %}
56+
<div class="fd-form__item fd-form__item--check">
57+
<label class="fd-form__label" for="y21YO3911">
58+
<span class="fd-toggle fd-form__control">
59+
<input type="checkbox" name="" value="" id="y21YO3911">
60+
<span class="fd-toggle__switch" role="presentation"></span>
61+
</span>
62+
Off
63+
</label>
64+
</div>
65+
{% endcapture %}
66+
{% include display-component.html component=default %}
67+
68+
69+
> **Note:** Use a checkbox instead:
70+
> - If it is not clear if the control is showing a state or action.
71+
> - If there are more than two options.
72+
73+
## Symantic Toggle
74+
`fd-toggle--semantic` modifier renders semnatic colors and icons inside the toggle switch
75+
76+
{% capture default %}
4377
<label>
4478
<span class="fd-toggle fd-toggle--semantic">
4579
<input type="checkbox" name="" value="" id="Enrat404">
@@ -54,7 +88,7 @@ In addition to the default option, there are two additional modifiers avialable:
5488

5589

5690
## Compact Mode
57-
`fd-toggle--compact` modifier can be used to render the compact size of the toggle `--label` and `--semantic` options are also avialable with the `compact` mode.
91+
`fd-toggle--compact` modifier can be used to render the compact size of the toggle
5892
{% capture default %}
5993
<label>
6094
<span class="fd-toggle fd-toggle--compact">
@@ -63,16 +97,6 @@ In addition to the default option, there are two additional modifiers avialable:
6397
</span>
6498
</label>
6599

66-
<label>
67-
<span class="fd-toggle fd-toggle--compact fd-toggle--label">
68-
<input type="checkbox" name="" value="" id="eKVll635">
69-
<span class="fd-toggle__switch" role="presentation">
70-
<span class="fd-toggle__label--on">ON</span>
71-
<span class="fd-toggle__label--off">OFF</span>
72-
</span>
73-
</span>
74-
</label>
75-
76100
<label>
77101
<span class="fd-toggle fd-toggle--compact fd-toggle--semantic">
78102
<input type="checkbox" name="" value="" id="Enrat404">
@@ -90,7 +114,7 @@ In addition to the default option, there are two additional modifiers avialable:
90114

91115
In addition to `default` and `--compact`, the toggle can be set to 3 sizes: `--xs`, `--s` and `--l`. When used with forms, it is recommended to use the small size so that form components will be consistent.
92116

93-
> Node: `--label` and `--semantic` modifiers are currently not supported by these optional sizes
117+
> Node: `--semantic` modifier is currently not supported by these optional sizes
94118
95119
{% capture default %}
96120
<div class="fd-form__item fd-form__item--check">

0 commit comments

Comments
 (0)