Toggle

An on/off switch that flips when its command is heard: “dark mode”.

Speaking the command toggles the switch — the same trigger pattern as a button, applied to a boolean. Clicking and keyboard toggling work as on any switch, speech or no speech.

Basic toggle

Loading the React Native kit…

Hold anywhere and say:“dark mode”

Props

  • not set
React Native
Updates as you tick props
import { ListensToggle } from "@listenssoft/speechui-react-native";import { useState } from "react";
function Demo() {  const [enabled, setEnabled] = useState(false);  return (    <ListensToggle      label="Dark mode"      command="dark mode"      value={enabled}      onValueChange={setEnabled}    />  );}

Bare mode (React)

React-only: bare renders just the underlying checkbox input so a parent supplies the visual switch — for Tailwind switches and design systems. className, id, and name forward to the input.

Loading the React Native kit…

Hold anywhere and say:“autopilot”

React Native
// React Native has no bare mode; style the toggle via its style// props or theme tokens (success, track, toggleThumb), or build your// own switch on useListensCommand:import { useListensCommand } from "@listenssoft/speechui-react-native";import { Switch } from "react-native";import { useState } from "react";
function Demo() {  const [on, setOn] = useState(false);  useListensCommand({    command: "autopilot",    onTriggered: () => setOn((v) => !v),  });  return <Switch value={on} onValueChange={setOn} />;}

What you can say

SayEffect
“dark mode”Toggles the switch once.
“…turn on dark mode please…”Also toggles — matching is contains. (The words “on/off” are not parsed; each match flips the current state.)
“dark mode … (again within ~1s)”Ignored by the per-command cooldown; repeat after a brief pause to flip back.

The toggle flips on each match rather than parsing an on/off argument — say it again to flip back. Pair it with listeningContent to show the current effect (“say: dark mode to turn off”).

API reference

React Native props for @listenssoft/speechui-react-native.

Props

PropTypeDefaultDescription
disabledboolean—Disables the switch.

The RN toggle renders the web kits' switch exactly (44×24 track, success green when on, 20px thumb, 160ms) rather than the platform Switch, so all kits look identical.

Extra props

PropTypeDefaultDescription
labelstring—Label beside the switch; the command fallback.
commandstringlabelThe spoken command that toggles the switch.
valueboolean—Controlled state. Pair with onValueChange. (RN's Switch naming, not checked/onChange.)
onValueChange(value: boolean) => void—Called with the next state — tap or speech.
styleStyleProp<ViewStyle>—Container override.
labelStyleStyleProp<TextStyle>—Label text override.

Styling hooks

Style props and theme keys

HookTypeDefaultDescription
style / labelStyleStyleProp—Direct overrides.
theme.success / theme.track / theme.toggleThumbtoken—On color, off track, thumb — from the active ListensTheme.

Was this page helpful?