diff --git a/packages/smarthr-ui/src/components/Switch/Switch.tsx b/packages/smarthr-ui/src/components/Switch/Switch.tsx index ef84fa9f30..2b12292d95 100644 --- a/packages/smarthr-ui/src/components/Switch/Switch.tsx +++ b/packages/smarthr-ui/src/components/Switch/Switch.tsx @@ -55,14 +55,19 @@ type Props = InputHTMLAttributes & { export const Switch = forwardRef( ({ children, dangerouslyLabelHidden, className, id, ...props }, ref) => { const { wrapper, input, icon, iconWrapper } = useMemo(() => switchStyle(), []) - const ActualLabel = dangerouslyLabelHidden ? VisuallyHiddenText : Text const inputId = useId(id) return ( - - {children} - + {dangerouslyLabelHidden ? ( + + {children} + + ) : ( + + )} {/* eslint-disable-next-line smarthr/a11y-input-has-name-attribute */} - } & ComponentProps<'span'> - > -> = ({ as: Component = 'span', className, ...props }) => { +type Props = PropsWithChildren<{ + as?: T +}> & + ComponentProps + +export const VisuallyHiddenText = ({ + as: Component = 'span', + className, + ...props +}: Props) => { const styles = useMemo(() => visuallyHiddenText({ className }), [className]) return