Dev Helpers
← Back

Bookmarkable resource card

Import and render <BookmarkableResourceCard /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/BookmarkableResourceCard.tsx

import { useState } from "react";

export default function BookmarkableResourceCard({
  title = "Field notes",
  body = "A guide to the workshop",
}: { title?: string; body?: string } = {}) {
  const [saved, set] = useState(false);
  return (
    <article>
      <h2>{title}</h2>
      <p>{body}</p>
      <button aria-pressed={saved} onClick={() => set(!saved)}>
        {saved ? "Remove bookmark" : "Bookmark"}
      </button>
    </article>
  );
}