Skip to content

refactor(clerk-js): Use min height vs empty element for UserProfile #6363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 21, 2025
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/smart-emus-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Refactor UserPreview to use min-height vs empty element to remove extra leading space
24 changes: 11 additions & 13 deletions packages/clerk-js/src/ui/elements/UserPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,16 @@ export const UserPreview = (props: UserPreviewProps) => {
elementId={descriptors.userPreview.setId(elementId)}
align='center'
as='span'
sx={[t => ({ minWidth: '0px', width: 'fit-content', gap: t.space.$4 }), sx]}
sx={[
t => ({
minWidth: '0px',
width: 'fit-content',
gap: t.space.$4,
// We reserve space for the avatar if it is not visible
minHeight: imageUrl && !showAvatar ? getAvatarSizes(t) : undefined,
}),
sx,
]}
{...rest}
>
{/*Do not attempt to render or reserve space based on height if image url is not defined*/}
Expand Down Expand Up @@ -122,18 +131,7 @@ export const UserPreview = (props: UserPreviewProps) => {
</Flex>
)}
</Flex>
) : (
// Reserve layout space when avatar is not visible
<Flex
elementDescriptor={descriptors.userPreviewAvatarContainer}
elementId={descriptors.userPreviewAvatarContainer.setId(elementId)}
justify='center'
as='span'
sx={t => ({
height: getAvatarSizes(t),
})}
/>
)
) : null
) : null}

<Flex
Expand Down
Loading