Quiz cards — Article block
Proarticle-quiz-cards · for article, home, landing pages
Quiz cards
Questions as cards side by side: a light quiz of three to six questions that invites a try
Documentation
Installation
One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).
pnpm dlx shadcn-vue@latest add @trame/article-quiz-cardsUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import ArticleQuizCards from '@/components/trame/blocks/article/article-quiz-cards.vue'
const props = {
title: "Do you know how to care for your bag?",
lead: "Six questions, two minutes. Each answer is explained as you go.",
questions: [
{
question: "Which leather develops the most beautiful patina?",
choices: [
"Chrome-tanned leather",
"Vegetable-tanned leather"
],
answer: 1,
explanation: "Vegetable tanning lets the leather breathe: it darkens and softens with use, while coated leather stays as it is."
},
{
question: "How often should you condition a leather bag?",
choices: [
"Every week",
"Twice a year"
],
answer: 1,
explanation: "Twice a year is enough. Too much cream smothers the leather; too little dries it out."
}
],
results: [
{
min: 0,
title: "A good start",
text: "Our care guide is waiting for you: a ten-minute read, and your bag will thank you."
},
{
min: 3,
title: "You know the basics",
text: "Just a few more habits and your leather will age beautifully."
}
],
options: {
eyebrow: "Quiz"
}
}
</script>
<template>
<ArticleQuizCards v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordsthe quiz’s title ("Which leather is right for you?") |
| lead | string | Wordswhat it is and how long it takes |
| questions* | Question[] | the questions shown, in order |
| results | Result[] | what each score range means |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Question questions[] · 4 props
| Prop | Type | Description |
|---|---|---|
| question* | string | Wordsthe question |
| choices* | string[] | Wordsthe question’s choices, in order |
| answer* | number | the index (from 0) of the right choice |
| explanation* | string | Wordswhy it is the right one, shown after the visitor chooses |
Result results[] · 3 props
| Prop | Type | Description |
|---|---|---|
| min* | number | the lowest score (right answers) this message applies to |
| title* | string | Wordsthe result’s title |
| text | string | Wordsthe result’s text |
Options options · 2 props
| Prop | Type | Description |
|---|---|---|
| eyebrow | string | Wordsthe section ("Quiz") |
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a band of the page that redefines the theme surfaces inside it |
What it asks your app for
The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your word for an interface key, or undefined to keep the block’s own |
The words it says itself, in English and French; label(key) replaces any of them:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too many attempts, try again in a moment. | Trop de tentatives, réessayez dans un moment. |
Features
- Every word in the server HTML
- Same markup in Vue and React
- Theme tokens only: every theme, light and dark
- Shows what you give it, invents nothing
- Subtle motion: one short reveal; still under reduced motion
- Real buttons and links, a visible focus
A article section, for article, home, landing pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.
More article blocks
- List ranked: big numerals and pictures alternating sides: a ranking or a countdown the visitor reads with pleasure.
- Long guide toc rail: a long guide with several headings: a sticky "on this page" rail with the article’s dates beside the text.
- Passage strip cards: Equal excerpt cards for real extracts of linked articles only.
- Passage strip stacked big: One large opening extract and a quiet reading list, for real linked extracts only.
- Reader desk accordion ask: questions that open onto their answer, the first one open: many questions, little room.
- Reader desk column case: numbered cases told in labelled columns (what happened, why, the lesson): repairs and lessons learnt.
- Reader desk field notes: short note cards with the place and the years of use: readers telling how they use what they bought.
- Reader desk inbox rows: the reader’s question on one side, the reply signed by a person on the other: an advice column.