All Projects → atomicpages → pretty-checkbox-react

atomicpages / pretty-checkbox-react

Licence: MIT license
A tiny react/preact wrapper around pretty-checkbox

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to pretty-checkbox-react

Examples Win32
Shows how to use Win32 controls by programming code (c++17).
Stars: ✭ 22 (-37.14%)
Mutual labels:  checkbox, radio-buttons
Magic Input
CSS3 Styles for Checkbox and Radio Button inputs look prettier. with only one element.
Stars: ✭ 81 (+131.43%)
Mutual labels:  checkbox, radio-buttons
Lthradiobutton
A radio button with a pretty animation
Stars: ✭ 303 (+765.71%)
Mutual labels:  checkbox, radio-buttons
Xamarin.forms.inputkit
CheckBox, Radio Button, Labeled Slider, Dropdowns etc.
Stars: ✭ 372 (+962.86%)
Mutual labels:  checkbox, radio-buttons
React Menu
React component for building accessible menu, dropdown, submenu, context menu and more.
Stars: ✭ 237 (+577.14%)
Mutual labels:  checkbox, radio-buttons
Examples Gtkmm
Shows how to use Gtkmm controls by programming code (c++17).
Stars: ✭ 23 (-34.29%)
Mutual labels:  checkbox, radio-buttons
Form Js
Easily create web forms. Supports Meteor, AngularJS, React, Polymer and any CSS library, e.g. Bootstrap.
Stars: ✭ 9 (-74.29%)
Mutual labels:  checkbox, radio-buttons
Examples Qt
Shows how to use Qt widgets only by programming code (c++17).
Stars: ✭ 38 (+8.57%)
Mutual labels:  checkbox, radio-buttons
Pretty Checkbox
A pure CSS library to beautify checkbox and radio buttons.
Stars: ✭ 1,708 (+4780%)
Mutual labels:  checkbox, radio-buttons
Selectionlist
Simple single-selection or multiple-selection checklist, based on UITableView
Stars: ✭ 93 (+165.71%)
Mutual labels:  checkbox, radio-buttons
Multipicker
Form styling plugin for jQuery
Stars: ✭ 90 (+157.14%)
Mutual labels:  checkbox, radio-buttons
Examples wxWidgets
Shows how to use wxWidgets controls only by programming code (c++17).
Stars: ✭ 116 (+231.43%)
Mutual labels:  checkbox, radio-buttons
Pretty Checkbox Vue
Quickly integrate pretty checkbox components with Vue.js
Stars: ✭ 240 (+585.71%)
Mutual labels:  checkbox, radio-buttons
LC-switch
Superlight vanilla javascript plugin improving forms look and functionality
Stars: ✭ 31 (-11.43%)
Mutual labels:  checkbox, radio-buttons
whaaaaat
Inquirer.js port to Python (https://www.npmjs.com/package/inquirer). people blame me for staling this project. I do not have time to work on this right now - whaaaaat do you want me to do? take it offline?
Stars: ✭ 73 (+108.57%)
Mutual labels:  checkbox
revite
Revolt client built with Preact.
Stars: ✭ 606 (+1631.43%)
Mutual labels:  preact
progressive-web-app-starter
Preact based starter kit for making a Progressive Web App (PWA).
Stars: ✭ 19 (-45.71%)
Mutual labels:  preact
fpreact
fpreact provides an alternative api for creating preact components, heavily inspired by elm.
Stars: ✭ 47 (+34.29%)
Mutual labels:  preact
anghamify
Anghami Downloader | Download Anghami songs with full meta-tags.
Stars: ✭ 22 (-37.14%)
Mutual labels:  preact
esri-preact-pwa
An example progressive web app (PWA) using the ArcGIS API for JavaScript built with Preact
Stars: ✭ 13 (-62.86%)
Mutual labels:  preact

A flexible, yet simple React API around Pretty Checkbox

Github Release License: MIT Downloads Coverage Status


Pretty checkbox preview

Pretty Checkbox React

Pretty Checkbox React (PCR for short) is a small react wrapper around the the pretty awesome library pretty checkbox.

Getting Started

Pretty Checkbox React uses hooks heavily., Be sure you're running React 16.9 or later 😄. Not using hooks? No sweat – you still need 16.9+! PCR is compatible with classes, too!

npm i pretty-checkbox pretty-checkbox-react

# or with yarn
yarn add pretty-checkbox pretty-checkbox-react

Make sure you're on a supported version of React and React DOM:

npm i react@^16.9 react-dom@^16.9

# or use the latest and greatest react
npm i react react-dom

Using Preact?

PCR seamlessly integrates with Preact 😎, you don't even need to include preact/compat!

Basic Usage

PCR components are easy to use and require no additional setup. Use as controlled or uncontrolled, use with hooks or with classes, and pass all the props you want -- it's all forwarded to the underlying input element. Hungry for more? Head on over the the doc site.

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

function App() {
  return <Checkbox>Do you agree to the terms and conditions?</Checkbox>;
}

Uncontrolled Usage

Add a ref and get access to the input element. Uncontrolled mode allows for seamless integration with form solutions like react-hook-form:

import { useEffect, useRef } from 'react';
import { Checkbox } from 'pretty-checkbox-react';

function App() {
  const ref = useRef(null);

  useEffect(() => {
    if (ref.current) {
      // do something awesome
    }
  }, []);

  return (
    <Checkbox ref={ref}>Do you agree to the terms and conditions?</Checkbox>
  );
}

Controlled Mode

Use our awesome hooks to abstract away state logic!

import { useCallback } from 'react';
import { Checkbox, useCheckboxState } from 'pretty-checkbox-react';

function App() {
  const checkbox = useCheckboxState();

  const onSubmit = useCallback(
    (e) => {
      e.preventDefault();

      if (!checkbox.state) {
        // update the state manually from the `confirm` result
        checkbox.setState(confirm('Do you agree to the terms and conditions?'));
      }
    },
    [checkbox]
  );

  return (
    <form onSubmit={onSubmit}>
      <Checkbox name="tac" value="" {...checkbox}>
        Do you agree to the terms and conditions?
      </Checkbox>
    </form>
  );
}

Documentation

PCR has extensive docs documented here: https://pretty-checkbox-react.netlify.app/. Give it a read and see what PCR is all about 👍.

Legacy Docs

For posterity purposes, PCR 1.x docs are still hosted here: https://atomicpages.github.io/pretty-checkbox-react/home/

Changelog

Head on over to releases 🎉

Contributions

Shout out to Lokesh for creating the original pretty-checkbox library

License

This project is licensed under the MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].