# Studio pass

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

[View Studio pass on CyberSpec](https://www.cyberspec.dev/sink/access-pass)

## 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.

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

## Usage

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

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

## Source

```tsx
"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](https://www.cyberspec.dev/components/sidebar/otp-input.md) — One cut cell per character of a code, with a blinking caret in the active one.
- [Micro-print](https://www.cyberspec.dev/components/sidebar/micro.md) — The printed decoration around frames: micro-print lines, barcodes, rulers, data streams and corner brackets.
- [Badge](https://www.cyberspec.dev/components/sidebar/badge.md) — A small cut label in seven tones, with count and status variants.
- [Button](https://www.cyberspec.dev/components/sidebar/button.md) — 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

- [All kitchen sink recipes](https://www.cyberspec.dev/sink.md)
- [Recipe source on GitHub](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/access-pass.tsx)
- [Recipe layout stylesheet](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/recipe-layout.css)
- [Shadcn registry item](https://www.cyberspec.dev/r/access-pass.json)
