@porsche-design-system/components-react
Version:
Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.
87 lines (86 loc) • 3.85 kB
TypeScript
import type { BaseProps } from '../../BaseProps';
import type { BreakpointCustomizable, SwitchAlignLabel, SwitchUpdateEventDetail } from '../types';
export type PSwitchProps = BaseProps & {
/**
* Sets the position of the slotted label relative to the switch toggle, either before (`start`) or after (`end`) it. Supports responsive breakpoint values.
* @default 'end'
*/
alignLabel?: BreakpointCustomizable<SwitchAlignLabel>;
/**
* Reflects the switch's current on/off state and allows setting the initial checked value when the component first renders.
* @default false
*/
checked?: boolean;
/**
* Reduces the switch size and spacing for use in dense layouts where vertical space is limited.
* @default false
*/
compact?: boolean;
/**
* Prevents user interaction with the switch and blocks all click and keyboard events while it is disabled.
* @default false
*/
disabled?: boolean;
/**
* Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values.
* @default false
*/
hideLabel?: BreakpointCustomizable<boolean>;
/**
* Disables the switch and shows a loading spinner to indicate an ongoing asynchronous toggle operation.
* @default false
*/
loading?: boolean;
/**
* Emitted when the user toggles the switch, carrying the new `checked` state in the event detail.
*/
onUpdate?: (event: CustomEvent<SwitchUpdateEventDetail>) => void;
/**
* Expands the space between the switch toggle and its label to fill the full available width of the container. Supports responsive breakpoint values.
* @default false
*/
stretch?: BreakpointCustomizable<boolean>;
};
export declare const PSwitch: import("react").ForwardRefExoticComponent<Omit<import("react").DOMAttributes<{}>, "onChange" | "onInput" | "onToggle"> & Pick<import("react").HTMLAttributes<{}>, "suppressHydrationWarning" | "autoFocus" | "className" | "dir" | "hidden" | "id" | "inert" | "inputMode" | "lang" | "slot" | "style" | "tabIndex" | "title" | "translate" | "role"> & {
/**
* Sets the position of the slotted label relative to the switch toggle, either before (`start`) or after (`end`) it. Supports responsive breakpoint values.
* @default 'end'
*/
alignLabel?: BreakpointCustomizable<SwitchAlignLabel>;
/**
* Reflects the switch's current on/off state and allows setting the initial checked value when the component first renders.
* @default false
*/
checked?: boolean;
/**
* Reduces the switch size and spacing for use in dense layouts where vertical space is limited.
* @default false
*/
compact?: boolean;
/**
* Prevents user interaction with the switch and blocks all click and keyboard events while it is disabled.
* @default false
*/
disabled?: boolean;
/**
* Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values.
* @default false
*/
hideLabel?: BreakpointCustomizable<boolean>;
/**
* Disables the switch and shows a loading spinner to indicate an ongoing asynchronous toggle operation.
* @default false
*/
loading?: boolean;
/**
* Emitted when the user toggles the switch, carrying the new `checked` state in the event detail.
*/
onUpdate?: (event: CustomEvent<SwitchUpdateEventDetail>) => void;
/**
* Expands the space between the switch toggle and its label to fill the full available width of the container. Supports responsive breakpoint values.
* @default false
*/
stretch?: BreakpointCustomizable<boolean>;
} & {
children?: import("react").ReactNode | undefined;
} & import("react").RefAttributes<HTMLElement>>;