feat(ui): add tooltip to IAISwitch

This commit is contained in:
psychedelicious 2023-06-03 22:47:51 +10:00
parent 4f7820719b
commit 2270c270ef

View File

@ -5,6 +5,7 @@ import {
FormLabelProps,
Switch,
SwitchProps,
Tooltip,
} from '@chakra-ui/react';
import { memo } from 'react';
@ -13,6 +14,7 @@ interface Props extends SwitchProps {
width?: string | number;
formControlProps?: FormControlProps;
formLabelProps?: FormLabelProps;
tooltip?: string;
}
/**
@ -25,9 +27,11 @@ const IAISwitch = (props: Props) => {
width = 'auto',
formControlProps,
formLabelProps,
tooltip,
...rest
} = props;
return (
<Tooltip label={tooltip} hasArrow placement="top" isDisabled={!tooltip}>
<FormControl
isDisabled={isDisabled}
width={width}
@ -43,6 +47,7 @@ const IAISwitch = (props: Props) => {
)}
<Switch {...rest} />
</FormControl>
</Tooltip>
);
};