[Docs] Accessibility : Should add aria-expanded and aria-controls for Collapse toggle
See original GitHub issueFor accessibility we should add aria-expanded and aria-controls for Collapse toggle: https://react-bootstrap.github.io/components.html#transitions-collapse
class Example extends React.Component {
constructor(...args) {
super(...args);
this.state = {};
}
render() {
return (
<div>
<Button onClick={ ()=> this.setState({ open: !this.state.open })}>
click
</Button>
<Collapse in={this.state.open}>
<div>
<Well>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</Well>
</div>
</Collapse>
</div>
);
}
}
ReactDOM.render(<Example/>, mountNode);
The accessible one:
class Example extends React.Component {
constructor(...args) {
super(...args);
this.state = {
open: false
};
}
render() {
return (
<div>
<Button onClick={ ()=> this.setState({ open: !this.state.open })} aria-expanded={this.state.open} aria-controls="collapseExample">
click
</Button>
<Collapse in={this.state.open}>
<div id="collapseExample">
<Well>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</Well>
</div>
</Collapse>
</div>
);
}
}
ReactDOM.render(<Example/>, mountNode);
Bootstrap example: https://getbootstrap.com/docs/4.0/components/collapse/
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
aria-expanded - Accessibility - MDN Web Docs - Mozilla
The aria-expanded attribute is set on an element to indicate if a control is expanded or collapsed, and whether or not its child...
Read more >Using the WAI-ARIA aria-expanded state to mark ...
Example 1: Using a button to collapse and expand a region The state of the paragraph is represented by the attribute aria-expanded on...
Read more >Collapse · Bootstrap
Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
Read more >Collapse · Bootstrap
The Bootstrap collapse plugin allows you to toggle content on your pages with a few ... aria-expanded="false" aria-controls="collapseExample"> Button with ...
Read more >What you need to know about ARIA and how to fix common ...
ARIA, or Accessible Rich Internet Applications, is HTML used to make webpages more accessible. Not all HTML elements have accessibility ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yup! please go for it 👍
We’re definitely open to PRs here.