Components
Toggle
A boolean control, as a button, a chip, or a switch.
Use Toggle for on/off state. Bind it to a boolean parameter or control it with value and onChange.
import { Toggle } from '@soundor/components';
import { Text, View, useParameter } from '@soundor/react';
import { useState } from 'react';
import { parameters } from 'soundor:parameters';
export default function Demo() {
const bypass = useParameter(parameters.bypass);
const [on, setOn] = useState(true);
return (
<>
<View style={{ flexDirection: 'row', gap: 16, alignItems: 'center' }}>
<Toggle label="Bypass" variant="switch" parameter={parameters.bypass} />
<Toggle label="Chip" variant="chip" value={on} onChange={setOn} />
<Toggle label="Button" variant="button" value={on} onChange={setOn} />
</View>
<Text style={{ fontSize: 12 }}>Bypass is {bypass ? 'on' : 'off'}</Text>
</>
);
}toggle.tsx, running in the web runtime.SourceKeyboard and accessibility
A Toggle is a tab stop, and Enter or Space switches it. It is announced as a switch or a toggle button, depending on variant, with its on or off state. See Keyboard and accessibility.
Props
See Mixed values for editing multiple items.
Prop
Type