forward switch ref

This commit is contained in:
jeffvli
2025-10-08 21:38:16 -07:00
parent 53daa90bff
commit 076710672c
+19 -15
View File
@@ -1,23 +1,27 @@
import type { SwitchProps as MantineSwitchProps } from '@mantine/core';
import { Switch as MantineSwitch } from '@mantine/core';
import { forwardRef, Ref } from 'react';
import styles from './switch.module.css';
type SwitchProps = MantineSwitchProps;
export const Switch = ({ classNames, ...props }: SwitchProps) => {
return (
<MantineSwitch
classNames={{
input: styles.input,
root: styles.root,
thumb: styles.thumb,
track: styles.track,
...classNames,
}}
withThumbIndicator={false}
{...props}
/>
);
};
export const Switch = forwardRef(
({ classNames, ...props }: SwitchProps, ref: Ref<HTMLInputElement>) => {
return (
<MantineSwitch
classNames={{
input: styles.input,
root: styles.root,
thumb: styles.thumb,
track: styles.track,
...classNames,
}}
ref={ref}
withThumbIndicator={false}
{...props}
/>
);
},
);