UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

43 lines 2.1 kB
import type { MouseEventHandler } from 'react'; import React from 'react'; import type { SxProp } from '../sx'; import type { CellAlignment } from '../DataTable/column'; export interface ToggleSwitchProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>, SxProp { /** The id of the DOM node that labels the switch */ ['aria-labelledby']: string; /** Uncontrolled - whether the switch is turned on */ defaultChecked?: boolean; /** Whether the switch is ready for user input */ disabled?: boolean; /** Whether the switch's value is being calculated */ loading?: boolean; /** Whether the switch is turned on */ checked?: boolean; /** The callback that is called when the switch is toggled on or off */ onChange?: (checked: boolean) => void; /** The callback that is called when the switch is clicked */ onClick?: MouseEventHandler; /** Size of the switch */ size?: 'small' | 'medium'; /** Whether the "on" and "off" labels should appear before or after the switch. * **This should only be changed when the switch's alignment needs to be adjusted.** For example: It needs to be left-aligned because the label appears above it and the caption appears below it. */ statusLabelPosition?: CellAlignment; /** * If the switch is in the loading state, this value controls the amount of delay in milliseconds before * the `loadingLabel` is announced to screen readers. * @default 2000 */ loadingLabelDelay?: number; /** The text to describe what is loading. It should be descriptive and not verbose. * This is primarily used for AT (screen readers) to convey what is currently loading. */ loadingLabel?: string; /** type of button to account for behavior when added to a form*/ buttonType?: 'button' | 'submit' | 'reset'; } declare const ToggleSwitch: React.ForwardRefExoticComponent<ToggleSwitchProps & { children?: React.ReactNode | undefined; } & React.RefAttributes<HTMLButtonElement>>; export default ToggleSwitch; //# sourceMappingURL=ToggleSwitch.d.ts.map