Skip to content

Select a unique value across multiple groups that share the same group of values

Notifications You must be signed in to change notification settings

dogsGhost/rc-shared-radio-groups

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Component: Shared Radio Groups

A normal radio group allows you to select one unique value exclusive to a group. This component allows you to select a unique value across multiple groups that share the same group of values. When an option is selected in one group, it is automatically disabled in associated groups.

View demo

Installing

$ npm i --save rc-shared-radio-groups

Usage

import SharedRadioGroups from 'rc-shared-radio-groups';

const sharedRadioGroupsHandler = (selection) => {
  console.log(selection.name);
  console.log(selection.value);
}

<SharedRadioGroups
  names={['cat', 'dog']}
  onSelect={sharedRadioGroupsHandler}
  values={['first', 'second']}>

Props

The component accepts three props.

names

Type: string[]

Required. Must be an array of strings.

onSelect

Type: function

Optional. If passed must be a function. This is passed the name/value of a specific group when it is selected/deselected.

values

Type: array

These are the shared options available to select for each item in names.

About

Select a unique value across multiple groups that share the same group of values

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published