Skip to main content

NeoPopToggle

A NeoPop-styled on/off toggle switch with animated thumb, customisable track and thumb colors, and optional custom drawables.

Usage

// dark mode example
import { NeoPopToggle } from 'neopop-rn';
import { useState } from 'react';

function Example() {
const [isOn, setIsOn] = useState(false);

return (
<NeoPopToggle
isChecked={isOn}
onValueChange={setIsOn}
colorMode="dark"
enableHaptics
/>
);
}
// light mode example
import { NeoPopToggle } from 'neopop-rn';
import { useState } from 'react';

function Example() {
const [isOn, setIsOn] = useState(false);

return (
<NeoPopToggle
isChecked={isOn}
onValueChange={setIsOn}
colorMode="light"
colorConfig={{
trackCheckedColor: '#06C270',
trackUncheckedColor: '#cccccc',
thumbCheckedColor: '#ffffff',
thumbUncheckedColor: '#ffffff',
borderColor: '#aaaaaa',
}}
/>
);
}

Props

PropTypeDefaultDescription
isCheckedbooleanRequired. Current on/off state.
onValueChange(value: boolean) => voidRequired. Called with the new boolean when toggled.
colorMode'dark' | 'light'Theme mode for default color selection.
colorConfigNeoPopToggleColorConfigPer-token color overrides (see colorConfig table).
trackDrawableReact.ReactNodeCustom content rendered inside the track background.
thumbDrawableReact.ReactNodeCustom content rendered inside the thumb circle.
disabledbooleanDisables interaction.
enableHapticsbooleanFires a haptic on each toggle.
styleStyleProp<ViewStyle>Additional style applied to the outer container.

colorConfig

KeyDescription
trackCheckedColorTrack background color when isChecked is true.
trackUncheckedColorTrack background color when isChecked is false.
thumbCheckedColorThumb circle color when checked.
thumbUncheckedColorThumb circle color when unchecked.
borderColorBorder color of the track.

Notes

  • trackDrawable and thumbDrawable replace the default background fills; when provided, colorConfig track/thumb colors may not be visible.
  • The thumb slides between the left and right positions using a Reanimated spring animation.
  • When disabled is true, the component ignores all press events.