[Switch] Add role="switch" by ZeeshanTamboli · Pull Request #46482 · mui/material-ui (original) (raw)

Skip to content

Sign in

Appearance settings

View all features

View all solutions

View all resources

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Sign in

Sign up

Appearance settings

mui / material-ui Public

Additional navigation options

Merged

ZeeshanTamboli

merged 3 commits into

mui:masterfrom

ZeeshanTamboli:issue-23216-add-role-switch

Jul 4, 2025

ConversationCommits (3)ChecksFiles changed

Merged

[Switch] Add role="switch"#46482

ZeeshanTamboli

merged 3 commits into

mui:masterfrom

ZeeshanTamboli:issue-23216-add-role-switch

Conversation

@ZeeshanTamboli

@ZeeshanTamboli ZeeshanTamboli commented

Jul 3, 2025

Copy link Copy Markdown

Member

Closes #23216

Adds role="switch" to the input element to improve accessibility.

Tested with NVDA—now announces "on/off" instead of "checked/unchecked".

oliviertassinari reacted with eyes emoji

ZeeshanTamboli added 2 commits

July 3, 2025 18:43

@ZeeshanTamboli

[Add role switch to Switch component](/mui/material-ui/pull/46482/commits/0bc7854bfb21a4f1ed69ff5fd35ad1941b1833a4 "Add role switch to Switch component")

[0bc7854](/mui/material-ui/pull/46482/commits/0bc7854bfb21a4f1ed69ff5fd35ad1941b1833a4)

@ZeeshanTamboli

[update docs](/mui/material-ui/pull/46482/commits/4f42a8f3a73b366d550f9f354a70db184dff4de8 "update docs")

[4f42a8f](/mui/material-ui/pull/46482/commits/4f42a8f3a73b366d550f9f354a70db184dff4de8)

@ZeeshanTamboli ZeeshanTamboli added accessibility

a11y

scope: switch

Changes related to the switch.

labels

Jul 3, 2025

@mui-bot

mui-bot commented

Jul 3, 2025

edited

Loading

Copy link Copy Markdown

Netlify deploy preview

Bundle size report

Bundle Parsed Size Gzip Size
@mui/material 🔺+22B(0.00%) 🔺+10B(+0.01%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against c2b4f83

@ZeeshanTamboli

[make tests pass](/mui/material-ui/pull/46482/commits/c2b4f83ff1966ddb2c6393d6a27cee27a4379729 "make tests pass")

[c2b4f83](/mui/material-ui/pull/46482/commits/c2b4f83ff1966ddb2c6393d6a27cee27a4379729)

@ZeeshanTamboli ZeeshanTamboli mentioned this pull request

Jul 3, 2025

[Switch][Checkbox][Radio] Remove aria-disabled from root span#46318

Merged

1 task

@ZeeshanTamboli ZeeshanTamboli requested review fromsai6855 and siriwatknp

July 3, 2025 14:51

sai6855

sai6855 approved these changes Jul 4, 2025

View reviewed changes

@ZeeshanTamboli ZeeshanTamboli merged commit 04b87f3 into mui:master

Jul 4, 2025

23 checks passed

@ZeeshanTamboli ZeeshanTamboli deleted the issue-23216-add-role-switch branch

July 4, 2025 13:43

yafeng-c pushed a commit to yafeng-c/material-ui that referenced this pull request

Jul 5, 2025

@ZeeshanTamboli @yafeng-c

`[fix and remove redundant tests](/yafeng-c/material-ui/commit/8744a1288e26d488d5c7e058f487881559f0e22b "fix and remove redundant tests

[Switch] Add role="switch" (#46482)

fix again

update new tests") `

[8744a12](/yafeng-c/material-ui/commit/8744a1288e26d488d5c7e058f487881559f0e22b)

[Switch] Add role="switch" (mui#46482)

fix again

update new tests

@oliviertassinari

oliviertassinari commented

Aug 10, 2025

edited

Loading

Copy link Copy Markdown

Member

To note that this change breaks tests like:

screen.getByRole('checkbox', { name: 'Pivot' });

https://github.com/mui/mui-x/blob/0a432d357613b0785c32aacf9414fa2cbf240d3b/packages/x-data-grid-premium/src/tests/pivoting.DataGridPremium.test.tsx#L163

that depends on being a specific role.

zettca reacted with thumbs up emoji

@ZeeshanTamboli ZeeshanTamboli mentioned this pull request

May 4, 2026

[switch] Fix incorrect role with slotProps.input #48469

Merged

1 task

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

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

Reviewers

@sai6855 sai6855 sai6855 approved these changes

@siriwatknp siriwatknp Awaiting requested review from siriwatknp

Assignees

No one assigned

Labels

accessibility

a11y

scope: switch

Changes related to the switch.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Switch] Use role="switch"

4 participants

@ZeeshanTamboli @mui-bot @oliviertassinari @sai6855