Open this example in the interactive library
Live preview
Source code
// components/FlippableStudyCard.tsx
import { useState } from "react";
export default function FlippableStudyCard({
title = "Field notes",
body = "A guide to the workshop",
}: { title?: string; body?: string } = {}) {
const [back, set] = useState(false);
return (
<button
onClick={() => set(!back)}
aria-label={back ? "Show question" : "Show answer"}
>
{back ? body : title}
</button>
);
}
