
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
@cloudflare/component-checkbox
Advanced tools
Cloudflare Checkbox Component
Installation with yarn is recommended
$ yarn add @cloudflare/component-checkbox
import React from 'react';
import { Checkbox, CheckboxGroup } from '../../src';
class CheckboxComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
checkbox1: true,
checkbox2: false,
checkboxValues: ['option1'],
checkbox5: false,
checkboxMulti: [false, true]
};
this.onCheckboxGroupChange = this.onCheckboxGroupChange.bind(this);
}
onCheckboxGroupChange(values) {
this.setState({
checkboxValues: values
});
}
render() {
return (
<div>
<p>
You can create them individually with <code>Checkbox</code>
</p>
<Checkbox
label="Checkbox 1"
name="checkbox-1"
value="checkbox1"
checked={this.state.checkbox1}
onChange={event => this.setState({ checkbox1: event.target.checked })}
/>
<Checkbox
label="Checkbox 2"
name="checkbox-2"
value="checkbox2"
checked={this.state.checkbox2}
onChange={event => this.setState({ checkbox2: event.target.checked })}
/>
<p>
Or as a group with <code>CheckboxGroup</code>
</p>
<CheckboxGroup
values={this.state.checkboxValues}
onChange={this.onCheckboxGroupChange}
>
<Checkbox label="Checkbox 3" name="checkbox-3" value="checkbox3" />
<Checkbox
mt={2}
label="Checkbox 4"
name="checkbox-4"
value="checkbox4"
/>
</CheckboxGroup>
<p>
You can also disable a label by passing <code>false</code> explicitly
</p>
<Checkbox
label={false}
name="checkbox-5-no-label"
value="checkbox5"
checked={this.state.checkbox5}
onChange={event => this.setState({ checkbox5: event.target.checked })}
/>
<p>
Using the indeterminate state, you can also build a multi-checkbox
selector
</p>
<Checkbox
label="Select All"
name="checkbox-all"
value="checkbox-all"
checked={this.state.checkboxMulti.every(checked => checked)}
indeterminate={
this.state.checkboxMulti.some(checked => checked) &&
!this.state.checkboxMulti.every(checked => checked)
}
onChange={({ target: { checked } }) =>
this.setState(({ checkboxMulti }) => ({
checkboxMulti: checkboxMulti.map(() => checked)
}))
}
/>
{this.state.checkboxMulti.map((checked, i) => (
<Checkbox
key={i}
label={`Multi Checkbox ${i + 1}`}
name={`multi-checkbox-${i}`}
value={`multiCheckbox${i}`}
checked={checked}
onChange={({ target: { checked } }) =>
this.setState(({ checkboxMulti }) => ({
checkboxMulti: checkboxMulti.map(
(cbState, cbIdx) => (i === cbIdx ? checked : cbState)
)
}))
}
/>
))}
</div>
);
}
}
export default CheckboxComponent;
FAQs
Cloudflare Checkbox Component
The npm package @cloudflare/component-checkbox receives a total of 6,154 weekly downloads. As such, @cloudflare/component-checkbox popularity was classified as popular.
We found that @cloudflare/component-checkbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 40 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.