Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle doc updates #4214

Merged
merged 30 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
38b3274
toggle_us
alina-jacob-ibm Aug 23, 2024
8d68817
Merge branch 'main' into toggle_us
laurenmrice Aug 26, 2024
17b0098
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
3a53cbd
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
a7827c9
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
40db1a9
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
eda1bab
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
7120e96
Merge branch 'main' into toggle_us
laurenmrice Aug 26, 2024
9061d7c
Update src/pages/components/toggle/style.mdx
alina-jacob Aug 26, 2024
5470c4a
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
675ae85
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
f8142dc
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
cd90fab
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
bd67942
Update src/pages/components/toggle/style.mdx
alina-jacob Aug 26, 2024
b748dd2
Update src/pages/components/toggle/style.mdx
alina-jacob Aug 26, 2024
0b1d5de
Update src/pages/components/toggle/style.mdx
alina-jacob Aug 26, 2024
40cdd85
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
106b99c
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 26, 2024
e3c4a9b
update_!
alina-jacob-ibm Aug 27, 2024
13585b6
update_2
alina-jacob-ibm Aug 28, 2024
b86b481
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 28, 2024
2670e70
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 28, 2024
33f996e
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 28, 2024
2d9dbcb
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 29, 2024
b4c99c8
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 29, 2024
e9fa1d4
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 29, 2024
63fb4e7
Update src/pages/components/toggle/usage.mdx
alina-jacob Aug 29, 2024
27cd680
update_#
alina-jacob-ibm Aug 29, 2024
98800b6
update_4
alina-jacob-ibm Aug 29, 2024
e11c68b
update_5
alina-jacob-ibm Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/pages/components/toggle/images/toggle-style-color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/pages/components/toggle/images/toggle-style-states.png
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 31 additions & 5 deletions src/pages/components/toggle/style.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ description:
tabs: ['Usage', 'Style', 'Code', 'Accessibility']
---

<PageDescription>

The following page documents visual specifications such as color, typography,
structure, and size.

</PageDescription>

<AnchorLinks>

<AnchorLink>Color</AnchorLink>
<AnchorLink>Typography</AnchorLink>
<AnchorLink>Structure</AnchorLink>
<AnchorLink>Sizes</AnchorLink>
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
<AnchorLink>Feedback</AnchorLink>

</AnchorLinks>

## Color

| Element | Property | Color token |
Expand All @@ -26,10 +43,13 @@ tabs: ['Usage', 'Style', 'Code', 'Accessibility']
</Column>
</Row>

<Caption>On and off toggle states</Caption>
<Caption>On and off toggle states.</Caption>
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

### Interactive states

The Default and Small toggle can be switched on and off across focus, disabled
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
and read-only states.

| State | Element | Property | Color token |
| --------- | ----------- | ---------------- | ------------------------- |
| Focus | Toggle | border | `$focus` |
Expand Down Expand Up @@ -57,7 +77,7 @@ tabs: ['Usage', 'Style', 'Code', 'Accessibility']
</Column>
</Row>

<Caption>Interactive toggle states</Caption>
<Caption>Interactive toggle states.</Caption>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Caption>Interactive toggle states.</Caption>
<Caption>Interactive toggle states</Caption>


## Typography

Expand Down Expand Up @@ -88,7 +108,7 @@ phrase and any proper nouns capitalized, and no more than three words.
</div>

<Caption>
Structure and spacing measurements for default toggle | px / rem
Structure and spacing measurements for default toggle. | px / rem
</Caption>

### Small toggle
Expand All @@ -107,7 +127,7 @@ phrase and any proper nouns capitalized, and no more than three words.
</div>

alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
<Caption>
Structure and spacing measurements for small toggle | px / rem
Structure and spacing measurements for small toggle. | px / rem
</Caption>

## Sizes
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -123,4 +143,10 @@ phrase and any proper nouns capitalized, and no more than three words.

</div>

<Caption>Toggle sizes | px / rem</Caption>
<Caption>Toggle sizes. | px / rem</Caption>

## Feedback

Help us improve this component by providing feedback, asking questions, and
leaving any other comments on
[GitHub](https://github.com/carbon-design-system/carbon-website/issues/new?assignees=&labels=feedback&template=feedback.md).
107 changes: 86 additions & 21 deletions src/pages/components/toggle/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ commonly used for “on/off” switches.

<AnchorLink>Live demo</AnchorLink>
<AnchorLink>Overview</AnchorLink>
<AnchorLink>Formatting</AnchorLink>
<AnchorLink>Content</AnchorLink>
<AnchorLink>Behaviors</AnchorLink>
<AnchorLink>Default toggle</AnchorLink>
Expand Down Expand Up @@ -52,6 +53,16 @@ Toggle is a control that is used to quickly switch between two possible states.
Toggles are only used for these binary actions that occur immediately after the
user “flips the switch”. They are commonly used for “on/off” switches.

<Row>
<Column colLg={8}>

![Toggle being used in context of a product UI.](images/toggle_usage_overview.png)
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

</Column>
</Row>

<Caption>Tags being used in context of a product UI.</Caption>
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

## Variants

| Variant | Purpose |
Expand All @@ -67,76 +78,130 @@ user “flips the switch”. They are commonly used for “on/off” switches.
</Column>
</Row>

<Caption>Default and small toggle variants</Caption>
<Caption>Default and small toggle variants.</Caption>

## Formatting

### Anatomy

Default and small toggle both comprise of a component label, the toggle button
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
and an action text. Default toggles are required to display component label and
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
action text unlike the small toggle where both these elements are optional.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
action text unlike the small toggle where both these elements are optional.
action text, unlike the small toggle, where both these elements are optional.


<Row>
<Column colLg={8}>

![Anatomy of Default and small toggle variants](images/toggle-usage-anatomy.png)
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved

</Column>
</Row>

<Caption>Anatomy of Default and Small toggle.</Caption>
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

<Row>
<Column colSm={2} colMd={4} colLg={4}>

#### 1. Default toggle

A. Label <br /> B. Toggle <br /> C. Action text <br />

</Column>
<Column colSm={2} colMd={4} colLg={4}>

#### 2. Small toggle

A. Label (optional) <br /> B. Toggle <br /> C. Action text (optional) <br />

</Column>
</Row>

## Content

#### Label text

Label text must accompany a toggle to further clarify the action that the toggle
performs.
performs. Label text is optional for Small toggle.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

#### Action text

Use text to describe the binary action of toggle so that the action is clear.
Action text must be three words or less and is displayed on the side of a
toggle.
toggle. Action text is optional for Small toggle.
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved

#### Language

Use adjectives rather than verbs to describe actions and the state of the object
affected.

### Further guidance

For further content guidance, see Carbon’s
[content guidelines](https://carbondesignsystem.com/guidelines/content/overview/).

## Behaviors

### States

Toggles have six states: on, off, focus, disabled, skeleton, and read-only.
The Default and Small toggles have six states: on, off, focus, disabled,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Default and Small toggles have six states: on, off, focus, disabled,
The Default and Small toggles have six states: **on**, **off**, **focus**, **disabled**,

We typically semibold each state here. If you were referencing the Tag usage tab for this, that one is kind of different than how we normally do this because the different variants also have different states so it was structured a little differently.

read-only and skeleton. For more information on toggle states, see the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
read-only and skeleton. For more information on toggle states, see the
**read-only** and **skeleton**. For more information on toggle states, see the

[style tab](https://carbondesignsystem.com/components/toggle/style/).
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved

| State | When to use |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| On | When a user clicks or uses the arrows keys to switch on the component. |
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
| Off | When a user clicks or uses the arrows keys to switch off the component. |
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
| Focus | When a user presses tab or clicks on the toggle, it becomes focused, indicating the user has successfully navigated to the component. |
| Disabled | When a user is not allowed to interact with the toggle due to either permissions, dependencies, or pre-requisites. The disabled state completely removes the interactive function from a component. The styling is not subject to WCAG contrast compliance. |
| Read-only | When the user can review but not modify the component. This state removes all interactive functions like the disabled state but can still be focusable, accessible by screen readers, and passes visual contrast for readability. |
| Skeleton | Use on an initial page load to indicate that the toggle has not yet fully loaded. |

## Default toggle

Default toggles are larger in size than Small toggles. They are commonly used in
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved
forms and can appear within full pages of information that are not restricted in
space. Default toggles are required to display visible label and action text.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
space. Default toggles are required to display visible label and action text.
space. Default toggles are required to display a visible label and action text.


<Row>
<Column colLg={8}>

![Default and small toggle variants](images/toggle-usage-states.png)
![Example of a Default toggle in context](images/toggle-usage-default.png)
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved

</Column>
</Row>

<Caption>Example of toggle states</Caption>
<Caption>Example of a Default toggle in context.</Caption>
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved

## Default toggle
## Small toggle

Default toggles are larger in size than small toggles. They are commonly used in
forms and can appear within full pages of information that are not restricted in
space. Default toggles are required to display visible label and action text.
Small toggles are often used in condensed spaces and appear inline with other
components or content. The label and action text is optional for Small toggle.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

<Row>
<Column colLg={8}>

![Example of a default toggle in context](images/toggle-usage-default.png)
![Example of a small toggle with action text in context](images/toggle-usage-small-with-action-text.png)

</Column>
</Row>

<Caption>Example of a default toggle in context</Caption>
<Caption>Example of a Small toggle with action text in context.</Caption>
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved

## Small toggle
<br />

Small toggles are often used in condensed spaces and appear inline with other
components or content, for example, inside
[data table](/components/data-table/usage) rows. Unlike the default toggle, the
small toggle is more compact in size and displays a checkmark tick in the on
state to ensure the toggle is still accessible without requiring visible label
or action text.
Unlike the Default toggle, the Small toggle is more compact in size and displays
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved
a checkmark tick in the on state to ensure the toggle is still accessible
without requiring visible label or action text. for example, inside
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
without requiring visible label or action text. for example, inside
without requiring a visible label or action text, for example, inside

alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
[data table](/components/data-table/usage) rows.

<Row>
<Column colLg={8}>

![Example of a small toggle in context](images/toggle-usage-small.png)
![Example of a Small toggle in context](images/toggle-usage-small.png)
laurenmrice marked this conversation as resolved.
Show resolved Hide resolved

</Column>
</Row>

<Caption>Example of a small toggle in context</Caption>
<Caption>Example of a Small toggle in context.</Caption>
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

## Feedback

Expand Down
Loading