0.5.1 • Published 3 months ago

react-native-swiggle v0.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

react-native-swiggle

Swiggles

What is the correct term? Toggle or Switch? I don't know. Who knows? That's why I created this component. It's a toggle, it's a switch, it's a Swiggle.

On a more serious note, this is a simple Toggle component for React Native.

Installation

npm install react-native-swiggle

Usage

import Swiggle from 'react-native-swiggle';

export default function App() {
  const [exampleValue, setExampleValue] = useState(true);

  const handleSwiggle = () => {
    setExampleValue((prevValue) => !prevValue);
  };

  return (
    <View style={styles.container}>
      <Swiggle isActive={exampleValue} onPress={handleSwiggle} />
    </View>
  );
}

Usage with optional props

Default colors: Background disabled: gray, Background enabled: green, Inner circle disabled: black, Inner circle enabled: white

import Swiggle from 'react-native-swiggle';

export default function App() {
  const [exampleValue, setExampleValue] = useState(true);

  const handleSwiggle = () => {
    setExampleValue((prevValue) => !prevValue);
  };

  return (
    <View style={styles.container}>
      <Swiggle
        isActive={exampleValue}
        onPress={handleSwiggle}
        enabledBackgroundColor="blue"
        disabledBackgroundColor="red"
        innerCircleEnabledColor="white"
        innerCircleDisabledColor="violet"
      />
    </View>
  );
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.5.1

3 months ago

0.3.0

8 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.4.2

8 months ago

0.2.0

8 months ago