@octopusdeploy/design-system-components
Version:
The design systems component library.
47 lines (46 loc) • 1.57 kB
TypeScript
import type * as React from "react";
import { type PopoverBasicHelpProps } from "../Popover";
type SwitchProps = {
/**
* The value of the Switch indicating whether the
* switch is on or off.
*/
value: boolean;
/**
* Controls whether the Switch should be automatically focused.
*/
autoFocus?: boolean;
/**
* Controls whether the Switch is disabled.
*/
disabled?: boolean;
/**
* onChange handler used to control the state for the Switch.
*/
onChange: (value: boolean) => void;
} & (SwitchWithLabelProps | SwitchWithoutLabelProps);
interface SwitchWithLabelProps {
/**
* The label of the switch. Prefer always providing a label for accessibility.
*/
label: string;
/**
* PopoverBasicHelp component to display additional help information
* via a help icon button next to the switch label.
*/
popover?: React.ReactElement<PopoverBasicHelpProps>;
/**
* An optional accessible name to use for this switch. If no accessible name
* is provided, then the label will be the accessible name for the switch.
*/
accessibleName?: string;
}
interface SwitchWithoutLabelProps {
/**
* Accessible name for screen readers when no visible label is shown.
* Required when omitting `label` so that the switch remains accessible.
*/
accessibleName: string;
}
export declare function Switch({ value, autoFocus, disabled, onChange, accessibleName, ...otherProps }: SwitchProps): import("react/jsx-runtime").JSX.Element;
export {};