Studio pass

Enter a sample code to issue a barcoded day pass and see how an invalid code is handled.

Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

bunx --bun shadcn@latest add https://www.cyberspec.dev/r/access-pass.json

Usage

import { Cyber } from "@/components/ui/cyber"
import Recipe from "@/components/recipes/access-pass"

export default function App() {
  return (
    <Cyber>
      <Recipe />
    </Cyber>
  )
}

Source

"use client"

import "./recipe-layout.css"
import { useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Barcode } from "@/components/ui/micro"
import { OtpInput } from "@/components/ui/otp-input"

export default function AccessPass() {
  const [code, setCode] = useState("")
  const [issued, setIssued] = useState(false)
  const [error, setError] = useState("")

  return (
    <form className="sink-stack" onSubmit={(event) => {
      event.preventDefault()
      if (issued) {
        setIssued(false)
        setCode("")
      } else if (code === "0427") {
        setIssued(true)
      } else {
        setError("That code did not match. Try 0427.")
      }
    }}>
      <div className="sink-between"><strong>Studio day pass</strong><Badge tone={issued ? "ok" : "mute"} status>{issued ? "Issued" : "Pending"}</Badge></div>
      <div style={{ borderBlock: "1px dashed var(--cy-line-ctl)", paddingBlock: 12 }}>
        <Barcode value={issued ? "STUDIO-0427" : "GUEST"} size={32} unit={2} />
      </div>
      <OtpInput label="Demo pass code" length={4} pattern="digits" value={code} disabled={issued} error={error}
        hint="Use the studio's sample code, 0427." onValueChange={(next) => {
          setCode(next)
          setError("")
        }} />
      <div className="sink-row"><Button type="submit" size="sm" disabled={code.length < 4}>{issued ? "Reset pass" : "Issue pass"}</Button><span role="status" className="sink-note">{issued ? "Ready for check-in." : ""}</span></div>
    </form>
  )
}

Components in this recipe

  • OTP input — One cut cell per character of a code, with a blinking caret in the active one.
  • Micro-print — The printed decoration around frames: micro-print lines, barcodes, rulers, data streams and corner brackets.
  • Badge — A small cut label in seven tones, with count and status variants.
  • Button — A cut-corner button with a raised tab, five tones, and a press flash. Enable the cipher prop to scramble the label and briefly tear the frame on hover.

Resources

View as Markdown