Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(core): remove ClickableCard hover ring by dropping invisible borders (#3712)

Kenton Quatman73cab9a0f9e4
diff --git a/.changeset/clickable-card-border-hover.md b/.changeset/clickable-card-border-hover.md
new file mode 100644
index 0000000000..93fa4e05da
--- /dev/null
+++ b/.changeset/clickable-card-border-hover.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] ClickableCard: remove the faint hover "ring" on borderless variants (everything except `default`) by dropping their invisible border. The `default` variant now draws its border inside the padding so outer dimensions stay identical across variants, and its border color emphasizes on hover. (#3712)
+@kentonquatman
diff --git a/packages/core/src/ClickableCard/ClickableCard.tsx b/packages/core/src/ClickableCard/ClickableCard.tsx
index 676d58b5d5..9802ef9371 100644
--- a/packages/core/src/ClickableCard/ClickableCard.tsx
+++ b/packages/core/src/ClickableCard/ClickableCard.tsx
@@ -31,7 +31,12 @@
import {type ReactNode, type MouseEvent, useRef, type Ref} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {colorVars, durationVars, easeVars} from '../theme/tokens.stylex';
+import {
+ borderVars,
+ colorVars,
+ durationVars,
+ easeVars,
+} from '../theme/tokens.stylex';
import type {SizeValue, SpacingStep} from '../utils/types';
import {mergeProps, mergeRefs} from '../utils';
import {Card} from '../Card/Card';
@@ -66,7 +71,6 @@ const styles = stylex.create({
content: '""',
position: 'absolute',
inset: 0,
- borderRadius: 'inherit',
pointerEvents: 'none',
transitionProperty: 'background-color',
transitionDuration: durationVars['--duration-fast'],
@@ -84,6 +88,38 @@ const styles = stylex.create({
},
},
},
+ // Borderless variants (everything except `default`): drop the transparent
+ // 1px border Card applies. The overlay is inset to the padding box — inside
+ // that border — so a transparent border strip stays untinted on hover and
+ // reads as a faint ring. With no border, the overlay covers the full box
+ // edge-to-edge and the ring disappears.
+ borderless: {
+ borderWidth: 0,
+ },
+ // Bordered variant (`default`): draw the 1px border *within* the padding by
+ // subtracting the border width from every side. Total inset (border +
+ // padding) then equals the borderless variants' padding, so content geometry
+ // and outer dimensions stay identical across all variants. The border rests
+ // at the subtle token and emphasizes on hover.
+ bordered: {
+ borderColor: colorVars['--color-border'],
+ paddingInlineStart: `calc(var(--container-padding-inline-start) - ${borderVars['--border-width']})`,
+ paddingInlineEnd: `calc(var(--container-padding-inline-end) - ${borderVars['--border-width']})`,
+ paddingBlockStart: `calc(var(--container-padding-block-start) - ${borderVars['--border-width']})`,
+ paddingBlockEnd: `calc(var(--container-padding-block-end) - ${borderVars['--border-width']})`,
+ transitionProperty: 'border-color',
+ transitionDuration: durationVars['--duration-fast'],
+ transitionTimingFunction: easeVars['--ease-standard'],
+ },
+ // Emphasize the bordered variant's border on hover. Guarded by
+ // @media (hover: hover) so touch devices don't get a stuck hover state.
+ borderedHoverOnPointer: {
+ '@media (hover: hover)': {
+ ':hover': {
+ borderColor: colorVars['--color-border-emphasized'],
+ },
+ },
+ },
disabled: {
cursor: 'not-allowed',
opacity: 0.5,
@@ -248,6 +284,11 @@ export function ClickableCard({
const isLink = href != null;
+ // Only the `default` variant has a visible border. Card draws a transparent
+ // 1px border on every other variant purely to avoid layout jitter; we drop
+ // it here so the hover overlay covers the full box with no untinted ring.
+ const hasBorder = variant === 'default';
+
return (
<Card
ref={mergeRefs(ref, containerRef)}
@@ -264,8 +305,10 @@ export function ClickableCard({
[
styles.interactive,
styles.focusWithin,
+ hasBorder ? styles.bordered : styles.borderless,
!isDisabled && styles.overlay,
!isDisabled && styles.hoverOnPointer,
+ !isDisabled && hasBorder && styles.borderedHoverOnPointer,
isDisabled && styles.disabled,
xstyleProp,
] as unknown as StyleXStyles