Skip to content
VenusUI
Get started

Event Ticket

A ticket with a perforated stub you can drag or click to tear off.

Preview

Installation

npx shadcn@latest add @venusui/event-ticket

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/event-ticket.tsx

Usage

The code behind the preview above.

event-ticket-demo.tsx

"use client"

import * as React from "react"
import { RotateCcw } from "lucide-react"

import { EventTicket } from "@/components/ui/event-ticket"

// Photo: Unsplash (free under the Unsplash License). The event is made up.
export default function EventTicketDemo() {
  const [ticket, setTicket] = React.useState(0)
  const [torn, setTorn] = React.useState(false)

  return (
    <div className="flex w-[min(34rem,calc(100vw-2rem))] flex-col items-center gap-5">
      <EventTicket
        key={ticket}
        onTornChange={setTorn}
        event="Golden Hour Live: Mara Lune"
        date="Sat, 14 Mar 2026"
        time="Doors 19:00"
        venue="The Roundhouse, Hall B"
        seat="Floor · General admission"
        code="GHL-0314-8842"
        image={{
          src: "https://images.unsplash.com/photo-1459749411175-04bf5292ceea?w=900&h=320&fit=crop&auto=format&q=75",
          alt: "A crowd with raised hands under golden stage lights",
        }}
      />
      <p className="flex items-center gap-3 text-sm text-muted-foreground">
        {torn ? "Enjoy the show!" : "Drag the stub to tear it off."}
        {torn ? (
          <button
            type="button"
            onClick={() => {
              setTicket((n) => n + 1)
              setTorn(false)
            }}
            className="inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs hover:text-foreground"
          >
            <RotateCcw aria-hidden="true" className="size-3" /> New ticket
          </button>
        ) : null}
      </p>
    </div>
  )
}

API reference

PropTypeDefaultDescription
event, date, time, venuestring—Printed on the ticket.
seatstring"General admission"Printed on the stub.
image{ src: string; alt: string }—Photo across the top of the ticket.
codestring—Printed under the barcode; the barcode pattern is drawn from it.
torn, defaultTornboolean—Controlled or initial torn state.
onTornChange(torn: boolean) => void—Called when the stub is torn off.

All <div> props.

Requirements

  • React 19 and Tailwind CSS v4.

Customization

  • To show a fresh ticket again, change its key (the demo's “New ticket” button does this).
  • The barcode is decorative. For a scannable code, put a real barcode or QR image in the stub.

Accessibility

  • The stub is a button (“Tear off the stub, Floor · General admission”); a click, tap, Enter or Space tears it, so dragging is optional.
  • Tearing is announced (“Stub torn off.”).
  • With reduced motion the stub disappears without the flying animation.

Troubleshooting

Dragging scrolls the page on a phone.
The stub only captures horizontal drags (touch-pan-y); drag sideways, or tap to tear.
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

A card that tilts in 3D toward the pointer with spring physics.

Loading preview

A flight boarding pass with a perforated stub and code that flips to the fare and baggage details.

Loading preview

Stacked cards with the next ones peeking out; Next sends the top card to the back.