MuiSwitch#
@palmyralabs/rt-forms-mui · form/MuiSwitch.tsx
Overview#
Toggle switch. Accepts a two-value options pair to store anything non-boolean (e.g. 'Y' / 'N'). The switch prop selects from four styled variants: 'MaterialUISwitch', 'Android12Switch', 'IOSSwitch', or the default 'Switch'.
Props — ISwitchDefinition & SwitchProps#
Common field props plus:
| Prop | Type | Purpose |
|---|---|---|
options |
{ onValue, offValue }? |
Values written to form data for on/off |
switch |
'MaterialUISwitch' | 'Android12Switch' | 'IOSSwitch' | 'Switch'? |
Styled switch variant |
Plus MUI SwitchProps (color, size, …).
Ref — ISwitchField#
interface ISwitchField {
focus(): void;
getValue(): any;
setValue(v: any): void;
toggle(): void;
isValid(): boolean;
}Example#
<MuiSwitch
attribute="status"
label="Active"
switch="IOSSwitch"
options={{ onValue: 'ACTIVE', offValue: 'INACTIVE' }}
/>