26
loading...
This website collects cookies to deliver better user experience
Accessibility support is necessary to allow assistive technology to interpret web pages.
Accessibility is the necessary tool or ways in which a website can be made easy to access by the user with features like clickable buttons or drop downs or spaces to write a comment and stuff.
Accessibility also helps in power users may find it faster to interact with your application using a keyboard, rather than a mouse or touch screen. Especially for applications involving a large amount of data entry, good keyboard navigation support can dramatically increase user productivity.
<input
aria-label={labelText}
aria-required="true"
onChange={onchangeHandler}
value={inputValue}
name="name"
/>
<div>
elements to our JSX to make our React code work, especially when working with lists (<ol>, <ul> and <dl>)
and the HTML <table>
this makes a problem of understanding the code and thus debugging the code.import React, { Fragment } from 'react';
function employeeList() {
return (
<Fragment>
<dt>EA824412</dt>
<dd> Sreashi Saha</dd>
</Fragment> );
}
<input>
and <textarea>
, needs to be labeled accessibly. There is one important thing you must provide in your application: a textual label for each control . This gives a screen reader user context about the control they are interacting with.Although these standard HTML practices can be directly used in React, note that the for attribute is written as htmlFor in JSX:<label htmlFor="name">Name:</label>
<input id="name" type="text" name="name"/>
ref
callback to store a reference to the text input DOMclass CustomDiv extends React.Component {
constructor(props) {
super(props);
this.div = React.createRef();
}
render() {
return (
<div
tabIndex= "-1"
ref={this.div}
/>
);
}
}
focus() {
this.textInput.current.focus();
}
(who might depend on screen readers)
are in your application. It is also really great for search engine optimisation.Set the document <title>
to correctly describe the current page content as this ensures that the user remains aware of the current page context.Let's see an example:function App() {
return (
<DocumentTitle title='My Web App'>
<SomeRouter />
</DocumentTitle>
);
}
class NewArticlePage extends React.Component {
constructor(props) {
super(props);
this.state = { title: 'Untitled' };
}
render() {
return (
<DocumentTitle title={this.state.title}>
<div>
<h1>New Article</h1>
<input
value={this.state.title}
onChange={(e) => this.setState({ title: e.target.value })}
/>
</div>
</DocumentTitle>
);
}
npm install eslint-plugin-jsx-a11y -— save-dev
{
"extends": ["react-app", "plugin:jsx-a11y/recommended"],
"plugins": ["jsx-a11y"]
}