diff --git a/.changeset/kind-melons-own.md b/.changeset/kind-melons-own.md new file mode 100644 index 00000000000..abf65ebc648 --- /dev/null +++ b/.changeset/kind-melons-own.md @@ -0,0 +1,5 @@ +--- +'@clerk/ui': patch +--- + +Fix checkbox default styles when using the simple theme. diff --git a/packages/ui/src/baseTheme.ts b/packages/ui/src/baseTheme.ts index c4ccb3b8018..5e7d09c9fd8 100644 --- a/packages/ui/src/baseTheme.ts +++ b/packages/ui/src/baseTheme.ts @@ -60,6 +60,21 @@ const checkboxShadowStyles = ( }; }; +const checkboxBaseStyles = (theme: InternalTheme) => ({ + padding: theme.space.$1, + width: theme.sizes.$3x5, + height: theme.sizes.$3x5, + appearance: 'none' as const, + borderRadius: theme.radii.$sm, + backgroundSize: `${theme.sizes.$2} ${theme.sizes.$2}`, + backgroundPosition: 'center', + backgroundRepeat: 'no-repeat', + '&:checked': { + backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 8 8'%3E%3Cpath fill='${theme.colors.$white}' fill-rule='evenodd' d='M7.712.233a.889.889 0 0 1 .055 1.256C6.742 2.61 6.249 3.291 5.508 4.615c-.279.5-.589 1.194-.835 1.784a36.761 36.761 0 0 0-.382.95l-.021.057-.006.014-.001.003a.89.89 0 0 1-1.504.27L.218 4.765A.889.889 0 1 1 1.56 3.6l1.591 1.834c.235-.548.524-1.181.806-1.685.807-1.445 1.38-2.239 2.499-3.46A.889.889 0 0 1 7.712.234Z' clip-rule='evenodd'/%3E%3C/svg%3E")`, + backgroundColor: theme.colors.$primary500, + }, +}); + const inputStyles = (theme: InternalTheme) => ({ borderWidth: 0, ...inputShadowStyles(theme, { @@ -177,6 +192,7 @@ const clerkTheme: Appearance = { }, }, checkbox: { + ...checkboxBaseStyles(theme), ...checkboxShadowStyles(theme, { idle1: theme.colors.$neutralAlpha150, idle2: theme.colors.$neutralAlpha100, @@ -184,19 +200,10 @@ const clerkTheme: Appearance = { hover2: theme.colors.$neutralAlpha150, focus: theme.colors.$neutralAlpha150, }), - padding: theme.space.$1, - width: theme.sizes.$3x5, - height: theme.sizes.$3x5, - appearance: 'none', - borderRadius: theme.radii.$sm, border: 'none', - backgroundSize: `${theme.sizes.$2} ${theme.sizes.$2}`, - backgroundPosition: 'center', - backgroundRepeat: 'no-repeat', '&:checked': { - backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 8 8'%3E%3Cpath fill='${theme.colors.$white}' fill-rule='evenodd' d='M7.712.233a.889.889 0 0 1 .055 1.256C6.742 2.61 6.249 3.291 5.508 4.615c-.279.5-.589 1.194-.835 1.784a36.761 36.761 0 0 0-.382.95l-.021.057-.006.014-.001.003a.89.89 0 0 1-1.504.27L.218 4.765A.889.889 0 1 1 1.56 3.6l1.591 1.834c.235-.548.524-1.181.806-1.685.807-1.445 1.38-2.239 2.499-3.46A.889.889 0 0 1 7.712.234Z' clip-rule='evenodd'/%3E%3C/svg%3E")`, + ...checkboxBaseStyles(theme)['&:checked'], borderColor: theme.colors.$transparent, - backgroundColor: theme.colors.$primary500, }, }, tagInputContainer: { diff --git a/packages/ui/src/elements/FieldControl.tsx b/packages/ui/src/elements/FieldControl.tsx index b6b659ded6f..d2f7444ceae 100644 --- a/packages/ui/src/elements/FieldControl.tsx +++ b/packages/ui/src/elements/FieldControl.tsx @@ -230,7 +230,6 @@ const CheckboxIndicator = forwardRef( elementId={elementId || descriptors.formFieldInput.setId(formField.fieldId)} focusRing={false} sx={t => ({ - width: 'fit-content', flexShrink: 0, marginTop: t.space.$0x5, })} diff --git a/packages/ui/src/primitives/Input.tsx b/packages/ui/src/primitives/Input.tsx index 632b9efce53..6ef03a6e9f2 100644 --- a/packages/ui/src/primitives/Input.tsx +++ b/packages/ui/src/primitives/Input.tsx @@ -18,8 +18,21 @@ const { applyVariants, filterProps } = createVariants((theme, props) => ({ outlineOffset: '2px', maxHeight: theme.sizes.$9, width: props.type === 'checkbox' ? theme.sizes.$4 : '100%', - aspectRatio: props.type === 'checkbox' ? '1/1' : 'unset', accentColor: theme.colors.$primary500, + ...(props.type === 'checkbox' + ? { + appearance: 'none', + height: theme.sizes.$4, + padding: theme.space.$1, + backgroundSize: `${theme.sizes.$2} ${theme.sizes.$2}`, + backgroundPosition: 'center', + backgroundRepeat: 'no-repeat', + '&:checked': { + backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 8 8'%3E%3Cpath fill='${theme.colors.$white}' fill-rule='evenodd' d='M7.712.233a.889.889 0 0 1 .055 1.256C6.742 2.61 6.249 3.291 5.508 4.615c-.279.5-.589 1.194-.835 1.784a36.761 36.761 0 0 0-.382.95l-.021.057-.006.014-.001.003a.89.89 0 0 1-1.504.27L.218 4.765A.889.889 0 1 1 1.56 3.6l1.591 1.834c.235-.548.524-1.181.806-1.685.807-1.445 1.38-2.239 2.499-3.46A.889.889 0 0 1 7.712.234Z' clip-rule='evenodd'/%3E%3C/svg%3E")`, + backgroundColor: theme.colors.$primary500, + }, + } + : {}), ...common.textVariants(theme).body, ...common.disabled(theme), // This is a workaround to prevent zooming on iOS when focusing an input @@ -40,6 +53,7 @@ const { applyVariants, filterProps } = createVariants((theme, props) => ({ variant: { default: { ...common.borderVariants(theme, props).normal, + ...(props.type === 'checkbox' ? { borderRadius: theme.radii.$sm } : {}), }, unstyled: { borderWidth: 0,