@invisionag/iris-react-radio
TypeScript icon, indicating that this package has built-in type declarations

4.5.2 • Public • Published
import Radio, { RadioGroup } from '@invisionag/iris-react-radio';

react-radio is a component that enables a user to chose between multiple choices. the layouting of these choices depends on what component gets put into the radio group.

Usage

Basic

<RadioGroup name="basic-group">
  <Radio value="1">First Option</Radio>
  <Radio value="2">Second Option</Radio>
</RadioGroup>

Preselected value

<RadioGroup name="basic-group" selectedValue="1">
  <Radio value="1">First Option</Radio>
  <Radio value="2">Second Option</Radio>
</RadioGroup>

Card layout

Instead of the default radio button layout, you can use clickable cards to render your options. Cards children will be displayed in the body, while the optional header prop expects valid jsx that will be rendered as a heading. Cards behave just like the Radio elements and can be mixed with them.

import RadioCard from '@invisionag/iris-react-radio/Card';
<RadioGroup name="basic-group" selectedValue="1">
  <RadioCard value="1">First Option</RadioCard>
  <RadioCard value="2" header={<h1>Second</h1>}>Second Option</RadioCard>
  <RadioCard value="3">Third Option</RadioCard>
</RadioGroup>

OnChange handler

Radios can receive an onChange handler, which will get executed before the builtin handler.

<RadioGroup name="basic-group" selectedValue="1">
  <Radio value="1" onChange={() => console.log('radio button changes')}>First Option</Radio>
  <Radio value="2">Second Option</Radio>
</RadioGroup>

Note that input elements only fire their onChange event when a radio gets selected. If, because of that, another radio gets deselected, this one won't fire.

Readme

Keywords

none

Package Sidebar

Install

npm i @invisionag/iris-react-radio

Weekly Downloads

12

Version

4.5.2

License

MIT

Unpacked Size

64.3 kB

Total Files

13

Last publish

Collaborators

  • jj-ivx
  • ivx-github
  • jana_hehr
  • roberter26
  • birgithorn
  • alexj-ivx
  • amft
  • aitortomas
  • yashabfaryal0322
  • nleinich
  • johannesluedke
  • pgotthardt-ivx
  • hrabe
  • plore_ivx
  • patricialieske
  • plaudel
  • mblumtritt
  • sruehlemann
  • brerx
  • mohamedmmahfouz
  • mbrendler
  • jens.zobel
  • cwaider
  • kattelans
  • ftrautmann
  • lutz.peukert
  • fruetel
  • schmitze333
  • csprle
  • beckerei
  • stefan.schiffer
  • ahx
  • cloudwaechter
  • tobias
  • alexmarold
  • t_klepzig
  • susahope
  • mwannewitz
  • ivx-circle-ci
  • yichang
  • ivx-jenkins