diff --git a/packages/components/src/Switch.tsx b/packages/components/src/Switch.tsx index 803548edb..f8ffbdaf3 100644 --- a/packages/components/src/Switch.tsx +++ b/packages/components/src/Switch.tsx @@ -12,6 +12,7 @@ const SIZE = 18 export interface SwitchProps extends Assign, BoxOwnProps> { + labelPosition?: 'start' | 'end', label?: string } @@ -23,7 +24,7 @@ export interface SwitchProps */ export const Switch: ForwardRef = React.forwardRef(function Switch( - { className, label, sx, variant = 'switch', ...rest }, + { className, label, sx, labelPosition = 'end', variant = 'switch', ...rest }, ref ) { const __css: ThemeUICSSObject = { @@ -33,7 +34,6 @@ export const Switch: ForwardRef = borderRadius: SIZE, height: SIZE + GUTTER * 2, width: SIZE * 2 + GUTTER * 2, - mr: 2, 'input:disabled ~ &': { opacity: 0.5, cursor: 'not-allowed', @@ -58,34 +58,45 @@ export const Switch: ForwardRef = }, } + // Inner really checkbox (but hidden) + const reallyHiddenCheckbox = ( + + ); + + // Switch just for show + const switchForShow = ( + + + + ); + return ( -