mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
forward switch ref
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
import type { SwitchProps as MantineSwitchProps } from '@mantine/core';
|
import type { SwitchProps as MantineSwitchProps } from '@mantine/core';
|
||||||
|
|
||||||
import { Switch as MantineSwitch } from '@mantine/core';
|
import { Switch as MantineSwitch } from '@mantine/core';
|
||||||
|
import { forwardRef, Ref } from 'react';
|
||||||
|
|
||||||
import styles from './switch.module.css';
|
import styles from './switch.module.css';
|
||||||
|
|
||||||
type SwitchProps = MantineSwitchProps;
|
type SwitchProps = MantineSwitchProps;
|
||||||
|
|
||||||
export const Switch = ({ classNames, ...props }: SwitchProps) => {
|
export const Switch = forwardRef(
|
||||||
|
({ classNames, ...props }: SwitchProps, ref: Ref<HTMLInputElement>) => {
|
||||||
return (
|
return (
|
||||||
<MantineSwitch
|
<MantineSwitch
|
||||||
classNames={{
|
classNames={{
|
||||||
@@ -16,8 +18,10 @@ export const Switch = ({ classNames, ...props }: SwitchProps) => {
|
|||||||
track: styles.track,
|
track: styles.track,
|
||||||
...classNames,
|
...classNames,
|
||||||
}}
|
}}
|
||||||
|
ref={ref}
|
||||||
withThumbIndicator={false}
|
withThumbIndicator={false}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
},
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user