Flip Card
Basic Usage
Loading...
Installation
pnpm add @corew500/uiUsage
import { FlipCard } from "@corew500/ui/flip-card"
<FlipCard>Content</FlipCard>Variants
flipCardVariants
| Axis | Values | Default |
|---|---|---|
| size | smdefaultlgfull | default |
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| trigger | enum | hover | How to trigger the flip |
| direction | enum | horizontal | Direction of the flip |
| flipped | enum | — | Controlled flipped state |
| onFlippedChange | (flipped: boolean) => void | — | Callback when flipped state changes |
| defaultFlipped | enum | false | Default flipped state (uncontrolled) |
| size | enum | — | — |
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