Skip to main content

Toggles

AppSwitch​

Native switch that exposes the correct accessibility role and state.

npx midestic-rn-library add app-switch
const [on, setOn] = useState(true);

<View className="flex-row items-center justify-between">
<MyText>Notifications</MyText>
<AppSwitch value={on} onValueChange={setOn} />
</View>;
PropTypeDescription
valuebooleanControlled on/off state
onValueChange(value: boolean) => voidChange handler
disabledbooleanDisables the switch
classNamestringExtra classes

AppCheckbox​

Custom checkbox with checkbox role, checked state and an accessibility label.

npx midestic-rn-library add checkbox
<AppCheckbox value={accepted} onValueChange={setAccepted} accessibilityLabel="Accept terms" />
PropTypeDescription
valuebooleanChecked state
onValueChange(value: boolean) => voidChange handler
sizenumberBox size (default 24)
disabledbooleanDisables the checkbox
accessibilityLabelstringAnnounced by screen readers

StatusSwitch​

Online/offline driver toggle with labels on both sides of the knob.

npx midestic-rn-library add status-switch
<StatusSwitch value={online} onValueChange={setOnline} onlineLabel="You are online" offlineLabel="You are offline" />
<StatusSwitch value={online} onValueChange={setOnline} knobImage={require("./car.png")} />
PropTypeDescription
valuebooleantrue = online
onValueChange(value: boolean) => voidChange handler
onlineLabel / offlineLabelstringText shown while in each state
knobImageImageSourcePropTypeImage inside the sliding knob (plain circle when omitted)
disabledbooleanDisables the toggle