{
    "componentChunkName": "component---src-templates-post-js",
    "path": "/web-accessibility-a11y-using-reactjs/",
    "result": {"data":{"markdownRemark":{"html":"<h1 id=\"achieving-accessibility-in-react-applications\" style=\"position:relative;\"><a href=\"#achieving-accessibility-in-react-applications\" aria-label=\"achieving accessibility in react applications permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Achieving Accessibility in React Applications</h1>\n<p>a11y stands for <code class=\"language-text\">ACCESSIBILITY</code>\nThe phrase '11 characters'. Arrows are pointing to the first letter c and the letter t in the word 'accessibility' to show how the numeronym is formed.\nThe A11Y Project is a community-driven effort to make digital accessibility easier.</p>\n<h3 id=\"what-is-accessibility\" style=\"position:relative;\"><a href=\"#what-is-accessibility\" aria-label=\"what is accessibility permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is accessibility?</h3>\n<p>This article starts off the module with a good look at what accessibility actually is — this includes what groups of people we need to consider and why, what tools different people use to interact with the Web, and how we can make accessibility part of our web development workflow.</p>\n<h3 id=\"html-a-good-basis-for-accessibility\" style=\"position:relative;\"><a href=\"#html-a-good-basis-for-accessibility\" aria-label=\"html a good basis for accessibility permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>HTML: A good basis for accessibility</h3>\n<p>A great deal of web content can be made accessible just by making sure that the correct HTML elements are used for the correct purpose at all times. This article looks in detail at how HTML can be used to ensure maximum accessibility.</p>\n<h3 id=\"css-and-javascript-accessibility-best-practices\" style=\"position:relative;\"><a href=\"#css-and-javascript-accessibility-best-practices\" aria-label=\"css and javascript accessibility best practices permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>CSS and JavaScript accessibility best practices</h3>\n<p>CSS and JavaScript, when used properly, also have the potential to allow for accessible web experiences. They can significantly harm accessibility if misused. This article outlines some CSS and JavaScript best practices that should be considered to ensure that even complex content is as accessible as possible.</p>\n<h3 id=\"wai-aria-basics\" style=\"position:relative;\"><a href=\"#wai-aria-basics\" aria-label=\"wai aria basics permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>WAI-ARIA basics</h3>\n<p>Following on from the previous article, sometimes making complex UI controls that involve unsemantic HTML and dynamic JavaScript-updated content can be difficult. WAI-ARIA is a technology that can help with such problems by adding in further semantics that browsers and assistive technologies can recognize and let users know what is going on. Here we'll show how to use it at a basic level to improve accessibility.</p>\n<h3 id=\"accessible-multimedia\" style=\"position:relative;\"><a href=\"#accessible-multimedia\" aria-label=\"accessible multimedia permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Accessible multimedia</h3>\n<p>Another category of content that can create accessibility problems is multimedia — video, audio, and image content need to be given proper textual alternatives so that they can be understood by assistive technologies and their users. This article shows how.</p>\n<h3 id=\"mobile-accessibility\" style=\"position:relative;\"><a href=\"#mobile-accessibility\" aria-label=\"mobile accessibility permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Mobile accessibility</h3>\n<p>With web access on mobile devices being so popular and popular platforms such as iOS and Android having fully-fledged accessibility tools, it is important to consider the accessibility of your web content on these platforms. This article looks at mobile-specific accessibility considerations.</p>\n<h1 id=\"what-is-web-accessibility-a11y\" style=\"position:relative;\"><a href=\"#what-is-web-accessibility-a11y\" aria-label=\"what is web accessibility a11y permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Web Accessibility (A11y)</h1>\n<p>Web Accessibility is the design of pages, tools and technologies on the web that can be used by everyone. Everyone here includes people with auditory, cognitive, neurological, physical, speech and visual disabilities. Accessibility support is necessary to allow assistive technology to interpret web pages and applications.</p>\n<p>A11y is a numero-nym that stands for <em>accessibility</em> as “a\" followed by 11 more letters, followed by “y\". Web development with accessibility in mind, ensures total inclusion of the entire population that use the web.</p>\n<h1 id=\"why-web-accessibility\" style=\"position:relative;\"><a href=\"#why-web-accessibility\" aria-label=\"why web accessibility permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Web Accessibility</h1>\n<p>Web Accessibility as a feature has been seen as a very wrong way of design thinking because by default it excludes a large number of web users. People who cannot see or for some reason cannot use a trackpad or a mouse pointer for instance should have as much rights and access as people who can. Inclusive design starts by thinking about every web user equally, this would easily make you see web accessibility as a must and not a feature. Web accessibility also benefits people without disabilities, these people may include:</p>\n<ul>\n<li>people using mobile phones, smart watches, smart TVs, and other devices with small screens, different input modes, etc.</li>\n<li>older people with changing abilities due to ageing.</li>\n<li>people with “temporary disabilities\" such as a broken arm or lost glasses</li>\n<li>people with “situational limitations\" such as in bright sunlight or in an environment where they cannot listen to audio</li>\n<li>people using a slow Internet connection, or who have limited or expensive bandwidth</li>\n</ul>\n<h1 id=\"accessibility-standards-and-guidelines\" style=\"position:relative;\"><a href=\"#accessibility-standards-and-guidelines\" aria-label=\"accessibility standards and guidelines permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Accessibility Standards and Guidelines</h1>\n<p>These are guidelines that govern how accessibility is achieved while building for and using the web. These ensure that there is support for screen readers, keyboard usability and captions for photos. Some of them are:</p>\n<p>WCAG: The <a href=\"https://www.w3.org/WAI/intro/wcag\">Web Content Accessibility Guidelines</a> provides guidelines for creating accessible web sites. WCAG is developed through the W3C process in cooperation with individuals and organisations around the world, with a goal of providing a single shared standard for web content accessibility that meets the needs of individuals, organisations, and governments internationally.</p>\n<p>WAI-ARIA: The <a href=\"https://www.w3.org/WAI/intro/aria\">Web Accessibility Initiative — Accessible Rich Internet Applications</a> document contains techniques for building fully accessible JavaScript widgets. It especially helps with dynamic content and advanced user interface controls developed with Ajax, HTML, JavaScript, and related technologies like React.</p>\n<h1 id=\"barrier-to-building-accessible-js-framework-apps\" style=\"position:relative;\"><a href=\"#barrier-to-building-accessible-js-framework-apps\" aria-label=\"barrier to building accessible js framework apps permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Barrier to Building Accessible JS Framework Apps..</h1>\n<p>I would argue that the most dominant issue we have when trying to build accessible apps is caused by <em>developers writing non-semantic code</em>. Using JSX in inefficient ways that when compiled, the code would not be exactly semantic HTML. And we know that whenever there is non semantic HTML, assistive technologies like screen readers find it difficult to parse the content as it was intended. This process ends up in making the apps non-accessible.</p>\n<ol>\n<li>Casing and Reserved Words</li>\n</ol>\n<p>=================================</p>\n<p>Writing semantic HTML in your React components would require that you pay attention to casing of attributes. In react, most HTML attributes are written in camel case.</p>\n<p>maxlength becomes maxLengthtabindex becomes tabIndexcontenteditable becomes contentEditable</p>\n<p>However, all <code class=\"language-text\">aria-*</code> HTML attributes are fully supported in JSX these attributes should be hyphen-cased kebab-cased as they are in plain HTML:</p>\n<p>aria-label={labelText}<br>\naria-required=\"true\"</p>\n<p>For reserved words, we have that some reserved words mean entirely different things in HTML and in javascript words like class and for are practical examples, so in React we change them like thus:</p>\n<p>for becomes htmlForclass becomes className</p>\n<ol start=\"2\">\n<li>Setting Page Titles</li>\n</ol>\n<p>===========================</p>\n<p>Setting the page title is another very powerful step to making your react application very accessible. It is actually crucial for screen readers, the page title is the first thing screen readers announce. It updates the content currently showing in the browser tab helping to announce exactly where the users (who might depend on screen readers) are in your application. It is also really great for search engine optimisation. It is done like this:</p>\n<p>componentDidMount() {  document.title = “this is the page title\";}</p>\n<p>There is also a plugin you can use instead, <a href=\"https://github.com/nfl/react-helmet\">react-helmet</a> where you essentially handle head tags per page/component. This can be done like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">\"react\"</span><span class=\"token punctuation\">;</span>  \n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span>Helmet<span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">\"react-helmet\"</span><span class=\"token punctuation\">;</span>  \n  \n<span class=\"token keyword\">class</span> <span class=\"token class-name\">Application</span> <span class=\"token keyword\">extends</span> <span class=\"token class-name\">React<span class=\"token punctuation\">.</span>Component</span> <span class=\"token punctuation\">{</span>  \n  <span class=\"token function\">render</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n    <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>  \n        <span class=\"token operator\">&lt;</span>div className<span class=\"token operator\">=</span><span class=\"token string\">\"application\"</span><span class=\"token operator\">></span>  \n            <span class=\"token operator\">&lt;</span>Helmet<span class=\"token operator\">></span>  \n                <span class=\"token operator\">&lt;</span>meta charSet<span class=\"token operator\">=</span><span class=\"token string\">\"utf-8\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>  \n                <span class=\"token operator\">&lt;</span>title<span class=\"token operator\">></span>My Title<span class=\"token operator\">&lt;</span><span class=\"token operator\">/</span>title<span class=\"token operator\">></span>  \n                <span class=\"token operator\">&lt;</span>link rel<span class=\"token operator\">=</span><span class=\"token string\">\"canonical\"</span> href<span class=\"token operator\">=</span><span class=\"token string\">\"http://mysite.com/example\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>  \n            <span class=\"token operator\">&lt;</span><span class=\"token operator\">/</span>Helmet<span class=\"token operator\">></span>  \n            <span class=\"token operator\">...</span>  \n        <span class=\"token operator\">&lt;</span><span class=\"token operator\">/</span>div<span class=\"token operator\">></span>  \n    <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n  <span class=\"token punctuation\">}</span>  \n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span></code></pre></div>\n<ol start=\"3\">\n<li>Write Semantic HTML</li>\n</ol>\n<p>=======================</p>\n<p>To ensure that every code block of yours is going to be accessible, write good HTML code. We all make the quick button mistake:</p>\n<div onClick={this.onClick}  className=\"button\">   <span>Click on me</span></div>\n<p>This would render a button, but it is not an accessible HTML button, a screen reader would not be able to interpret this. A more accessible and semantic code that does the same thing is this:</p>\n<p><button onClick={this.onClick}>  Click on me</button></p>\n<ol start=\"4\">\n<li>Never Forget the text Alt of any content</li>\n</ol>\n<p>================================================</p>\n<p>This is very important for every non-text content. Text is the most optimal format for any content, so make sure to add text alternatives. For images, use the alt:</p>\n<img src=\"apple.png\" alt=\" A big picture of an Apple \" />\n<blockquote>\n<p>All non-text content that is presented to the user has a text alternative that serves the equivalent purpose — Ire Aderinokun</p>\n</blockquote>\n<p>For user interfaces, use labels:</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>navigation<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-label</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Primary<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>  \n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>ul</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>...a list of links here ...<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>ul</span><span class=\"token punctuation\">></span></span>   \n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>  \n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>navigation<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-label</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Secondary<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>  \n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>ul</span><span class=\"token punctuation\">></span></span>  \n   <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>...a list of links here ...<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>   \n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>ul</span><span class=\"token punctuation\">></span></span>  \n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\n</code></pre></div>\n<ol start=\"5\">\n<li>Handling Headers</li>\n</ol>\n<p>========================</p>\n<p>It is very important for assistive technologies like screen readers to use headers the way it was intended to be used and not in any other (confusing) form.</p>\n<h1> Main Heading </h1> <h2> Sub Heading </h2>  <h3> Sub Sub Heading </h3>\n<p>Anytime you are tempted to just bring in a h1 tag because of font, kindly head to the css file and style the sub header font instead.</p>\n<blockquote>\n<p><em>Make text content readable and understandable and make Web pages appear and operate in predictable ways</em> — Ire Aderinokun</p>\n</blockquote>\n<ol start=\"6\">\n<li>Handling Live Announcements</li>\n</ol>\n<p>===================================</p>\n<p>If your React application fetches any data from any external source like an API, it makes sense to put some kind of structure in place for people using assistive technologies to be aware of the fetching of data going on. We can achieve this with live announcements. Here is a sample live announcement component:</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">\"react\"</span><span class=\"token punctuation\">;</span>  \n  \n  \n<span class=\"token keyword\">class</span> <span class=\"token class-name\">Announcements</span> <span class=\"token keyword\">extends</span> <span class=\"token class-name\">React<span class=\"token punctuation\">.</span>Component</span> <span class=\"token punctuation\">{</span>  \n  <span class=\"token function\">render</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>  \n    <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>  \n        <span class=\"token operator\">&lt;</span>div aria<span class=\"token operator\">-</span>live<span class=\"token operator\">=</span><span class=\"token string\">\"polite\"</span> aria<span class=\"token operator\">-</span>atomic<span class=\"token operator\">=</span><span class=\"token string\">\"true\"</span>   \n          className<span class=\"token operator\">=</span><span class=\"token string\">\"visuallyhidden\"</span><span class=\"token operator\">></span>  \n          <span class=\"token punctuation\">{</span><span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span>props<span class=\"token punctuation\">.</span>message<span class=\"token punctuation\">}</span>  \n        <span class=\"token operator\">&lt;</span><span class=\"token operator\">/</span>div<span class=\"token operator\">></span>  \n    <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>  \n  <span class=\"token punctuation\">}</span>  \n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> Announcements<span class=\"token punctuation\">;</span></code></pre></div>\n<ul>\n<li>aria-live with the polite value indicates that the screen reader waits till everything else is read before reading the updated content.</li>\n<li>aria-atomic attribute set to true tells the screen reader that all page content would be announced, not just the updated content.</li>\n</ul>\n<p>After the announcement component has been created, to use the live announcement we:</p>\n<ul>\n<li>first create a state property in a parent component</li>\n</ul>\n<p><code class=\"language-text\">this.state = {  message: null; };</code></p>\n<ul>\n<li>then set message, optimally at the point where the API or fetch logic is:</li>\n</ul>\n<p><code class=\"language-text\">this.setState({  message: “this is currently happening mate!\" });</code></p>\n<ul>\n<li>finally, include the announcement component in the parent component like this:</li>\n</ul>\n<Announcements message={this.state.message} /> \n<p>This would now set up live announcements properly for screen readers at specified points of your code where fetching of data occurs.</p>\n<ol start=\"7\">\n<li>Using Fragments</li>\n</ol>\n<p>===================</p>\n<p>Fragments shipped with React 16.2.0, it allows you to group together a list of child elements without adding more nodes to the DOM. We know react component templates MUST always be wrapped with a HTML element for rendering to work correctly. This has made developers get really lazy and continuously wrap their code blocks with elements like divs (I used to always do this) We always end up with non-semantic HTML most times with the abuse of divs; remember how important semantic HTML is for accessibility.</p>\n<p>Take a look at this sample template from <a href=\"/lazy-loading-react-components-with-react-lazy-and-suspense-f05c4cfde10c\">my react.lazy tutorial</a></p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span><span class=\"token punctuation\">></span></span> {artists.map(artist =>(  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>1. Davido<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>2. Burna Boy<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">id</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">key</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span>{artist.id}</span><span class=\"token punctuation\">></span></span>   <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h1</span><span class=\"token punctuation\">></span></span>MTV Base Headline Artists 2019<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h1</span><span class=\"token punctuation\">></span></span>  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span> )}<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span><span class=\"token punctuation\">/></span></span></code></pre></div>\n<p>The highlighted div actually really looks harmless but might result to non-semantic and sometimes invalid HTML and even creation of extra nodes like this when compiled back to HTML:</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>ul</span><span class=\"token punctuation\">></span></span>  \n <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>1. Davido<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>2. Burna Boy<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>   \n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>ul</span><span class=\"token punctuation\">></span></span></code></pre></div>\n<p>So using React Fragments is the right way to get around this problem I bet you must have had before. With fragments, we can now have the same template be like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>React.Fragment</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>1. Davido<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>2. Burna Boy<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>React.Fragment</span><span class=\"token punctuation\">></span></span></code></pre></div>\n<p>This results in really semantic HTML:</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>ul</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>1. Davido<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>li</span><span class=\"token punctuation\">></span></span>2. Burna Boy<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>li</span><span class=\"token punctuation\">></span></span>  \n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>ul</span><span class=\"token punctuation\">></span></span></code></pre></div>\n<p>For shortcut lovers like myself, there is an optional and simpler syntax for React fragments. It is the use of empty angle brackets:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">&lt;>  \n    &lt;li>1. Davido&lt;/li>  \n    &lt;li>2. Burna Boy&lt;/li>  \n&lt;/></code></pre></div>\n<p>It is JSX syntax and it looks neater yes!</p>\n<ol start=\"8\">\n<li>Keyboard Focus with refs</li>\n</ol>\n<p>============================</p>\n<p>We can use ref functions to handle where we want the user to focus on in our application. As your react application is a single page application with routes, it is important that users with disabilities know when a new route renders in the DOM because screen readers are silent when routes change. A more modern type of ref was introduced with React 16.3.0 <em>React.createRef()</em>. Using the new ref, we can control the focus with the following steps:</p>\n<ul>\n<li>Create a ref for the component you want to add focus on</li>\n<li>Attach the created ref to the element to focus on</li>\n<li>Set the focus with a lifecycle method.</li>\n</ul>\n<h1 id=\"a-few-helpful-tools\" style=\"position:relative;\"><a href=\"#a-few-helpful-tools\" aria-label=\"a few helpful tools permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>A Few Helpful Tools..</h1>\n<ul>\n<li>You can install ESLint Plugin for Code Editors.</li>\n<li>You can also install ESLint jsx-a11y plugin for your React projects to display accessibility rules you miss while building your application.</li>\n</ul>\n<p>npm install eslint-plugin-jsx-a11y  -— save-dev</p>\n<ul>\n<li>Update your eslint.rc file’s plugin and extends sections in your code editor. For plugin section:</li>\n</ul>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">“plugin<span class=\"token string\">\": [   “jsx-a11y\"</span> <span class=\"token punctuation\">]</span></code></pre></div>\n<p>In the extends section:</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">“<span class=\"token keyword\">extends</span><span class=\"token string\">\": [  “plugin: jsx-a11y/recommended\"</span><span class=\"token punctuation\">]</span></code></pre></div>\n<h1 id=\"references\" style=\"position:relative;\"><a href=\"#references\" aria-label=\"references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>References</h1>\n<ul>\n<li>Every quote in this article is from <a href=\"https://bitsofco.de/the-accessibility-cheatsheet/\">Ire’s blog</a>, she is easily my favourite web developer.</li>\n<li>I got some resources and insights from <a href=\"https://www.w3.org/WAI/standards-guidelines/aria/\">w3.org</a>.</li>\n<li>Some notes from a seminar from Scott Vinkle, Accessibility Advocate at Shopify.</li>\n<li>The <a href=\"https://reactjs.org/docs/accessibility.html\">React Official Documentation</a>.</li>\n<li><a href=\"https://www.a11yproject.com/resources/#html-and-aria\">https://www.a11yproject.com/resources/#html-and-aria</a></li>\n</ul>\n<h1 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h1>\n<p>By going through this article, you must have picked up various steps that would not only improve your efficiency writing React, but would also make you a global citizen, one who thinks equality and does not discriminate while building for the web. Now go out there and become an accessibility advocate, happy coding! Feel free to comment and ask anything 👐</p>","excerpt":"Achieving Accessibility in React Applications a11y stands for \nThe phrase '11 characters'. Arrows are pointing to the first letter c and the…","fields":{"slug":"/web-accessibility-a11y-using-reactjs/"},"frontmatter":{"title":"learning accessibility standards reactjs","date":"June 04, 2022","tags":["web-design","reactjs","a11y"],"description":"learning accessibility standards reactjs"}}},"pageContext":{"slug":"/web-accessibility-a11y-using-reactjs/","previous":{"id":"b0c82b8d-3aef-589b-8093-ebf004823d6c","frontmatter":{"title":"learning svelte js quick starter","tags":["seveltejs","javascript"],"categories":["sveltejs","javascript"],"template":"post"},"fields":{"slug":"/learning-sveltejs-over-the-weekend/"}},"next":{"id":"a4e2a4aa-8ac2-5c5f-9448-4b80992b3788","frontmatter":{"title":"Build design system with reactjs","tags":["web-design","reactjs","a11y"],"categories":["a11y","reactjs","web-design"],"template":"post"},"fields":{"slug":"/build-design-system-with-reactjs/"}}}},
    "staticQueryHashes": ["352937542"]}