npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

actually-accessible-react-radios

v1.0.2

Published

Accessible ReactJS radio group

Downloads

10

Readme

Actually accessible react radios

A radio group is used when one option must be selected from two or more options. One option can be selected by default (usually the top of the list) or all options can begin unselected, however, it’s common that a selection is required in order to proceed.

A fully WCAG2.1 compliant switch component.

This includes full keyboard support and will work with the following screen reader pairings:

  • Chrome/Windows + Jaws
  • Safari/OSX + Voice over

The behaviour in other pairings is not catered for so may or may not function as expected. In general however, testing with NVDA has also yielded good results.

Installation

npm i actually-accessible-react-radios --save

Usage

import ReactDOM from 'react-dom';
import React from 'react';
import RadioGroup from 'actually-accessible-react-radios';

const options = [
  {id: '1', label: 'Option 1', value: 1},
  {id: '2', label: 'Option 2', value: 2},
  {id: '3', label: 'Option 3', value: 3},
  {id: '4', label: 'Option 4', value: 4, isDisabled: true},
  {
    id: '5', label: 'Option 5', value: 5, isActive: true, isDisabled: true
  }
];

ReactDOM.render(
  <RadioGroup
    id="demo1"
    label="Some title"
    name="fields"
    options={options}
    onSelect={o => console.log(o)}
  />,
  window.document.getElementById('demo')
);

Props

id required - Unique control identifier

label required - Not visible by set as aria-label attribute

onSelect(Object) required - A function called when a radio selection or change occurs

options required - An array of options to render. Each option must have an id, label and a value. Additional properties such as isActive can be passed on one option to indicate when an item is selected. An option can also be disabled using the isDisabled property.

isLabelHidden optional - Do not display group title and only make it available to a screen reader

Accessibility

Keyboard interaction

TAB Moves focus to the checked radio button in the radiogroup. If a radio button is not checked, focus moves to the first radio button in the group.

SPACE If the radio button with focus is not checked, changes state to checked. Otherwise, it does nothing.

DOWN RIGHT Moves focus to and checks the next radio button in the group. If focus is on the last radio button, moves focus to first radio. If an item is disabled focus will still be moved to the item so screen readers will announce the state of the radio.

UP LEFT Moves focus to and checks the previous radio button in the group. If focus is on the first radio button, moves to last radio. If an item is disabled focus will still be moved to the item so screen readers will announce the state of the radio.