Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kind-melons-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/ui': patch
---

Fix checkbox default styles when using the simple theme.
27 changes: 17 additions & 10 deletions packages/ui/src/baseTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -177,26 +192,18 @@ const clerkTheme: Appearance = {
},
},
checkbox: {
...checkboxBaseStyles(theme),
...checkboxShadowStyles(theme, {
idle1: theme.colors.$neutralAlpha150,
idle2: theme.colors.$neutralAlpha100,
hover1: theme.colors.$neutralAlpha300,
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: {
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/elements/FieldControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ const CheckboxIndicator = forwardRef<HTMLInputElement, CheckboxIndicatorProps>(
elementId={elementId || descriptors.formFieldInput.setId(formField.fieldId)}
focusRing={false}
sx={t => ({
width: 'fit-content',
flexShrink: 0,
marginTop: t.space.$0x5,
})}
Expand Down
16 changes: 15 additions & 1 deletion packages/ui/src/primitives/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
: {}),
...common.textVariants(theme).body,
...common.disabled(theme),
// This is a workaround to prevent zooming on iOS when focusing an input
Expand All @@ -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,
Expand Down
Loading