Skip to content
fayeuiStatic / 0.1.0
LLMs
API / Static edition

@fayegram-ai/faye-ui/controls/switch

Public exports and dependency-resolved component properties, with usage and rendering guidance.

Import

import { Switch } from '@fayegram-ai/faye-ui/controls/switch';

Usage and behavior guide · API JSON

This entry declares a client boundary. Follow the rendering guide for framework integration.

Public exports

NameKindResolved declaration type
Switchvalue{ readonly Root: { (input: Omit<import("@base-ui/react").SwitchRootProps, "ref"> & import("react").RefAttributes<HTMLElement> & { variants?: { readonly size?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVariant<"switch", "size"> | undefined; readonly tone?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVariant<"switch", "tone"> | undefined; } | undefined; }): import("react").ReactElement; displayName: string; }; readonly Thumb: { (input: Omit<import("@base-ui/react").SwitchThumbProps, "ref"> & import("react").RefAttributes<HTMLSpanElement> & { variants?: { readonly size?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVariant<"switch", "size"> | undefined; readonly tone?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVari… (full type in API JSON)

Switch

Public component; use the linked family guide for complete composition and behavior.

Dependency-resolved declaration properties. Common React/native HTML attributes are omitted from the table; use the full declaration and React/native references. Generic and union restrictions remain authoritative in TypeScript.

Switch.Root

PropertyRequiredTypeMeaning
checkedNoboolean | undefinedWhether the switch is currently active. To render an uncontrolled switch, use the defaultChecked prop instead.
classNameNostring | ((state: SwitchRootState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state.
defaultCheckedNoboolean | undefinedWhether the switch is initially active. To render a controlled switch, use the checked prop instead.
disabledNoboolean | undefinedWhether the component should ignore user interaction.
formNostring | undefinedIdentifies the form that owns the hidden input. Useful when the switch is rendered outside the form.
idNostring | undefinedThe id of the hidden input element. When nativeButton is true, the id is applied to the root element.
inputRefNoRef<HTMLInputElement> | undefinedA ref to access the hidden <input> element.
nameNostring | undefinedIdentifies the field when a form is submitted.
nativeButtonNoboolean | undefinedWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
onCheckedChangeNo((checked: boolean, eventDetails: SwitchRoot.ChangeEventDetails) => void) | undefinedEvent handler called when the switch is activated or deactivated.
readOnlyNoboolean | undefinedWhether the user should be unable to activate or deactivate the switch.
renderNoReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchRootState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
requiredNoboolean | undefinedWhether the user must activate the switch before submitting a form.
styleNoCSSProperties | ((state: SwitchRootState) => React.CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state.
uncheckedValueNostring | undefinedThe value submitted with the form when the switch is off. By default, unchecked switches do not submit any value, matching native checkbox behavior.
valueNostring | undefinedThe value submitted with the form when the switch is on. By default, switch submits the "on" value, matching native checkbox behavior.
variantsNo{ readonly size?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVariant<"switch", "size"> | undefined; readonly tone?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVariant<"switch", "tone"> | undefined; } | undefinedSee the usage contract and declaration.

Switch.Thumb

PropertyRequiredTypeMeaning
classNameNostring | ((state: SwitchThumbState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state.
renderNoReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchThumbState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
styleNoCSSProperties | ((state: SwitchThumbState) => React.CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state.
variantsNo{ readonly size?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVariant<"switch", "size"> | undefined; readonly tone?: import("@fayegram-ai/faye-ui/contracts/visual-variants").VisualVariant<"switch", "tone"> | undefined; } | undefinedSee the usage contract and declaration.

Defaults and customization

Descriptor defaults: {"size":"md","tone":"neutral"}. Parts: root, thumb. Explicit instance props take precedence over configured defaults.

Use semantic tokens, public part hooks and customization sheets. Keep visual configuration separate from application state.

State, events and accessibility

For interactive controls, pair a controlled value/open prop with its corresponding change callback; default props initialize uncontrolled state. Keep application validation and submission policy explicit. Name controls with visible labels, name icon-only actions on the button, and preserve focus and dismissal behavior when replacing parts. Use native form names and submit/reset types where supported. See the usage guide for component-specific behavior and live examples.

Declaration authority

Generated from packages/faye-ui/dist/controls/switch.d.ts after the semantic package build. Common native/React attributes are intentionally omitted from property tables. Generic overloads, discriminated unions and complete inherited attributes remain authoritative in installed TypeScript declarations. React DOM attributes and Base UI component contracts describe the inherited foundations.