Flashcard
Flashcard shows a question that flips to its answer. Use it, alone or in a deck, to help people recall what a lesson taught.
Beta until design confirms the code-only parts: the flip animation, the focus ring, the deck's progress bar and the Got it / Review again rating. Everything else on this page is implemented and tested.
Preview
Change the controls to try every supported combination. Click the card, or focus it and press Enter or Space, to flip it.
Click to see answer
import { Flashcard } from '@nuton/ui'
const [flipped, setFlipped] = useState(false)
<Flashcard
front="What is Human-Centered Design?"
back="A design approach that puts people’s needs, behaviours and experiences at the centre of every stage of the design process."
hint="Think about who comes first: the product or the person using it?"
note="Design starts with humans, not screens."
flipped={flipped}
onFlippedChange={setFlipped}
/>Installation
Availability
@nuton/ui and @nuton/tokens are private workspace packages and aren't published yet (D4, D12). Inside the Nuton monorepo, add them as workspace dependencies.
pnpm add @nuton/ui @nuton/tokens @remixicon/reactnpm install @nuton/ui @nuton/tokens @remixicon/reactyarn add @nuton/ui @nuton/tokens @remixicon/reactimport '@nuton/tokens/tokens.css'
import '@nuton/ui/styles.css'Usage
import { Flashcard, FlashcardDeck } from '@nuton/ui'
<Flashcard
front="What is Human-Centered Design?"
back="A design approach that puts people's needs at the centre of every stage."
hint="Who comes first: the product or the person?"
/>
<FlashcardDeck cards={cards} onRate={(rating, card) => save(card.id, rating)} />- Keep the question short. It is the flip button's accessible name, so it is read every time the card gets focus.
- Use a
FlashcardDeckfor more than one card. It adds previous and next buttons, the position (“Card 3 of 12”) and arrow-key movement. - Add a
hintwhen the question is hard. People open it on purpose, so it doesn't give the answer away. - Use
notefor a short takeaway under the answer (Figma “Remember: …”). - Pass
onRatewhen your app schedules reviews. Got it and Review again appear once the answer is shown.
Variants and sizes
Flashcard has one size: it fills its container (Figma 612px in a lesson, 704px in the component set). Figma's three states are the sides and the hint.
Question side
Click to see answer
<Flashcard
front="What is Human-Centered Design?"
back="A design approach that puts people first."
/>Answer side with a note
Press to see the question again
Remember: Design starts with humans, not screens.
<Flashcard
defaultFlipped
front="What is Human-Centered Design?"
back="A design approach that puts people's needs, behaviours and experiences at the centre of every stage of the design process."
note="Design starts with humans, not screens."
/>Question with the hint open
Click to see answer
Hint
<Flashcard
defaultHintOpen
front="What is Human-Centered Design?"
back="A design approach that puts people first."
hint="Think about who comes first: the product or the person using it?"
/>| Part | Measurement |
|---|---|
| Card | Fills its container; min height 335, radius 24, padding 24/40, gap 16, 1px Stroke/Soft-200, Bg/Weak-50 |
| Question · answer | Title/H6 (Fraunces 20/28), Text/Strong-950 |
| Prompt | “Click to see answer”, Paragraph/X Small, Text/Sub-600 |
| Hint button | Button sm, lighter, rounded; 12 from the left, 16 from the bottom |
| Hint · note | Divider, then Label/X Small title and Paragraph/X Small text |
| Deck nav row | 10 below the card; 36 × 36 icon buttons and Label/Medium position text, spaced apart |
States and interactions
Click to see answer
Press to see the question again
Click to see answer
Hint
Click to see answer
Motion
The card turns over on its vertical axis in --nu-duration-slow (300ms) with --nu-ease-standard (code-only). When people ask for reduced motion, the sides swap with no animation.
State tokens
Set on .nu-flashcard: --nu-flashcard-bg (Bg/Weak-50), -stroke (Stroke/Soft-200), -radius (24), -focus-stroke (State/Primary/Base), -focus-shadow (buttons/primary-focus), -duration (duration-slow) and -min-height (335px).
Figma discrepancies (pending a decision)
- The Figma set keeps a hidden dark “Back” frame from an older design (Instrument Sans, white text). It isn't implemented; every state uses the light “Front” frame.
- Figma writes “click to see answer” in lower case. Code starts it with a capital, and you can change it with
labels.flipPrompt. - The lesson frames show “Card 1 of 10” but no progress bar. The deck's progress bar is code-only; turn it off with
showProgress={false}.
Composition examples
Lesson deck with rating
After a lesson, a deck lets people check what they remember. Got it and Review again appear once the answer is shown, and move on to the next card.
Controlled deck
Control index to start a deck again or to remember where someone stopped.
API reference
Flashcard props
| Prop | Type | Default | Description |
|---|---|---|---|
frontrequired | ReactNode | — | The question (Figma States=Question). It names the flip button, so keep it short and plain. |
backrequired | ReactNode | — | The answer (Figma States=Answer). |
hint | ReactNode | — | Adds the Hint button and the hint shown under the prompt (Figma States=Question + Hint). |
note | ReactNode | — | A line under the answer after "Remember:". |
flipped | boolean | — | Shows the answer side (controlled). |
defaultFlipped | boolean | false | Initially shows the answer side (uncontrolled). |
onFlippedChange | (flipped: boolean) => void | — | Called when the person flips the card. |
hintOpen | boolean | — | Shows the hint (controlled). |
defaultHintOpen | boolean | false | Initially shows the hint (uncontrolled). |
onHintOpenChange | (open: boolean) => void | — | Called when the hint is shown or hidden. |
labels | Partial<FlashcardLabels> | — | Overrides for flipPrompt, flipBackPrompt, question, answer, showHint, hideHint, hint and note. |
…div props | HTMLAttributes<HTMLDivElement> | — | className and other attributes go to the root. The ref points at the root. |
FlashcardDeck props
| Prop | Type | Default | Description |
|---|---|---|---|
cardsrequired | FlashcardData[] | — | The cards in order: { id?, front, back, hint?, note? }. |
index | number | — | Zero-based card shown (controlled). |
defaultIndex | number | 0 | Initial card (uncontrolled). |
onIndexChange | (index: number) => void | — | Called when the person moves through the deck. |
showProgress | boolean | true | Shows the code-only progress bar above the card. |
onRate | (rating: 'known' | 'review', card, index) => void | — | Shows Got it and Review again once the answer is shown (code-only). |
advanceOnRate | boolean | true | Moves to the next card after a rating. |
labels | Partial<FlashcardDeckLabels> | — | Overrides for deck, previous, next, position(current, total), progress, known, review and rating. |
cardLabels | Partial<FlashcardLabels> | — | Label overrides passed to every card. |
…section props | HTMLAttributes<HTMLElement> | — | className, onKeyDown and other attributes go to the section. The ref points at it. |
Accessibility
Keyboard
| Key | Behaviour |
|---|---|
| Enter / Space | Flips the focused card |
| Tab | Moves from the card to the Hint button and the deck buttons |
| ← / → | In a deck: previous or next card |
Screen readers
Each side is a button named “Question: …” or “Answer: …” and described by the prompt. After a flip, focus moves to the side now shown, so its name is read. The hidden side is out of the accessibility tree. The deck is a named region; “Card 3 of 12” is announced politely when the card changes.
Focus
The card shows a State/Primary/Base border and the primary halo. At the start and end of a deck, the previous and next buttons stay focusable with aria-disabled, so focus is never lost.
Contrast and colour
Question and answer 17.93:1 on Bg/Weak-50; prompt 6.69:1. Nothing relies on colour: the side is named in text and the hint button's state uses aria-expanded and its label.
Touch and pointer
The whole card is the flip target. The hint and deck buttons are 36 × 36, above 24 × 24 (WCAG 2.5.8).
You must: keep each question short and unique, and don't put links or buttons inside front or back (they sit inside the flip button).
Figma mapping
| Figma | Values | Code |
|---|---|---|
| Flashcard cards · States | Question · Answer · Question + Hint | flipped · hintOpen |
| “Remember:” row | Text | note |
| Nav row in the lesson frames | Arrows and “Card 1 of 10” | FlashcardDeck |
| (none) | No progress bar, rating or focus state | showProgress, onRate, focus ring (code-only) |
Guidelines and related components
Use Flashcard for
- Recall practice after a lesson or before a quiz
- Key terms and short definitions
Don't use Flashcard for
- Questions with several answers to choose from (use Quiz)
- Long explanations (use the lesson text)
Do and don't
Click to see answer
Click to see answer
Click to see answer
Hint
Click to see answer
Hint