npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-input-checkbox

v1.1.0

Published

Simple and stylable checkbox UI component for React apps

Downloads

821

Readme

react-input-checkbox

Checkbox is React component for boolean values.

  • Tiny: 957 bytes minified and gzipped (by Size Limit);
  • Easy customize: themes and modifications support;
  • Indeterminate state support.

Demos

Check it live on CodePen

To run demo locally install dev dependencies by npm install and use npm run demo.

Parcel start demo on http://localhost:1234/ and select one of three themes.

Table of Contents

  1. Installation
  2. Usage
    1. Props
    2. Style template
  3. License

Installation

npm install react-input-checkbox --save

It is necessary to make sure you include component base styles

import 'react-input-checkbox/lib/react-input-checkbox.min.css';

And then use as any other React component

import { Checkbox } from 'react-input-checkbox';

export const FancyCheckbox = props => (
    <Checkbox theme="fancy-checkbox"
        disabled={props.disabled}
        value={props.value}
        onChange={props.onChange}>
);

Usage

Props

children: React.ReactNode

Node that will be placed near checkbox as a label.

disabled : Boolean

Optional, default value is false

Flag for making checkbox disabled.

indeterminate : Boolean

Optional, default value is false

Visual only state of checkbox which is still either checked or unchecked as a state. If you want tot use it, you must create visual styles for that state, because it is not provided by default.

Note: if prop value is true indeterminate state will be ignored

modification : String

Optional, default value is null

CSS class for modification. Good to change color of checkbox, for example.

Note: check material-checkbox for example of changing color without changing the theme

onChange : (event: SyntheticEvent) => void

Callback which will be called any time the input value changes.

theme: String

Optional, default value is null

Class name prefix for your css styles for checkbox

value: Boolean

A value for the checkbox.

Style template

You can use any styles to checkboxes. Here is simple CSS template, that you can copy and paste to your project, just replace %your_style_prefix% with prefix that you will pass to theme prop:

.%your_style_prefix% {
    /* Common styles for the checkbox */
    /* Most likely you will customize left padding here */
}
.%your_style_prefix%__image {
    /* Default state of the checkbox image */
    /* Right place to size, background-image of unchecked state */
}
.%your_style_prefix%__label {
    /* Label styles (font styles mostly) */
}

/* Some states of checkbox image */
.%your_style_prefix%__input:focus + .%your_style_prefix%__image {
    /* Focused and unchecked */
}
.%your_style_prefix%__input:disabled + .%your_style_prefix%__image {
    /* Disabled and unchecked */
}
.%your_style_prefix%__input:checked + .%your_style_prefix%__image {
    /* Checked */
}
.%your_style_prefix%__input:checked:focus + .%your_style_prefix%__image {
    /* Focused and checked */
}
.%your_style_prefix%__input:checked:disabled + .%your_style_prefix%__image {
    /* Disabled and checked */
}

/* Additional indeterminate states */
.%your_style_prefix%__input_indeterminate + .%your_style_prefix%__image {
    /* Marks as indeterminate */
}
.%your_style_prefix%__input_indeterminate:focus + .%your_style_prefix%__image {
    /* Indeterminate and focused */
}
.%your_style_prefix%__input_indeterminate:disabled + .%your_style_prefix%__image {
    /* Indeterminate and disabled */
}

Check out demo styles for examples of styles: fancy-checkbox, bootstrap-checkbox and material-checkbox

License

Copyright (c) 2019 Paul Popov. MIT License.