Skip to content

feat(Card): hover state for clickable cards#151

Merged
corbanbrook merged 2 commits intov4from
feat/card-hover-border
May 6, 2026
Merged

feat(Card): hover state for clickable cards#151
corbanbrook merged 2 commits intov4from
feat/card-hover-border

Conversation

@yigiterdev
Copy link
Copy Markdown
Member

@yigiterdev yigiterdev commented May 6, 2026

Summary

  • Replaced the hover:opacity-80 affordance on clickable cards with a 2px outline in border-hover
  • On hover, the underlying 1px border becomes transparent so the outline reads as a single edge (not a layered shadow under the border)
  • Added a ClickableHover story covering all three variants

Why outline instead of a thicker border?

A border-1border-2 swap on hover causes a 1px layout shift on every hover/leave because the border participates in the box model. outline lives outside the box model, so swapping outline-2 on/off doesn't reflow content. outline-offset-0 keeps it tight to the edge so it reads as a border thickening, and modern browsers follow border-radius on outlines automatically.

border-transparent on hover hides the 1px card border underneath the new outline — without it, the 1px border + 2px outline stack visually like a faint shadow.

Trade-off

When a card is both :hover and :focus-visible, hover:outline-offset-0 overrides focusRingVariants' outline-offset-2, so the focus ring snaps tight on hover. Acceptable for now; if it ever bothers us we can swap the hover affordance to ring (box-shadow) so the two states use different properties.

Screen.Recording.2026-05-06.at.13.05.05.mov

yigiterdev and others added 2 commits May 6, 2026 13:09
Replace the opacity-80 hover with an outline-based hover affordance:
- 2px outline in border-hover, offset 0
- border becomes transparent on hover so it doesn't read as a layered shadow under the outline

Used outline (not a thicker border) to avoid the 1px layout shift that
border-1 → border-2 would cause on every hover/leave.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Switches the clickable hover affordance from `outline` to `ring`
(box-shadow) so it doesn't share the `outline` property with the
focus-visible ring. Hover and focus can now both render without
either overriding the other's offset/color.

Per Corban's review on #151.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@corbanbrook corbanbrook merged commit f6bb167 into v4 May 6, 2026
1 check passed
@corbanbrook corbanbrook deleted the feat/card-hover-border branch May 6, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants