'use client'; import { SwitchField, SwitchButton, type SwitchFieldProps, type ValidationResult } from 'react-aria-components/Switch'; import './Switch.css'; import {Description, FieldError} from './Form'; import type {ReactNode} from 'react'; export interface SwitchProps extends Omit { children: ReactNode; description?: string; errorMessage?: string | ((validation: ValidationResult) => string); } export function Switch({children, description, errorMessage, ...props}: SwitchProps) { return ( {({isSelected, isDisabled}) => ( <>
{children} )} {description && {description}} {errorMessage} ); }