Skip to content

Conversation

@wemmyo
Copy link
Contributor

@wemmyo wemmyo commented Dec 15, 2025

Closes #3840

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

🦋 Changeset detected

Latest commit: 567fb33

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@salt-ds/core Patch
@salt-ds/countries Patch
@salt-ds/data-grid Patch
@salt-ds/embla-carousel Patch
@salt-ds/lab Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
saltdesignsystem Ready Ready Preview, Comment Dec 17, 2025 1:29pm

border: 0;
}

.salt-density-high .saltSwitch-readOnly .saltSwitch-thumb {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume it's to do with sizing, could you check with the designers if what is there meets the expected outcome please

Copy link
Contributor

Choose a reason for hiding this comment

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

Figma doesn't have a stroke on the switch thumb in all the densities. Read-only states look correct though.

@wemmyo wemmyo marked this pull request as ready for review December 16, 2025 11:53

## Best Practice

Ideally we shouln't use readOnly
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to talk more about why we shouldn't? We included a note in the example section, wondering if we should move it here? @karlgoldstraw

Copy link
Contributor

Choose a reason for hiding this comment

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

@wemmyo I was walking Karl through how to edit the docs. I believe he might add more information to this but I'll take a look as well. Also, I did make a slight change to the read only note and tried to align it with what we are using elsewhere (Checkbox for example). Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah sounds good thanks!

A read-only switch allows the user to select and copy its text, but does not allow them to change its state. You can set a switch as read-only via the prop `readOnly`.

**Note:** We recommend avoiding read-only switches due to the lack of adequate `aria-readonly` support and conflicting user expectations. If you must use a read-only switch, you can add visual or non-visual labels to make its state clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copying and pasting a label does not seem to be of that much value but that's how we are selling read-only.

What is more valuable is a focusable control being announced by the screen reader, whilst a disabled control cannot be focused and so will not be seen by the screenreader.

  • Lack of adequate support for aria-readonly, we are not clear enough hereon the impact, I guess you browser and screenreader combination.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe generally we're not trying to sell the readonly switch because of it's limitations including limited support for screen readers, but it's something we have just to be consistent with similar components. Guidance here is similar to what we have for checkbox but @karlgoldstraw and @jake-costa can help expand on that

Unlike disabled switches, read-only switches are focusable and shown in the tab order when using a keyboard, allowing users to interact with its text. Use a read-only switch when its text contains information that is valuable to the user.

<LivePreview componentName="switch" exampleName="Readonly" />

Copy link
Contributor

Choose a reason for hiding this comment

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

No guidance currently on the accessibility tab.
Feels like accessibility info is on this page instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From @jake-costa's comment earlier @karlgoldstraw might be adding more here but we thought the note in the examples section might be beneficial. We can move it to the accessibility tab if that's better

Copy link
Contributor

Choose a reason for hiding this comment

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

@wemmyo @mark-tate In addition, we have this kind of language on other read only examples (checkbox, radio, etc.)


it("THEN should not toggle when pressing the Space key", () => {
cy.mount(<Switch readOnly />);
cy.findByRole("switch").should("not.be.checked");
Copy link
Contributor

Choose a reason for hiding this comment

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

no test of focus but it's something we call out as a differentiator between disabled?

Copy link
Contributor

Choose a reason for hiding this comment

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

read-only attribute as well ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point thanks, I've included them in the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a read-only state to Switch

7 participants