GitHub

Flip Card

Card with front and back that flips on interaction

Basic Usage

Loading...

Installation

pnpm add @corew500/ui

Usage

import { FlipCard } from "@corew500/ui/flip-card"

<FlipCard>Content</FlipCard>

Variants

flipCardVariants

AxisValuesDefault
size
smdefaultlgfull
default

API Reference

Props

PropTypeDefaultDescription
triggerenumhoverHow to trigger the flip
directionenumhorizontalDirection of the flip
flippedenumControlled flipped state
onFlippedChange(flipped: boolean) => voidCallback when flipped state changes
defaultFlippedenumfalseDefault flipped state (uncontrolled)
sizeenum

Accessibility

Keyboard Navigation

  • `FlipCardTrigger` renders a native `<button>` for keyboard and screen reader access
  • Hidden face is marked with `inert` attribute, removing it from tab order and screen readers
  • For hover trigger, include `FlipCardTrigger` in each face for keyboard-only users

Screen Readers

  • - Root container has `role="group"` and `aria-roledescription="flip card"` when an accessible name is provided
  • Provide `aria-label` or `aria-labelledby` on the FlipCard for best screen reader experience (e.g., `<FlipCard aria-label="Product card">` announces "Product card, flip card")
  • Without an accessible name, `aria-roledescription` is omitted per ARIA spec requirements
  • Default `aria-label` on trigger is "Flip to back" / "Flip to front" based on state

Localization

Translatable Content

  • - Pass translated content to FlipCardFront and FlipCardBack children
  • If using text prompts like "Click to flip", ensure they're localized