Theme

PlaygroundBeta

npm_versionnpm Paragon package page

Checkbox

Basic usage

Any Paragon component or export may be added to the code example.

<CheckBox
name="checkbox"
label="check me out!"
/>

Disabled

Any Paragon component or export may be added to the code example.

<CheckBox
name="checkbox"
label="you cannot check me out"
disabled
/>

Default checked

Any Paragon component or export may be added to the code example.

<CheckBox
name="checkbox"
label="(un)check me out"
checked
/>

Call a function

Any Paragon component or export may be added to the code example.

<CheckBox
name="checkbox"
label="check out the console"
onChange={() => console.log('the checkbox changed state')}
/>

Controlled example

Any Paragon component or export may be added to the code example.

class CheckBoxWrapper extends React.Component {
constructor(props) {
super(props);
this.toggleCheckBox = this.toggleCheckBox.bind(this);
this.state = {
checked: false,
};
}
toggleCheckBox() {
this.setState({
checked: !this.state.checked,
});
}
render() {
return (
<div className="d-flex align-items-center">
<Button
variant="light"
className="mr-3"
onClick={this.toggleCheckBox}
>
Click me to toggle the check box!
</Button>
<CheckBox
name="checkbox"
label="click the button"
checked={this.state.checked}
/>
</div>
);
}
}

Props API#

Check Props API
  • checked bool

    (Boolean): true if the state should be checked, false otherwise. This prop can be used to manage the Checkbox more directly, overriding the default Checkbox checked state.

    Defaultfalse
  • onChange func

    (Boolean): true if the checkbox should be disabled, false otherwise

    Default() => {}
  • inputRef func | shape {
    current: PropTypes.element,
    }

    function to be called when the checkbox changes state

Usage Insights#

Check

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.26.32
frontend-app-authn20.36.23
frontend-app-communications20.30.12
frontend-app-course-authoring20.32.02
frontend-app-discussions20.15.02
frontend-app-learner-record20.32.01
frontend-app-learning20.28.41
frontend-lib-content-components20.34.04
frontend-lib-special-exams20.22.41
prospectus20.32.310