Socket
Socket
Sign inDemoInstall

rc-switch

Package Overview
Dependencies
10
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rc-switch

switch ui component for react


Version published
Weekly downloads
964K
decreased by-15.92%
Maintainers
6
Install size
374 kB
Created
Weekly downloads
 

Package description

What is rc-switch?

The rc-switch npm package is a React component library for creating switch (toggle) inputs. It allows developers to easily implement switch components in their React applications, providing both visual and functional customization options.

What are rc-switch's main functionalities?

Basic switch

This code sample demonstrates how to render a basic switch component using the rc-switch package. It imports the Switch component from the package and includes it in a React component to be displayed.

import React from 'react';
import Switch from 'rc-switch';

function App() {
  return (
    <Switch />
  );
}

export default App;

Customized switch

This example shows how to customize a switch by adding labels for the checked and unchecked states, and setting the default state to checked. The 'checkedChildren' and 'unCheckedChildren' props allow for custom labels, while 'defaultChecked' initializes the switch in the on position.

import React from 'react';
import Switch from 'rc-switch';

function App() {
  return (
    <Switch
      checkedChildren="on"
      unCheckedChildren="off"
      defaultChecked
    />
  );
}

export default App;

Other packages similar to rc-switch

Readme

Source

rc-switch


Switch ui component for react.

NPM version build status Test coverage Dependencies DevDependencies npm download bundle size

Install

rc-switch

Usage

import Switch from 'rc-switch';

export default () => <Switch />;

Compatibility

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versions

API

PropertyTypeDefaultDescription
prefixClsStringrc-switch
classNameString''additional class name of root node
checkedbooleanfalsewhether switch is checked
defaultCheckedbooleanfalsewhether switch is checked on init
onChangeFunction(checked, event)called when switch is checked or unchecked
tabIndexnumbertab-index of switch node
onClickFunction(checked, event)called when switch is clicked
autoFocusbooleanget focus when mounts
disabledbooleanfalsewhether switch is disabled
loadingIconReact.ReactNodespecific the extra node. generally used in loading icon.

Development

npm install
npm start

Online demo: http://react-component.github.io/switch/examples/

License

rc-switch is released under the MIT license.

Keywords

FAQs

Last updated on 21 Oct 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc