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

react-flat-switch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-flat-switch

Inspired by Oleg Frolov's codepen, React Flat Switch is a toggle/switch component for React.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-flat-switch

Inspired by Oleg Frolov's codepen, React Flat Switch is a toggle/switch component for React.

Installation

npm install --save react-flat-switch

Demo & Example

Live demo: cameronbourke.github.io/example/react-flat-switch

To build the example locally, clone this repo then run:

npm install
npm start
Then open localhost:8080 in a browser.

Usage

import React from 'react';
import FlatSwitch from 'react-flat-switch';

class App extends React.Component {
	...

	render() {
		const background = this.state.switchEnabled ? '#2196f3' : '#DCDCDC';
		const enabledStyles = {
			color: '#2196f3'
		};
		const disabledStyles = {
			color: '#F32121'
		};

		return (
			<section className='container' style={{ background }}>
				<FlatSwitch
					width={150}
					height={40}
					enabled={this.state.switchEnabled}
					enabledText='enable'
					enabledStyles={enabledStyles}
					disabledStyles={disabledStyles}
					disabledText='disable'
					className='list-item--switch'
					onSwitch={this.handleOnClick.bind(this)}
				/>
			</section>
		);
	}
}

Available Props

PropertyTypeDefaultDescription
enabledbool(required)determines which side of the switch is shown
enableTextstringenablethe text value of the enabled side of the switch
disableTextstringdisablethe text value of the disabled side of the switch
onSwitchfuncundefinedcalled when the user clicks the switch
hideBoxShadowboolfalsewill hide any box shadows used
widthnumber/string150the width of the component
heightnumber/string40the height of the component
classNamestringundefinedthe classname of the component
enabledStylesobjectundefinedstyle object that will be applied to the enabled side
disabledStylesobjectundefinedstyle object that will be applied to the disabled side

Todo

  • Extend Styling Capabilities

License

MIT Licensed Copyright (c) Cameron Bourke 2016

Keywords

FAQs

Package last updated on 22 Feb 2016

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