Aria button
Author: v | 2025-04-24
Here are some commonly used aria-labels aria-label: This attribute is used to provide a label for an element. For example, you might use aria-label=Search to describe a search button. button aria-label= Search Search /button !- Button with aria-label for accessibility - aria-labelled by: button aria-label= Search Search /button !- Button with aria-label for accessibility - aria-labelled by: This attribute is used to reference another element on the
The button role - ARIA Reference Guide - ARIA roles
GetByRole('tab', { selected: true }).To learn more about the selected state and which elements can have this statesee ARIA aria-selected.busyYou can filter the returned elements by their busy state by setting busy: trueor busy: false.For example inbody> section> div role="alert" aria-busy="false">Login faileddiv> div role="alert" aria-busy="true">Error: Loading message...div> section>body>you can get the "Login failed" alert by callinggetByRole('alert', { busy: false }). To learn more about the busy state seeARIA aria-busy andMDN aria-busy attribute.checkedYou can filter the returned elements by their checked state by settingchecked: true or checked: false.For example inbody> section> button role="checkbox" aria-checked="true">Sugarbutton> button role="checkbox" aria-checked="false">Gummy bearsbutton> button role="checkbox" aria-checked="false">Whipped creambutton> section>body>you can get the "Sugar" option by callinggetByRole('checkbox', { checked: true }). To learn more about the checkedstate and which elements can have this state seeARIA aria-checked.NoteCheckboxes have a "mixed" state, which is considered neither checked norunchecked (details here).currentYou can filter the returned elements by their current state by settingcurrent: boolean | string. Note that no aria-current attribute will matchcurrent: false since false is the default value for aria-current.For example inbody> nav> a href="current/page" aria-current="page">👍a> a href="another/page">👎a> nav>body>you can get the "👍" link by calling getByRole('link', { current: 'page' })and the "👎" by calling getByRole('link', { current: false }). To learn moreabout the current state seeARIA aria-current.pressedButtons can have a pressed state. You can filter the returned elements by theirpressed state by setting pressed: true or pressed: false.For example inbody> section> button aria-pressed="true">👍button> button aria-pressed="false">👎button> section>body>you can get the "👍" button by calling getByRole('button', { pressed: true }).To learn Here are some commonly used aria-labels aria-label: This attribute is used to provide a label for an element. For example, you might use aria-label=Search to describe a search button. button aria-label= Search Search /button !- Button with aria-label for accessibility - aria-labelled by: Heading level using the level optiongetByRole('heading', { level: 2 }).The level option queries the element(s) with the heading role matching theindicated level determined by the semantic HTML heading elements - ormatching the aria-level attribute.Given the example below,body> section> h1>Heading Level Oneh1> h2>First Heading Level Twoh2> h3>Heading Level Threeh3> div role="heading" aria-level="2">Second Heading Level Twodiv> section>body>you can query the Heading Level Three heading usinggetByRole('heading', { level: 3 }).getByRole('heading', {level: 1})// Heading Level OnegetAllByRole('heading', {level: 2})// [// First Heading Level Two,// Second Heading Level Two// ]While it is possible to explicitly set role="heading" and aria-levelattribute on an element, it is strongly encouraged to use the semantic HTMLheadings -.To learn more about the aria-level property, seeARIA aria-level.The level option is only applicable to the heading role. An error willbe thrown when used with any other role.valueA range widget can be queried by any value getByRole('spinbutton') or by aspecific value using the level optiongetByRole('spinbutton', { value: { now: 5, min: 0, max: 10, text: 'medium' } }).Note that you don't have to specify all properties in value. A subset issufficient e.g.getByRole('spinbutton', { value: { now: 5, text: 'medium' } }).Given the example below,body> section> button role="spinbutton" aria-valuenow="5" aria-valuemin="0" aria-valuemax="10" aria-valuetext="medium" > Volume button> button role="spinbutton" aria-valuenow="3" aria-valuemin="0" aria-valuemax="10" aria-valuetext="medium" > Pitch button> section>body>you can query specific spinbutton(s) with the following queries,getByRole('spinbutton', {value: {now: 5}})// VolumegetAllByRole('spinbutton', {value: {min: 0}})// [// Volume,// Pitch// ]Every specified property in value must match. For example, if you query for{value: {min: 0, now: 3}} aria-valuemin must be equal to 0Comments
GetByRole('tab', { selected: true }).To learn more about the selected state and which elements can have this statesee ARIA aria-selected.busyYou can filter the returned elements by their busy state by setting busy: trueor busy: false.For example inbody> section> div role="alert" aria-busy="false">Login faileddiv> div role="alert" aria-busy="true">Error: Loading message...div> section>body>you can get the "Login failed" alert by callinggetByRole('alert', { busy: false }). To learn more about the busy state seeARIA aria-busy andMDN aria-busy attribute.checkedYou can filter the returned elements by their checked state by settingchecked: true or checked: false.For example inbody> section> button role="checkbox" aria-checked="true">Sugarbutton> button role="checkbox" aria-checked="false">Gummy bearsbutton> button role="checkbox" aria-checked="false">Whipped creambutton> section>body>you can get the "Sugar" option by callinggetByRole('checkbox', { checked: true }). To learn more about the checkedstate and which elements can have this state seeARIA aria-checked.NoteCheckboxes have a "mixed" state, which is considered neither checked norunchecked (details here).currentYou can filter the returned elements by their current state by settingcurrent: boolean | string. Note that no aria-current attribute will matchcurrent: false since false is the default value for aria-current.For example inbody> nav> a href="current/page" aria-current="page">👍a> a href="another/page">👎a> nav>body>you can get the "👍" link by calling getByRole('link', { current: 'page' })and the "👎" by calling getByRole('link', { current: false }). To learn moreabout the current state seeARIA aria-current.pressedButtons can have a pressed state. You can filter the returned elements by theirpressed state by setting pressed: true or pressed: false.For example inbody> section> button aria-pressed="true">👍button> button aria-pressed="false">👎button> section>body>you can get the "👍" button by calling getByRole('button', { pressed: true }).To learn
2025-03-28Heading level using the level optiongetByRole('heading', { level: 2 }).The level option queries the element(s) with the heading role matching theindicated level determined by the semantic HTML heading elements - ormatching the aria-level attribute.Given the example below,body> section> h1>Heading Level Oneh1> h2>First Heading Level Twoh2> h3>Heading Level Threeh3> div role="heading" aria-level="2">Second Heading Level Twodiv> section>body>you can query the Heading Level Three heading usinggetByRole('heading', { level: 3 }).getByRole('heading', {level: 1})// Heading Level OnegetAllByRole('heading', {level: 2})// [// First Heading Level Two,// Second Heading Level Two// ]While it is possible to explicitly set role="heading" and aria-levelattribute on an element, it is strongly encouraged to use the semantic HTMLheadings -.To learn more about the aria-level property, seeARIA aria-level.The level option is only applicable to the heading role. An error willbe thrown when used with any other role.valueA range widget can be queried by any value getByRole('spinbutton') or by aspecific value using the level optiongetByRole('spinbutton', { value: { now: 5, min: 0, max: 10, text: 'medium' } }).Note that you don't have to specify all properties in value. A subset issufficient e.g.getByRole('spinbutton', { value: { now: 5, text: 'medium' } }).Given the example below,body> section> button role="spinbutton" aria-valuenow="5" aria-valuemin="0" aria-valuemax="10" aria-valuetext="medium" > Volume button> button role="spinbutton" aria-valuenow="3" aria-valuemin="0" aria-valuemax="10" aria-valuetext="medium" > Pitch button> section>body>you can query specific spinbutton(s) with the following queries,getByRole('spinbutton', {value: {now: 5}})// VolumegetAllByRole('spinbutton', {value: {min: 0}})// [// Volume,// Pitch// ]Every specified property in value must match. For example, if you query for{value: {min: 0, now: 3}} aria-valuemin must be equal to 0
2025-03-28Key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Trending topics Spotlight\r\n"}}" id="subnav-highlights-wrapper-1" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Spotlight Services\r\n"}}" id="subnav-intro-title-2" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Services EY helps clients create long-term value for all stakeholders. Enabled by data and technology, our services and solutions provide trust through assurance and help clients transform, grow and operate.\r\n"}}" id="subnav-intro-description-2" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> EY helps clients create long-term value for all stakeholders. Enabled by data and technology, our services and solutions provide trust through assurance and help clients transform, grow and operate. Spotlight\r\n"}}" id="subnav-highlights-wrapper-2" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Spotlight Industries\r\n"}}" id="subnav-intro-title-3" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Industries Discover how EY insights and services are helping to reframe the future of your industry.\r\n\r\n"}}" id="subnav-intro-description-3" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less
2025-04-15About this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Spotlight Industries\r\n"}}" id="subnav-intro-title-3" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Industries Discover how EY insights and services are helping to reframe the future of your industry.\r\n\r\n"}}" id="subnav-intro-description-3" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Discover how EY insights and services are helping to reframe the future of your industry. Case studies\r\n"}}" id="subnav-highlights-wrapper-3" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Case studies Careers\r\n"}}" id="subnav-intro-title-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Careers We bring together extraordinary people, like you, to build a better working world.\r\n"}}" id="subnav-intro-description-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> We bring together extraordinary people, like you, to build a better working world. Spotlight\r\n"}}" id="subnav-highlights-wrapper-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Spotlight About us\r\n"}}" id="subnav-intro-title-5" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> About us At EY, our purpose is building a better working world. The insights and services we provide help to create long-term value for clients, people and society, and to build trust in the capital markets.\r\n"}}" id="subnav-intro-description-5" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about
2025-04-02Button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Discover how EY insights and services are helping to reframe the future of your industry. Case studies\r\n"}}" id="subnav-highlights-wrapper-3" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Case studies Careers\r\n"}}" id="subnav-intro-title-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Careers We bring together extraordinary people, like you, to build a better working world.\r\n"}}" id="subnav-intro-description-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> We bring together extraordinary people, like you, to build a better working world. Spotlight\r\n"}}" id="subnav-highlights-wrapper-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Spotlight About us\r\n"}}" id="subnav-intro-title-5" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> About us At EY, our purpose is building a better working world. The insights and services we provide help to create long-term value for clients, people and society, and to build trust in the capital markets.\r\n"}}" id="subnav-intro-description-5" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate,
2025-04-19Content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Discover how EY insights and services are helping to reframe the future of your industry. Case studies\r\n"}}" id="subnav-highlights-wrapper-3" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Case studies Careers\r\n"}}" id="subnav-intro-title-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Careers We bring together extraordinary people, like you, to build a better working world.\r\n"}}" id="subnav-intro-description-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> We bring together extraordinary people, like you, to build a better working world. Spotlight\r\n"}}" id="subnav-highlights-wrapper-4" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read more button, press enter to activate, or use Up arrow key to learn more about this content" data-up-translation-aria-label-read-less="Read less button, press enter to activate, or use Up arrow key to learn more about this content" data-up-analytics="rich-text"> Spotlight About us\r\n"}}" id="subnav-intro-title-5" data-up-is="rich-text" data-up-translation-read-more="Read More" data-up-translation-read-less="Read Less" data-up-translation-aria-label-read-more="Read
2025-04-22