Skip to content

Switch

An on/off toggle switch control for Ink 5 terminal UIs.

Install

npm install @matthesketh/ink-switch

Usage

import { Switch } from '@matthesketh/ink-switch';
<Switch value={isOn} onChange={setIsOn} label="Wi-Fi" />

Props

PropTypeDefaultDescription
valuebooleanrequiredWhether the switch is on
onChange(value: boolean) => void---Called when toggled
labelstring---Label shown after the toggle
onLabelstring'ON'Text shown when on
offLabelstring'OFF'Text shown when off
onColorstring'green'Ink color when on
offColorstring'red'Ink color when off
disabledbooleanfalseDims the switch

Visual

(*)-- ON (green, on)
--(*) OFF (red, off)