0.3.3 • Published 4 months ago

rn-switch-kit v0.3.3

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

rn-switch-kit

rn-switch-kit is a customizable React Native switch component, designed for seamless integration and modern UI needs.

Installation

npm install rn-switch-kit

Usage

import RNSwitchKit from 'rn-switch-kit';

// ...

  const [status1, setStatus1] = useState(true);
  const handleChange1 = (value: boolean) => {
    setStatus1(value);
  };

// ...

      <Text>test 1: {status1 ? 'True' : 'False'}</Text>
      <RNSwitchKit
        label="test 1"
        onColor="green"
        offColor="gray"
        initialValue={status1}
        onToggle={(value) => handleChange1(value)}
      />

// ...
      <RNSwitchKit onColor="#f205c3" offColor="red" initialValue={status1} />

Props

NameTypeDefaultDescription
labelstringundefinedOptional label displayed next to the switch.
onColorstring#4caf50Background color of the switch when it is in the "on" state.
offColorstring#cccBackground color of the switch when it is in the "off" state.
thumbColorstring#fffColor of the switch thumb.
initialValuebooleanfalseInitial state of the switch (true for "on", false for "off").
styleStyleProp<ViewStyle>undefinedCustom styles for the switch container.
labelStyleStyleProp<TextStyle>undefinedCustom styles for the label text.
labelPosition'left' | 'right''left'Position of the label relative to the switch.
onToggle(value: boolean) => voidundefinedCallback function invoked when the switch is toggled. Receives the new state as a parameter.
disabledbooleanfalseDisables the switch when set to true.
widthnumber100Width of the container. If no label is provided, the width defaults to the switch size (50).

Contributing

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

License

MIT


Made with create-react-native-library

0.3.3

4 months ago

0.3.2

5 months ago

0.2.2

5 months ago

0.2.1

5 months ago

0.1.1

6 months ago

0.1.0

6 months ago