Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@chakra-ui/checkbox
Advanced tools
@chakra-ui/checkbox is a component library for creating accessible and customizable checkbox components in React applications. It is part of the Chakra UI library, which provides a set of accessible, reusable, and composable React components.
Basic Checkbox
This feature allows you to create a basic checkbox component. The Checkbox component can be used to render a simple checkbox with a label.
import { Checkbox } from '@chakra-ui/react';
function BasicCheckbox() {
return <Checkbox>Checkbox</Checkbox>;
}
Checkbox Group
This feature allows you to create a group of checkboxes. The CheckboxGroup component helps manage the state of multiple checkboxes and can be used to render a group of checkboxes with a shared color scheme and default values.
import { Checkbox, CheckboxGroup } from '@chakra-ui/react';
function CheckboxGroupExample() {
return (
<CheckboxGroup colorScheme="green" defaultValue={['one', 'two']}>
<Checkbox value="one">One</Checkbox>
<Checkbox value="two">Two</Checkbox>
<Checkbox value="three">Three</Checkbox>
</CheckboxGroup>
);
}
Indeterminate Checkbox
This feature allows you to create an indeterminate checkbox. The useCheckbox hook can be used to manage the state of the checkbox and set it to an indeterminate state.
import { Checkbox, useCheckbox } from '@chakra-ui/react';
function IndeterminateCheckbox() {
const { getCheckboxProps, getInputProps } = useCheckbox({
isIndeterminate: true,
});
return (
<Checkbox {...getCheckboxProps()}>
<input {...getInputProps()} />
Indeterminate Checkbox
</Checkbox>
);
}
react-checkbox-group is a lightweight library for managing groups of checkboxes in React. It provides a simple API for creating and managing checkbox groups, but it lacks the built-in accessibility and styling options provided by @chakra-ui/checkbox.
rc-checkbox is a React component for creating checkboxes. It offers basic checkbox functionality and customization options, but it does not provide the same level of accessibility and theming support as @chakra-ui/checkbox.
react-final-form is a form state management library for React. It includes components for creating and managing checkboxes within forms. While it offers powerful form management capabilities, it is more complex and not as focused on styling and accessibility as @chakra-ui/checkbox.
Checkbox component is used in forms when a user needs to select multiple values from several options.
yarn add @chakra-ui/checkbox
# or
npm i @chakra-ui/checkbox
import { Checkbox } from "@chakra-ui/checkbox"
<Checkbox>This is a checkbox</Checkbox>
CheckboxGroup is used to bind multiple checkboxes into a group, and it indicates whether one or more options are selected.
<CheckboxGroup defaultValue={["one", "two"]}>
<Checkbox value="one">One</Checkbox>
<Checkbox value="two">Two</Checkbox>
<Checkbox value="three">Three</Checkbox>
</CheckboxGroup>
FAQs
A React Checkbox component for use in forms
We found that @chakra-ui/checkbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.