Postcard

An interactive postcard component with flip animation, front/back faces, vintage image effects, and a realistic postage stamp.

Installation

npx shadcn@latest add https://ui.collectivecreation.company/postcard.json

Preview

Scenic mountain landscape

ARE YOU LIVING YOUR DREAMS?

Somewhere beautiful. 2024

Hello from the mountains.

The air is thin, but the view is worth it.

Alex

From:
Patagonia, Argentina
15 Jan 2024, 02:30 PM
To:
Somewhere, Earth
Postage stamp

Usage

example.tsx
import { Postcard } from '@/components/ui/postcard'

export function MyPage() {
  return (
    <Postcard
      front={{
        imageSrc: '/my-photo.webp',
        imageAlt: 'A beautiful landscape',
        imageEffect: 'vintage',
        quote: 'EXPLORE THE WORLD',
        caption: 'Patagonia, 2024',
        captionHref: 'https://maps.google.com',
      }}
      back={{
        message: [
          'Hi there,',
          'Greetings from the edge of the world.',
        ],
        signature: 'Alex',
        senderLocation: 'Buenos Aires, Argentina',
        senderDate: '15 Jan 2024',
        senderTime: '02:30 PM',
        receiverLocation: 'Your City',
        stampSrc: '/stamp.webp',
        stampAlt: 'Postage stamp',
      }}
    />
  )
}

Composition

The postcard is composable. You can use the full Postcard wrapper or build your own layout with the sub-components.

composition.tsx
import {
  Postcard,
  PostcardFront,
  PostcardBack,
  PostcardStamp,
} from '@/components/ui/postcard'

// Using the full wrapper
<Postcard front={{...}} back={{...}} />

// Or compose manually
<div className="grid grid-cols-2 gap-4">
  <PostcardFront
    front={{
      imageSrc: '/photo.webp',
      quote: 'HELLO WORLD',
    }}
  />
  <PostcardBack
    back={{
      message: ['Hi!'],
      stampSrc: '/stamp.webp',
    }}
  />
</div>

// Standalone stamp
<PostcardStamp
  src="/stamp.webp"
  alt="Commemorative stamp"
  className="w-16"
/>

API Reference

Postcard

PropTypeDescription
frontPostcardFrontDataConfiguration for the front face
backPostcardBackDataConfiguration for the back face
classNamestringAdditional CSS classes
interactivebooleanEnable click-to-flip (default: true)
activeFacefront or backControlled active face
onFaceChangefunctionCallback when face changes

PostcardFrontData

PropTypeDescription
imageSrcstringFront image URL (required)
imageAltstringImage alt text
imageEffectnone, misty, or vintageImage filter preset
quotestringOverlay text on front
captionstringBottom caption text
captionHrefstringCaption link URL

PostcardBackData

PropTypeDescription
messagestring arrayParagraphs of the message
signaturestringSignature text
senderLocationstringSender location
senderDatestringSender date
senderTimestringSender time
receiverLocationstringReceiver location
stampSrcstringStamp image URL
stampAltstringStamp alt text

Customization

The postcard uses Tailwind CSS for styling. You can customize the appearance by passing a className to override wrapper styles, using the exported sub-components (PostcardFront, PostcardBack, PostcardStamp) for full control, or overriding CSS variables in your Tailwind config.

Accessibility

  • Clickable areas have role=button and keyboard support
  • Images include alt text support
  • Motion respects user preferences via prefers-reduced-motion (inherited from motion/react)