1.0.10 • Published 1 year ago

react-custom-toggle v1.0.10

Weekly downloads
1
License
MIT
Repository
github
Last release
1 year ago

react-custom-toggle

A customizable toggle-switch component for react

Demo and docs

NPM JavaScript Style Guide

Install

npm install react-custom-toggle

Or

yarn add react-custom-toggle

Usage

import React, { useState } from 'react';
import Toggle from 'react-custom-toggle';
     
const Example = () => {
  const [isSunShining, setIsSunShining] = useState(false);

  return (
    <Toggle checked={isSunShining} onChange={setIsSunShining} />
  );
};

Props

NameTypeRequiredDescription
checkedbooleantrueDetermines whehter the toggle is checked or not
onChangefunctiontrueA function to handle the changes in the toggle state

Sizes

Only single size can be picked. The toggle has a medium size by default (if no size specified)

NameTypeDefaultDescription
extraLargebooleanfalseSet an extra large size to the toggle
largebooleanfalseSet a large size to the toggle
smallbooleanfalseSet a small size to the toggle
extraSmallbooleanfalseSet an extra small size to the toggle

Texts

NameTypeDefaultDescription
onTextstring''Text attached to the 'on' state
offTextstring''Text attached to the 'off' state

Colors

NameTypeDefaultDescription
colorOnstring#68d391 #68d391Background color of the Toggle in 'on' mode
colorOffstring#fc8181 #fc8181Background color of the Toggle in 'off' mode
textColorOnstringinheritColor of the 'on' text
textColorOffstringinheritColor of the 'off' text

Other props

NameTypeDefaultDescription
disabledbooleanfalseSet the Toggle disabled

License

MIT © YairAriel

1.0.9

1 year ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.10

1 year ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago