Skip to content

Commit 2b51e8f

Browse files
jluyauLFDanLu
andauthored
add extra conditional for icon-only Button styling (#3503)
* add extra conditional for icon-only Button styling * Update packages/@react-spectrum/button/src/Button.tsx Co-authored-by: Daniel Lu <[email protected]> Co-authored-by: Daniel Lu <[email protected]>
1 parent 2072a5a commit 2b51e8f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/@react-spectrum/button/src/Button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
5151
let {hoverProps, isHovered} = useHover({isDisabled});
5252
let {styleProps} = useStyleProps(otherProps);
5353
let hasLabel = useHasChild(`.${styles['spectrum-Button-label']}`, domRef);
54+
let hasIcon = useHasChild(`.${styles['spectrum-Icon']}`, domRef);
5455

5556
let buttonVariant = variant;
5657
if (VARIANT_MAPPING[variant]) {
@@ -70,7 +71,7 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
7071
`spectrum-Button--${buttonVariant}`,
7172
{
7273
'spectrum-Button--quiet': isQuiet,
73-
'spectrum-Button--iconOnly': !hasLabel,
74+
'spectrum-Button--iconOnly': hasIcon && !hasLabel,
7475
'is-disabled': isDisabled,
7576
'is-active': isPressed,
7677
'is-hovered': isHovered

0 commit comments

Comments
 (0)