import { Field } from '@headlessui/react'; import React from 'react'; import type { ReactNode } from 'react'; import type { EitherInclusive, ExtractProps } from '../../util/utility-types'; type ToggleLabelProps = { /** * Visible text label for the toggle. */ children: ReactNode; /** * Additional classnames passed in for styling the toggle label. */ className?: string; }; type ToggleButtonProps = { /** * Additional classnames passed in for styling the toggle button. */ className?: string; /** * Whether toggle is checked or unchecked. */ checked: boolean; /** * Callback called when toggle state is changed. */ onChange: (checked: boolean) => void; /** * Whether toggle is disabled. */ disabled?: boolean; }; type ToggleProps = ToggleButtonProps & { children?: ReactNode; subLabel?: ReactNode; } & EitherInclusive<{ /** * Visible text label for the component. */ label: ReactNode; }, { /** * Aria-label to provide an accesible name for the text input if no visible label is provided. */ 'aria-label': string; }>; /** * ## Usage * * | Type/Use | Description | Example | * |----------|-------------|---------| * | Enable/Disable a feature | Turns a feature on or off. | Dark mode toggle in a settings menu. | * | Show/Hide content | Reveals or hides additional UI elements. | Show/hide advanced search filters. | * | Activate notifications | Turns notifications on or off. | Push notifications toggle in a mobile app. | * | Privacy & security settings | Adjusts user privacy or security preferences. | Allow/block location sharing. | * | Subscription/opt-in settings | Lets users opt in or out of subscriptions. | Newsletter sign-up toggle. | * | Account preferences | Changes user-specific account features. | Two-factor authentication toggle. | * | Mode switching | Switches between different UI modes. | Toggle between grid view and list view. | * | Accessibility options | Improves usability for accessibility. | High contrast mode toggle. | * * **NOTE**: This component requires a `label` or `aria-label` prop. * * ### Best Practices * * * Use only for binary yes/no or on/off options. * * Don't use a toggle to perform a single action. * * ## Content & Accessibility * * ### Do's * * * Write labels in sentence case. * * Use punctuation in full-sentence secondary labels, and punctuate all secondary labels in a list the same way. * * Ensure labels are clear without surrounding information for context. * * Include alt text for toggles that don't have a label. * * ### Don'ts * * * Don't add end punctuation to the primary label. * * Don't mix full-sentence and partial-sentence secondary labels. * * ## Resources * * * https://headlessui.dev/react/switch */ export declare const Toggle: { ({ label, subLabel, ...other }: ToggleProps): React.JSX.Element; displayName: string; Label: { ({ children, className }: ToggleLabelProps): React.JSX.Element; displayName: string; }; Button: { ({ className, checked, ...other }: ToggleButtonProps): React.JSX.Element; displayName: string; }; Wrapper: { (props: ExtractProps): React.JSX.Element; displayName: string; }; SubLabel: { ({ children, className }: ToggleLabelProps): React.JSX.Element; displayName: string; }; }; export {};