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
  • Accessibility
  • Figma Flashcard cards 262:16347
  • packages/ui/src/components/Flashcard

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

tsx
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.

bash
pnpm add @nuton/ui @nuton/tokens @remixicon/react
tsx
import '@nuton/tokens/tokens.css'
import '@nuton/ui/styles.css'

Usage

tsx
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 FlashcardDeck for more than one card. It adds previous and next buttons, the position (“Card 3 of 12”) and arrow-key movement.
  • Add a hint when the question is hard. People open it on purpose, so it doesn't give the answer away.
  • Use note for a short takeaway under the answer (Figma “Remember: …”).
  • Pass onRate when 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

Answer side with a note

Press to see the question again

Remember: Design starts with humans, not screens.

Question with the hint open

Click to see answer

Hint

Think about who comes first: the product or the person using it?
PartMeasurement
CardFills its container; min height 335, radius 24, padding 24/40, gap 16, 1px Stroke/Soft-200, Bg/Weak-50
Question · answerTitle/H6 (Fraunces 20/28), Text/Strong-950
Prompt“Click to see answer”, Paragraph/X Small, Text/Sub-600
Hint buttonButton sm, lighter, rounded; 12 from the left, 16 from the bottom
Hint · noteDivider, then Label/X Small title and Paragraph/X Small text
Deck nav row10 below the card; 36 × 36 icon buttons and Label/Medium position text, spaced apart

States and interactions

Click to see answer

Question (Figma States=Question)The default side. The whole card is the flip button.

Press to see the question again

Answer (Figma States=Answer)“Answer” eyebrow, the answer and an optional note.

Click to see answer

Hint

A hint
Question + HintThe hint opens below the prompt; the button reads Hide hint.

Click to see answer

Focus (code-only)Figma has no focused card. Code adds a State/Primary/Base border and the primary focus halo.

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.

Click to see answer

Card 1 of 4

Controlled deck

Control index to start a deck again or to remember where someone stopped.

Click to see answer

Card 1 of 4

API reference

Flashcard props

Flashcard props
PropTypeDefaultDescription
frontrequiredReactNode—The question (Figma States=Question). It names the flip button, so keep it short and plain.
backrequiredReactNode—The answer (Figma States=Answer).
hintReactNode—Adds the Hint button and the hint shown under the prompt (Figma States=Question + Hint).
noteReactNode—A line under the answer after "Remember:".
flippedboolean—Shows the answer side (controlled).
defaultFlippedbooleanfalseInitially shows the answer side (uncontrolled).
onFlippedChange(flipped: boolean) => void—Called when the person flips the card.
hintOpenboolean—Shows the hint (controlled).
defaultHintOpenbooleanfalseInitially shows the hint (uncontrolled).
onHintOpenChange(open: boolean) => void—Called when the hint is shown or hidden.
labelsPartial<FlashcardLabels>—Overrides for flipPrompt, flipBackPrompt, question, answer, showHint, hideHint, hint and note.
…div propsHTMLAttributes<HTMLDivElement>—className and other attributes go to the root. The ref points at the root.

FlashcardDeck props

FlashcardDeck props
PropTypeDefaultDescription
cardsrequiredFlashcardData[]—The cards in order: { id?, front, back, hint?, note? }.
indexnumber—Zero-based card shown (controlled).
defaultIndexnumber0Initial card (uncontrolled).
onIndexChange(index: number) => void—Called when the person moves through the deck.
showProgressbooleantrueShows 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).
advanceOnRatebooleantrueMoves to the next card after a rating.
labelsPartial<FlashcardDeckLabels>—Overrides for deck, previous, next, position(current, total), progress, known, review and rating.
cardLabelsPartial<FlashcardLabels>—Label overrides passed to every card.
…section propsHTMLAttributes<HTMLElement>—className, onKeyDown and other attributes go to the section. The ref points at it.

Accessibility

Keyboard

KeyBehaviour
Enter / SpaceFlips the focused card
TabMoves 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

FigmaValuesCode
Flashcard cards · StatesQuestion · Answer · Question + Hintflipped · hintOpen
“Remember:” rowTextnote
Nav row in the lesson framesArrows and “Card 1 of 10”FlashcardDeck
(none)No progress bar, rating or focus stateshowProgress, 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

DoAsk one short question per card People can recall the answer before flipping, and screen readers read the question quickly.

Click to see answer

Don'tPut a paragraph on the question side The whole paragraph becomes the button name and is read on every focus.

Click to see answer

Hint

Think of hob knobs and burners.
DoGive a hint that points the way A hint helps people think, so they still recall the answer themselves.

Click to see answer

Hint

Controls laid out like the things they control.
Don'tPut the answer in the hint It skips the recall step that makes flashcards work.