• Stars
    star
    945
  • Rank 48,368 (Top 1.0 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Elegant, accessible toggle component for React. Also a glorified checkbox.

An elegant, accessible toggle component for React. Also a glorified checkbox.

See usage and examples.

Props

The component takes the following props.

Prop Type Description
checked boolean If true, the toggle is checked. If false, the toggle is unchecked. Use this if you want to treat the toggle as a controlled component
defaultChecked boolean If true on initial render, the toggle is checked. If false on initial render, the toggle is unchecked. Use this if you want to treat the toggle as an uncontrolled component
onChange function Callback function to invoke when the user clicks on the toggle. The function signature should be the following: function(e) { }. To get the current checked status from the event, use e.target.checked.
onFocus function Callback function to invoke when field has focus. The function signature should be the following: function(e) { }
onBlur function Callback function to invoke when field loses focus. The function signature should be the following: function(e) { }
name string The value of the name attribute of the wrapped <input> element
value string The value of the value attribute of the wrapped <input> element
id string The value of the id attribute of the wrapped <input> element
icons object If false, no icons are displayed. You may also pass custom icon components in icons={{checked: <CheckedIcon />, unchecked: <UncheckedIcon />}}
aria-labelledby string The value of the aria-labelledby attribute of the wrapped <input> element
aria-label string The value of the aria-label attribute of the wrapped <input> element
disabled boolean If true, the toggle is disabled. If false, the toggle is enabled

Installation

npm install react-toggle

Usage

If you want the default styling, include the component's CSS with

import "react-toggle/style.css" // for ES6 modules
// or
require("react-toggle/style.css") // for CommonJS

Development

npm install
npm run dev

Build

npm run build

License

MIT

More Repositories

1

dynamodb-admin

GUI for DynamoDB Local or dynalite
EJS
1,340
star
2

security-plus

Security+ SY0-501 study resources
56
star
3

bongo.js

[Deprecated] Store and query massive amounts of structured data on the browser.
JavaScript
48
star
4

shaf-chart

Custom element that upgrades table to a chart
JavaScript
45
star
5

shaf-toggle

Elegant, accessible toggle element. Upgrades existing <input type="checkbox" />
JavaScript
28
star
6

react-text-selection

(in progress, aims to be...) accessible text selection React component
JavaScript
22
star
7

reasonml-in-browser

[Deprecated] Drop-in script to run ReasonML in the browser. For development and demos.
JavaScript
21
star
8

sqs-admin

GUI for SQS. Useful for local development.
HTML
16
star
9

react-openapi

React component for viewing Open API specifications
JavaScript
15
star
10

totes

React-like web components
JavaScript
14
star
11

bible

For reading the Bible and studying its languages.
JavaScript
12
star
12

react-sortable-item

Reorder elements in a list. Uses the native HTML5 Drag and Drop API.
JavaScript
11
star
13

xhr-interceptor

Express-style XHR interception for the browser. Useful for caching and testing.
JavaScript
11
star
14

html-router

Drop-in router using web components
JavaScript
10
star
15

dem

Download an ECMAScript module and its relative dependencies
JavaScript
9
star
16

react-callbag-subject

Asynchronous pipelines in React using callbags
JavaScript
8
star
17

callbag-gamepads

Callbag source for connected gamepad inputs
JavaScript
7
star
18

office-document-viewer

DOCX web viewer
JavaScript
7
star
19

stats.re

Statistics module written in Reason
OCaml
5
star
20

callbag-animation-frames

Callbag listenable source sending DOMHighResTimeStamp at display refresh rate
JavaScript
5
star
21

parcel-reasonml-starter

Parcel + JavaScript + ReasonML
OCaml
4
star
22

react-barrier-game

For fun
JavaScript
4
star
23

element-easel

Wrap an element. Paint on it.
JavaScript
4
star
24

intensity-slider

THIS IS INTENSE
JavaScript
4
star
25

x-flex

Micro-classes for CSS flex. Tested against two latest major versions of browsers.
CSS
4
star
26

reasonml-fastify

ReasonML bindings for Fastify
OCaml
4
star
27

react-sortable-item-groups-hackweek

Sortable item groups using browser's native drag and drop API. Alpha. Not ready for production.
JavaScript
4
star
28

shaf-star-rating

Keyboard-accessible star rating element. Upgrades input element.
JavaScript
4
star
29

datchat

Chat powered by the Dat protocol
JavaScript
3
star
30

confident

Use an OpenAPI (Swagger) design to define express routes, API documentation, and request/response validation
JavaScript
3
star
31

callbag-keyboard

Callbag source for the keyboard
JavaScript
3
star
32

react-context-recoil-compared

Recoil state library demonstration
JavaScript
3
star
33

callbag-flatten-iter

Callbag operator that flattens iterables
JavaScript
2
star
34

reasonml-examples

OCaml
2
star
35

codeplumbers

A wiki for coders
2
star
36

jira-cli

Immersive command line interface (CLI) for JIRA
JavaScript
2
star
37

sblgnt

The Greek New Testament: SBL Edition
Ruby
2
star
38

react-publish-toggle

Toggle component for publishing or unpublishing a resource. WIP. Not ready for production.
JavaScript
2
star
39

koine-lexer

Lexical analysis of New Testament Koine Greek
TypeScript
2
star
40

create-element-class

Create custom element classes with a function.
JavaScript
2
star
41

lexham-english-bible

Ruby
2
star
42

ga-experiments

JavaScript A/B testing with custom variables in Google Analytics
JavaScript
2
star
43

leeroy

Better interface for Jenkins
JavaScript
1
star
44

png-to-phash

Generate pHash from PNG
JavaScript
1
star
45

canvas-console

CoffeeScript
1
star
46

php-elasticsearch-client

Simple PHP 5.4 client for ElasticSearch. Requires PEAR's HTTP_Request2.
PHP
1
star
47

modern-web-development

1
star
48

sudoku

JavaScript
1
star
49

local-elasticsearch

A Node.js wrapper of Elasticsearch
JavaScript
1
star
50

babel-html-element

DEPRECATED
JavaScript
1
star
51

shaf-unified-diff

Custom element to view unified diff
HTML
1
star
52

canvas-command

1
star
53

panda-ui

Stylesheets and web components in the likeness of InstUI
HTML
1
star
54

Kelvin

Website for weather app. Includes SVG animation with JavaScript.
JavaScript
1
star
55

jod

Historical archive of early Mormon sermons
JavaScript
1
star
56

canvas-dyson

Fake Canvas JSON. Useful for development. Uses webpro/dyson.
JavaScript
1
star
57

shaf-timeago

Custom element for 'ago' and 'in' time formatting
HTML
1
star
58

sift-wiki-starter

1
star
59

common-cartridge

Parser for common cartridges
JavaScript
1
star
60

react-pdf-render

WIP. Move along.
JavaScript
1
star
61

aaronshaf

Me.
1
star
62

SimplifyShakespeare

JavaScript
1
star
63

github-corner-element

Custom element for GitHub corner
JavaScript
1
star
64

koine

Koine learning resources
1
star
65

canvas-modules

Experimental workflow for Canvas app
JavaScript
1
star
66

subscribeAjax

jQuery plugin for XHR/pubsub magic
JavaScript
1
star
67

canvas-dev-box

Experimental virtual machine for developing Canvas LMS. Abandoned due to problems with guard
Shell
1
star
68

reasonml-project-euler

Project Euler solutions in ReasonML
OCaml
1
star
69

ic-sortable

Ember component for drag-and-drop between connected and nested lists (WIP)
JavaScript
1
star
70

phashin

compare screenshots with perceptual hashes
JavaScript
1
star
71

react-app-element

Custom element for loading React component
JavaScript
1
star