finds.dev← search

// the find

chenglou/react-radio-group

★ 441 · JavaScript · MIT · updated Nov 2023

Better radio buttons.

A thin React wrapper that turns a group of radio inputs into one controlled component. You pass a name, a selectedValue and an onChange, and each Radio child gets type, name and checked filled in for it. It is aimed at React apps that are tired of repeating those three attributes on every input.

The API is five optional props on RadioGroup, and Radio forwards its other props to the underlying input, so there is little new to learn beyond the group itself. It is controlled by design: selectedValue drives the checked state and onChange receives the new value directly rather than an event, which removes event.target handling from every consumer. The Component prop lets the group render as any tag or component, so it can sit inside an existing form layout without extra wrapper markup. It is MIT-licensed and ships a UMD build for projects without a bundler.

The README example puts the label text as a bare sibling after each Radio rather than inside a label element. Clicking the text does nothing and screen readers get no accessible name, so adopters have to wrap each Radio and its text in a label themselves. selectedValue is documented as String, Number or Boolean only, so object-valued options need an id key first. The last push was 2023-11-13 and the README links to the old facebook.github.io React docs, so compatibility with current React is unverified and nothing suggests recent maintenance. The listed tree has no test directory and no type definitions, so TypeScript users should expect to write their own typings.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →