Socket
Socket
Sign inDemoInstall

@chakra-ui/checkbox

Package Overview
Dependencies
13
Maintainers
3
Versions
535
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/checkbox


Version published
Weekly downloads
447K
decreased by-9.67%
Maintainers
3
Install size
246 kB
Created
Weekly downloads
 

Package description

What is @chakra-ui/checkbox?

@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.

What are @chakra-ui/checkbox's main functionalities?

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>
  );
}

Other packages similar to @chakra-ui/checkbox

Readme

Source

@chakra-ui/checkbox

Checkbox component is used in forms when a user needs to select multiple values from several options.

Installation

yarn add @chakra-ui/checkbox

# or

npm i @chakra-ui/checkbox

Import component

import { Checkbox } from "@chakra-ui/checkbox"

Usage

<Checkbox>This is a checkbox</Checkbox>

CheckboxGroup

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>

Resources

  • https://www.a11ymatters.com/pattern/checkbox/
  • https://www.sarasoueidan.com/blog/inclusively-hiding-and-styling-checkboxes-and-radio-buttons/

Keywords

FAQs

Last updated on 25 Apr 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc