@cloudflare/component-radio
TypeScript icon, indicating that this package has built-in type declarations

5.0.6 • Public • Published

@cloudflare/component-radio

Cloudflare Radio Component

Installation

Installation with yarn is recommended

$ yarn add @cloudflare/component-radio

Usage

import React from 'react';
import { Radio, RadioGroup } from '../../src/index';

class RadioComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      radioValue: 'option1'
    };
    this.onRadioChange = this.onRadioChange.bind(this);
  }

  onRadioChange(val) {
    this.setState({
      radioValue: val
    });
  }

  render() {
    return (
      <div>
        <p>
          You can create them individually with <code>Radio</code>
        </p>

        <Radio
          label="Radio 1"
          name="radio-1"
          value="radio1"
          checked={this.state.radioValue === 'radio1'}
          onChange={this.onRadioChange}
        />

        <Radio
          label="Radio 2"
          name="radio-2"
          value="radio2"
          checked={this.state.radioValue === 'radio2'}
          onChange={this.onRadioChange}
        />

        <p>
          Or as a group with <code>RadioGroup</code>
        </p>

        <RadioGroup value={this.state.radioValue} onChange={this.onRadioChange}>
          <Radio
            label="Radio 3 (Disabled)"
            name="radio-3"
            value="radio3"
            disabled
          />
          <Radio label="Radio 4" name="radio-4" value="radio4" />
        </RadioGroup>

        <p>
          You can also disable a label by passing <code>false</code> explicitly
        </p>

        <Radio
          label={false}
          name="radio-5-no-label"
          value="radio5"
          checked={this.state.radioValue === 'radio5'}
          onChange={this.onRadioChange}
        />
      </div>
    );
  }
}

export default RadioComponent;

Readme

Keywords

none

Package Sidebar

Install

npm i @cloudflare/component-radio

Weekly Downloads

4,277

Version

5.0.6

License

BSD-3-Clause

Unpacked Size

191 kB

Total Files

12

Last publish

Collaborators

  • lerwincf
  • lbarthonet
  • cf-media-manager
  • jacobbednarz
  • celso
  • cf-radar
  • dash_service_account
  • g4brym
  • snigdha34
  • wrangler-publisher
  • marksteyn
  • chiminator
  • sgoodhew_cf
  • terinjokes
  • third774
  • jsteinberger
  • jasnell
  • asapzacy
  • pcostanzo
  • gregbrimble
  • geelen
  • rexscaria
  • dcruz_cf
  • xuranwang
  • jculvey
  • sejoker
  • vasturiano
  • cf-ci-write
  • segments-write
  • thibmeu
  • xortive
  • gurjinder
  • cf-ci2
  • lvalenta
  • worenga