New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dooboo-ui/native-switch-toggle

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dooboo-ui/native-switch-toggle

[![Npm Version](http://img.shields.io/npm/v/@dooboo-ui/native-switch-toggle.svg?style=flat-square)](https://npmjs.org/package/@dooboo-ui/native-switch-toggle) [![Downloads](http://img.shields.io/npm/dm/@dooboo-ui/native-switch-toggle.svg?style=flat-square

  • 0.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
132
decreased by-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

SwitchToggle

Npm Version Downloads

Simple switch toggle component for react-native. This component supports horizontal switch toggle with animation with several options like start/end background colors, start/end circle colors, and duration for animation.

Props

necessarytypesdefault
switchOnbooleanfalse
onPressfunc() => {}
containerStyleViewStyle{ width: 72, height: 36, borderRadius: 18 ... }
circleStyleViewStyle{ width: 30, height: 30, borderRadius: 15 ... }
backgroundColorOnstring'rgb(227,227,227)'
backgroundColorOffstring'rgb(215,215,215)'
circleColorOnstring'white'
circleColorOffstring'rgb(102,134,205)'
durationnumber300
typenumber0 - Normal switch, 1 - Switch with a text
buttonTextstringText on-top of the button
backTextRightstringText to appear in right side when button toggled to left
backTextLeftstringText to appear in left side when button toggled to right
buttonTextStyleStyleProp<TextStyle>Styles for text on the button
textRightStyleStyleProp<TextStyle>Styles for text in right
textLeftStyleStyleProp<TextStyle>Styles for text in left
buttonStyleStyleProp<ViewStyle>Styles for the button
buttonContainerStyleStyleProp<ViewStyle>Styles for button container
rightContainerStyleStyleProp<ViewStyle>Styles for right text container
leftContainerStyleStyleProp<ViewStyle>Styles for left text container

Installation

yarn add @dooboo-ui/native

or

yarn add @dooboo-ui/native-switch-toggle

Usage

import React, { ReactElement, useState } from 'react';

import { SwitchToggle } from '@dooboo-ui/native';
// or
import SwitchToggle from '@dooboo-ui/native-switch-toggle';
import styled from 'styled-components/native';

const Container = styled.View`
  flex: 1;
  background-color: #f5fcff;
  flex-direction: column;
  align-items: center;
  justify-content: center;
`;

function Page(): ReactElement {
  const [switchOn1, setSwitchOn1] = useState(false);
  const [switchOn2, setSwitchOn2] = useState(false);
  const [switchOn3, setSwitchOn3] = useState(false);
  const [switchOn4, setSwitchOn4] = useState(false);

  return (
    <Container>
      <SwitchToggle
        switchOn={switchOn1}
        onPress={(): void => setSwitchOn1(!switchOn1)}
      />
      <SwitchToggle
        containerStyle={{
          marginTop: 16,
          width: 108,
          height: 48,
          borderRadius: 25,
          backgroundColor: '#ccc',
          padding: 5,
        }}
        circleStyle={{
          width: 38,
          height: 38,
          borderRadius: 19,
          backgroundColor: 'white', // rgb(102,134,205)
        }}
        switchOn={switchOn2}
        onPress={(): void => setSwitchOn2(!switchOn2)}
        circleColorOff="white"
        circleColorOn="red"
        duration={500}
      />
      <SwitchToggle
        containerStyle={{
          marginTop: 16,
          width: 160,
          height: 65,
          borderRadius: 30,
          padding: 5,
        }}
        backgroundColorOn="#a0e1e5"
        backgroundColorOff="#e5e1e0"
        circleStyle={{
          width: 55,
          height: 55,
          borderRadius: 27.5,
          backgroundColor: 'blue', // rgb(102,134,205)
        }}
        switchOn={switchOn3}
        onPress={(): void => setSwitchOn3(!switchOn3)}
        circleColorOff="#ff11ff"
        circleColorOn="green"
        duration={500}
      />
      <SwitchToggle
        buttonText={switchOn4 ? 'Hour' : 'Day'}
        backTextRight={switchOn4 ? '' : 'Hour'}
        backTextLeft={switchOn4 ? 'Day' : ''}
        type={1}
        buttonStyle={{
          alignItems: 'center',
          justifyContent: 'center',
          position: 'absolute',
        }}
        rightContainerStyle={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
        }}
        leftContainerStyle={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'flex-start',
        }}
        buttonTextStyle={{ fontSize: 20 }}
        textRightStyle={{ fontSize: 20 }}
        textLeftStyle={{ fontSize: 20 }}
        containerStyle={{
          marginTop: 16,
          width: 160,
          height: 65,
          borderRadius: 30,
          padding: 5,
        }}
        backgroundColorOn="#fff"
        backgroundColorOff="#fff"
        circleStyle={{
          width: 80,
          height: 55,
          borderRadius: 27.5,
          backgroundColor: 'blue', // rgb(102,134,205)
        }}
        switchOn={switchOn4}
        onPress={(): void => setSwitchOn4(!switchOn4)}
        circleColorOff="#e5e1e0"
        circleColorOn="#e5e1e0"
        duration={500}
      />
    </Container>
  );
}

export default Page;

Keywords

FAQs

Package last updated on 26 May 2020

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