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 23 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.
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-sizes.png
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.
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.
Binary file modified src/pages/components/toggle/images/toggle-usage-variants.png
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.
30 changes: 28 additions & 2 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>Size</AnchorLink>
<AnchorLink>Feedback</AnchorLink>

</AnchorLinks>

## Color

| Element | Property | Color token |
Expand All @@ -30,6 +47,9 @@ tabs: ['Usage', 'Style', 'Code', 'Accessibility']

### Interactive states

The default and small toggle can be switched on and off across focus, disabled,
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 @@ -110,7 +130,7 @@ phrase and any proper nouns capitalized, and no more than three words.
Structure and spacing measurements for small toggle | px / rem
</Caption>

## Sizes
## Size

| Size | Height px / rem |
| ---------- | --------------- |
Expand All @@ -124,3 +144,9 @@ phrase and any proper nouns capitalized, and no more than three words.
</div>

<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).
105 changes: 87 additions & 18 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>Toggle being used in context of a product UI</Caption>

## Variants

| Variant | Purpose |
Expand All @@ -69,64 +80,122 @@ user “flips the switch”. They are commonly used for “on/off” switches.

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

## Formatting

### Anatomy

Default and small toggles are both comprised of a component label, a toggle button
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
and action text. Default toggles are required to display a component label and
action text unlike the small toggle where both these elements are optional. The
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
small toggle displays a checkmark tick in the on state to ensure the toggle is
still accessible when label and action text are unavailable.

<Row>
<Column colLg={8}>

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

</Column>
</Row>

<Caption>Anatomy of default and small toggle</Caption>

<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 /> D.
Checkmark tick (on state) <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.

#### 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.

#### 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 toggle has six states: on, off, focus, disabled, read-only
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
and skeleton. For more information on toggle states, see the
[Style tab](https://carbondesignsystem.com/components/toggle/style/).

| State | When to use |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| On | When a user clicks or uses the arrow keys to switch on the component. |
| Off | When a user clicks or uses the arrow keys to switch off the component. |
| 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

The Default toggle is larger in size than the small toggle. They are commonly
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
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
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
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)

</Column>
</Row>

<Caption>Example of toggle states</Caption>
<Caption>Example of a default toggle in context</Caption>

## 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 toggle is often used in condensed spaces and appear inline with other
components or content. The label and action text are optional for small toggle.

<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>

## 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
a checkmark tick in the on state to ensure the toggle is still accessible
without requiring visible label or action text. For example, inside
[data table](/components/data-table/usage) rows.

<Row>
<Column colLg={8}>
Expand Down
Loading