2.0.0 • Published 6 years ago

@trendmicro/react-radio-button v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

react-radio-button build status Coverage Status

NPM

React Radio Button

Demo: https://trendmicro-frontend.github.io/react-radio-button

Installation

  1. Install the latest version of react and react-radio-button:

    npm install --save react @trendmicro/react-radio-button
  2. At this point you can import @trendmicro/react-radio-button and its styles in your application as follows:

    import RadioButton from '@trendmicro/react-radio-button';
    
    // Be sure to include styles at some point, probably during your bootstraping
    import '@trendmicro/react-radio-button/dist/react-radio-button.css';

Usage

<RadioButton label="RadioButton label" />

The label prop is optional, you can use children to pass through the component.

<RadioButton label="RadioButton label">
    <p style={{ marginLeft: 24 }}>
        Lorem ipsum dolor sit amet...
    </p>
</RadioButton>

<RadioButton>
    <span style={{ verticalAlign: 'middle', marginLeft: 8 }}>
        Lorem ipsum dolor sit amet...
    </span>
</RadioButton>

Uncontrolled RadioButton

// Default checked
<RadioButton defaultChecked />

Controlled RadioButton

// Checked
<RadioButton checked />

API

Properties

NameTypeDefaultDescription
childrenanyChildren to pass through the component.
classNameObjectCustomized class name for the component.
styleObjectCustomized style for the component.
labelNode or StringText label to attach next to the radio button.
inputClassNameObjectCustomized class name for the radio button.
inputStyleObjectCustomized style for the radio button.
disabledBooleanfalseIf true, the radio button shown as disabled and cannot be modified.
checkedBooleanThe checked state of the radio button.
defaultCheckedBooleanThe default checked state of the radio button.

Class Properties

Use the ref property to get a reference to the component:

<RadioButton
    ref={node => {
        if (node) {
            this.radioButton = node;
            console.log(this.radioButton.checked);
        }
    }}
/>
NameTypeDescription
checkedBooleanGet the checked state.

License

MIT