Giter Site home page Giter Site logo

ppoulsen / react-fun-toggles Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 523 KB

React Components for Fun Toggle Inputs

Home Page: https://ppoulsen.github.io/react-fun-toggles/

License: MIT License

JavaScript 6.50% TypeScript 93.50%
react typescript typestyle toggle checkbox switch

react-fun-toggles's Introduction

react-fun-toggles

A collection of React components for toggle and other checkbox inputs. Built in TypeScript with types exported.

Animated Image of Toggles in Action

Getting Started

Installation

npm install react-fun-toggles

or

yarn add react-fun-toggles

Usage

There is one component ready for use, SmileyToggle. Import it like so:

import { SmileyToggle } from 'react-fun-toggles';

It can be actively controlled by setting the checked property:

class ControlledToggle extends React.PureComponent<
  any,
  IControlledToggleState
> {
  constructor(props: {}) {
    super(props);
    this.state = {
      checked: true,
    };
  }
  public render() {
    return (
      <SmileyToggle onChange={this.onChange} checked={this.state.checked} />
    );
  }

  private onChange = (next: boolean) => this.setState({ checked: next });
}

It can also be left uncontrolled, with changes sent through the onChange handler:

<SmileyToggle defaultChecked={true} />

The height and colors are also customizable:

<SmileyToggle height={70} checkedColor="#27986d" uncheckedColor="#c646bd" />

Getting Started (Contributing)

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Install node >= 6 from https://nodejs.org/en/download/ Install yarn for package management https://yarnpkg.com/en/docs/install

Installing

A step by step series of examples that tell you how to get a development env running

Clone the repository

git clone https://github.com/ppoulsen/react-fun-toggles.git

Install dependencies with yarn

yarn

Run the storybook development server! This will start it on http://localhost:9001

yarn storybook

Built With

Credit

Authors

  • Paul Poulsen - Initial work - ppoulsen

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

react-fun-toggles's People

Contributors

ppoulsen avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.