Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-bootstrap-toggle

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-bootstrap-toggle

A React version of the bootstrap-toggle without the JQuery dependency

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
decreased by-60.44%
Maintainers
1
Weekly downloads
 
Created
Source

React-Bootstrap-Toggle

Build Status Coverage Status

This is a react component of the http://www.bootstraptoggle.com/ project.

Usage

You need to include the bootstrap css file and also the bootstrap2-toggle css file in your app.

If you are using the npm version then you can include it from the module like this.

<link rel="stylesheet" href="node_modules/lib/bootstrap2-toggle.css">

Or you could import it to your SASS or LESS build.

@import "node_modules/lib/bootstrap2-toggle.css";
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Toggle from 'react-bootstrap-toggle';

class Form extends Componentn {
  constructor() {
    super();
    this.state = { toggleActive: false };
    this.onToggle = this.onToggle.bind(this);
  }

  onToggle() {
    this.setState({ toggleActive: !this.state.toggleActive });
  }

  render() {
    return (
      <form>
        <SomeInput something={true} />
        .....
        <Toggle
          onClick={this.onToggle}
          on={<h2>ON</h2>}
          off={<h2>OFF</h2>}
          size="large"
          offstyle="danger"
          active={this.state.toggleActive}
        />
      </form>
    )
  }

}


Install via NPM

npm install react-bootstrap-toggle --save

Props

NameTypeDefaultDescription
activebooleantrueSets the initial state of the toggle
onstring/html"On"Text of the on toggle
offstring/html"Off"Text of the off toggle
sizestring"normal"Size of the toggle. Possible values are large, normal, small, mini.
onstylestring"primary"Style of the on toggle. Possible values are default, primary, success, info, warning, danger
offstylestring"default"Style of the off toggle. Possible values are default, primary, success, info, warning, danger
widthintegernullSets the width of the toggle. if set to null, width will be calculated.
heightintegernullSets the height of the toggle. if set to null, height will be calculated.
onClickfunctionnullA Callback that returns the current state of the toggle

Using Bootstrap2 class names

If you want to use bootstrap two class names you can import the component like this

import { Bootstrap2Toggle } from 'react-bootstrap-toggle';

Now the component will use large instead of lg and etc..

Keywords

FAQs

Package last updated on 01 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc