Add switch component

This commit is contained in:
jeffvli
2022-10-28 13:03:10 -07:00
parent 00710125d3
commit b3f4cfee5d
2 changed files with 28 additions and 0 deletions
+1
View File
@@ -8,3 +8,4 @@ export * from './input';
export * from './segmented-control';
export * from './dropdown-menu';
export * from './toast';
export * from './switch';
+27
View File
@@ -0,0 +1,27 @@
import styled from '@emotion/styled';
import {
Switch as MantineSwitch,
SwitchProps as MantineSwitchProps,
} from '@mantine/core';
type SwitchProps = MantineSwitchProps;
const StyledSwitch = styled(MantineSwitch)`
& .mantine-Switch-track {
background-color: var(--switch-track-bg);
}
& .mantine-Switch-input {
&:checked + .mantine-Switch-track {
background-color: var(--switch-track-enabled-bg);
}
}
& .mantine-Switch-thumb {
background-color: var(--switch-thumb-bg);
}
`;
export const Switch = ({ ...props }: SwitchProps) => {
return <StyledSwitch {...props} />;
};