import * as React from 'react'; import type { BaseUIComponentProps, NonNativeButtonProps } from "../../utils/types.js"; import type { FieldRoot } from "../../field/root/FieldRoot.js"; import { REASONS } from "../../utils/reasons.js"; import type { BaseUIChangeEventDetails } from "../../types/index.js"; /** * Represents the switch itself. * Renders a `` element and a hidden `` beside. * * Documentation: [Base UI Switch](https://base-ui.com/react/components/switch) */ export declare const SwitchRoot: React.ForwardRefExoticComponent>; export interface SwitchRootState extends FieldRoot.State { /** * Whether the switch is currently active. */ checked: boolean; /** * Whether the component should ignore user interaction. */ disabled: boolean; /** * Whether the user should be unable to activate or deactivate the switch. */ readOnly: boolean; /** * Whether the user must activate the switch before submitting a form. */ required: boolean; } export interface SwitchRootProps extends NonNativeButtonProps, Omit, 'onChange'> { /** * The id of the switch element. */ id?: string; /** * Whether the switch is currently active. * * To render an uncontrolled switch, use the `defaultChecked` prop instead. */ checked?: boolean; /** * Whether the switch is initially active. * * To render a controlled switch, use the `checked` prop instead. * @default false */ defaultChecked?: boolean; /** * Whether the component should ignore user interaction. * @default false */ disabled?: boolean; /** * A ref to access the hidden `` element. */ inputRef?: React.Ref; /** * Identifies the field when a form is submitted. */ name?: string; /** * Event handler called when the switch is activated or deactivated. */ onCheckedChange?: (checked: boolean, eventDetails: SwitchRoot.ChangeEventDetails) => void; /** * Whether the user should be unable to activate or deactivate the switch. * @default false */ readOnly?: boolean; /** * Whether the user must activate the switch before submitting a form. * @default false */ required?: boolean; /** * The value submitted with the form when the switch is off. * By default, unchecked switches do not submit any value, matching native checkbox behavior. */ uncheckedValue?: string; } export type SwitchRootChangeEventReason = typeof REASONS.none; export type SwitchRootChangeEventDetails = BaseUIChangeEventDetails; export declare namespace SwitchRoot { type State = SwitchRootState; type Props = SwitchRootProps; type ChangeEventReason = SwitchRootChangeEventReason; type ChangeEventDetails = SwitchRootChangeEventDetails; }