Skip to content

Commit

Permalink
fix(FormControl): fix spacing in vertical layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
hussam-i-am committed Jan 29, 2025
1 parent d14c48c commit 0e2dcd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-snakes-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

fix(FormControl): fix spacing in vertical layouts"
14 changes: 5 additions & 9 deletions packages/react/src/FormControl/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ const FormControl = React.forwardRef<HTMLDivElement, FormControlProps>(
<StyledVerticalLayout
ref={ref}
data-has-label={!isLabelHidden ? '' : undefined}
sx={sx}
sx={
enabled
? sx
: {...(isLabelHidden ? {'> *:not(label) + *': {marginTop: 1}} : {'> * + *': {marginTop: 1}}), ...sx}
}
className={clsx(className, {
[classes.ControlVerticalLayout]: enabled,
})}
Expand Down Expand Up @@ -268,14 +272,6 @@ const StyledVerticalLayout = toggleStyledComponent(
flex-direction: column;
align-items: flex-start;
& > *:not(label) + * {
margin-top: var(--base-size-4);
}
&:where([data-has-label]) > * + * {
margin-top: var(--base-size-4);
}
${sx}
`,
)
Expand Down

0 comments on commit 0e2dcd9

Please sign in to comment.