Skip to main content
A React component that accepts SwitchComponentProps as props.
export type SwitchComponent = React.Component<SwitchComponentProps>;

SwitchComponentProps

export interface SwitchComponentProps {
  ariaLabelledBy?: string;
  isChecked?: boolean;
  isDisabled?: boolean;
  isInvalid?: boolean;
  onCheckedChange?: (isChecked: boolean) => void;
  ref?: React.Ref<any>;
}
ariaLabelledBy
string
The id of an external element that labels this switch, if a label exists. Pass this as the aria-labelledby attribute on your root element to satisfy accessibility requirements when a visible label exists in the DOM.
isChecked
boolean
Whether the switch should be rendered in the on (checked) state.
isDisabled
boolean
When true, the switch is non-interactive and should be rendered in a visually disabled state.
isInvalid
boolean
When true, the switch is in an error state.
onCheckedChange
(isChecked: boolean) => void
Callback that should be invoked with the new isChecked value when the user toggles the switch.
ref
React.Ref<any>
A React ref that should be forwarded to the underlying DOM element.