New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-checkbox-hook

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-checkbox-hook

A React hook to easily work with checkboxes

latest
Source
npmnpm
Version
1.0.13
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

react-checkbox-hook

NPM CI codecov JavaScript Style Guide

A React hook to easily work with checkboxes

Example | Demo

Features

  • Controllable API
  • Headless (Bring-your-own-UI)
  • Checkboxes nesting
  • Support of indeterminate checkboxes
  • Small size and no dependencies

Install

yarn add react-checkbox-hook
npm install --save react-checkbox-hook

Quickstart

Learn more in example
CodeSandbox

import React from 'react';
import { useCheckbox } from 'react-checkbox-hook';

const App = () => {
  const options = [
    { id: 0, title: 'Option 1' },
    { id: 1, title: 'Option 2' },
    { id: 2, title: 'Option 3' },
  ];
  const { selectedOptions, handleOptionChange } = useCheckbox({ options });

  return (
    <div>
      {options.map((option) => (
        <div key={option.id}>
          <label>
            <input
              type="checkbox"
              checked={selectedOptions.includes(option.id)}
              onChange={(e) => handleOptionChange(option, e.target.checked)}
            />
            {option.title}
          </label>
          <br />
        </div>
      ))}
    </div>
  )
}

License

MIT © rostyk-begey

This hook is created using create-react-hook.

Keywords

frontend

FAQs

Package last updated on 24 Jan 2024

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