# Punched ticket checkbox

> A train ticket where checking the stub punches a clean hole and the paper disc falls away.

- Category: [Checkboxes](https://library.aimran.es/components/checkboxes)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-chk-ticket
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

This checkbox is drawn as a paper train ticket with a perforated stub, a route line and a small barcode. Checking it punches a hole through the stub while the cut paper circle tumbles down and fades. It is plain HTML and CSS around a real checkbox, so it suits ticket validation, event check-in, boarding steps and travel apps.

The main color sets the punch guide and the validated label, the secondary color is the paper tone. Change the route text to your own codes, and line several tickets up in a column for multi-leg trips or group bookings.

## Code

### HTML

```html
<label class="uvq02-tkt"><input type="checkbox"><span class="pz" aria-hidden="true"><i class="tg"></i><i class="hl"></i><i class="ch"></i></span><span class="bd"><small aria-hidden="true">MAD → LIS · 08:45</small><b>Validate ticket</b><i class="bc" aria-hidden="true"></i></span></label>
```

### CSS

```css
.uvq02-tkt {
  --c1: #d8452e;
  --c2: #f3ead6;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq02-tkt {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  width: 17em;
  border-radius: .55em;
  background: radial-gradient(120% 90% at 100% 0,rgba(255,255,255,.55),transparent 60%),var(--c2);
  color: #2b2620;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 .1em .15em rgba(0,0,0,.12),0 .9em 1.6em -1em rgba(0,0,0,.55);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq02-tkt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq02-tkt .pz {
  position: relative;
  flex: none;
  width: 4.4em;
  border-right: 2px dashed rgba(43,38,32,.28);
}

.uvq02-tkt .pz::before,.uvq02-tkt .pz::after {
  content: "";
  position: absolute;
  right: -.55em;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: var(--bg);
}

.uvq02-tkt .pz::before {
  top: -.5em;
}

.uvq02-tkt .pz::after {
  bottom: -.5em;
}

.uvq02-tkt .pz i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5em;
  height: 1.5em;
  margin: -.75em;
  border-radius: 50%;
  box-sizing: border-box;
}

.uvq02-tkt .tg {
  border: 2px dashed color-mix(in srgb,var(--c1) 70%,transparent);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-tkt .hl {
  background: var(--bg);
  box-shadow: inset 0 .15em .25em rgba(0,0,0,.4);
  transform: scale(0);
  transition: transform calc(0.16s / var(--k)) cubic-bezier(.5,0,.75,0);
}

.uvq02-tkt .ch {
  background: var(--c2);
  box-shadow: 0 .1em .2em rgba(0,0,0,.25);
  opacity: 0;
}

.uvq02-tkt .bd {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .35em;
  padding: .85em 1em .8em 1.1em;
}

.uvq02-tkt small {
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-size: .66em;
  font-weight: 600;
  letter-spacing: .12em;
  color: rgba(43,38,32,.6);
}

.uvq02-tkt b {
  font-size: 1.05em;
  font-weight: 750;
  letter-spacing: -.01em;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-tkt .bc {
  display: block;
  width: 7em;
  height: .8em;
  opacity: .75;
  background: repeating-linear-gradient(90deg,#2b2620 0 .08em,transparent .08em .16em,#2b2620 .16em .21em,transparent .21em .33em,#2b2620 .33em .45em,transparent .45em .52em);
}

.uvq02-tkt:hover {
  transform: rotate(-1.2deg) translateY(-.1em);
}

.uvq02-tkt:hover .tg {
  transform: scale(1.1);
}

.uvq02-tkt:active .tg {
  transform: scale(.85);
}

.uvq02-tkt input:checked + .pz .tg {
  opacity: 0;
  transform: scale(1.35);
}

.uvq02-tkt input:checked + .pz .hl {
  transform: scale(1);
}

.uvq02-tkt input:checked + .pz .ch {
  animation: uvq02-tkt calc(0.9s / var(--k)) cubic-bezier(.45,0,.8,.6) forwards;
}

.uvq02-tkt input:checked ~ .bd b {
  color: color-mix(in srgb,var(--c1) 85%,#2b2620);
}

@keyframes uvq02-tkt {
  0% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translate(.7em,3.6em) rotate(220deg) scale(.8);
  }
}

.uvq02-tkt:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq02-tkt,.uvq02-tkt *,.uvq02-tkt *::before,.uvq02-tkt *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### React

```tsx
import type { CSSProperties } from "react";

const css = `
.uvq02-tkt {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  width: 17em;
  border-radius: .55em;
  background: radial-gradient(120% 90% at 100% 0,rgba(255,255,255,.55),transparent 60%),var(--c2);
  color: #2b2620;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 .1em .15em rgba(0,0,0,.12),0 .9em 1.6em -1em rgba(0,0,0,.55);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq02-tkt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq02-tkt .pz {
  position: relative;
  flex: none;
  width: 4.4em;
  border-right: 2px dashed rgba(43,38,32,.28);
}

.uvq02-tkt .pz::before,.uvq02-tkt .pz::after {
  content: "";
  position: absolute;
  right: -.55em;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: var(--bg);
}

.uvq02-tkt .pz::before {
  top: -.5em;
}

.uvq02-tkt .pz::after {
  bottom: -.5em;
}

.uvq02-tkt .pz i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5em;
  height: 1.5em;
  margin: -.75em;
  border-radius: 50%;
  box-sizing: border-box;
}

.uvq02-tkt .tg {
  border: 2px dashed color-mix(in srgb,var(--c1) 70%,transparent);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-tkt .hl {
  background: var(--bg);
  box-shadow: inset 0 .15em .25em rgba(0,0,0,.4);
  transform: scale(0);
  transition: transform calc(0.16s / var(--k)) cubic-bezier(.5,0,.75,0);
}

.uvq02-tkt .ch {
  background: var(--c2);
  box-shadow: 0 .1em .2em rgba(0,0,0,.25);
  opacity: 0;
}

.uvq02-tkt .bd {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .35em;
  padding: .85em 1em .8em 1.1em;
}

.uvq02-tkt small {
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-size: .66em;
  font-weight: 600;
  letter-spacing: .12em;
  color: rgba(43,38,32,.6);
}

.uvq02-tkt b {
  font-size: 1.05em;
  font-weight: 750;
  letter-spacing: -.01em;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-tkt .bc {
  display: block;
  width: 7em;
  height: .8em;
  opacity: .75;
  background: repeating-linear-gradient(90deg,#2b2620 0 .08em,transparent .08em .16em,#2b2620 .16em .21em,transparent .21em .33em,#2b2620 .33em .45em,transparent .45em .52em);
}

.uvq02-tkt:hover {
  transform: rotate(-1.2deg) translateY(-.1em);
}

.uvq02-tkt:hover .tg {
  transform: scale(1.1);
}

.uvq02-tkt:active .tg {
  transform: scale(.85);
}

.uvq02-tkt input:checked + .pz .tg {
  opacity: 0;
  transform: scale(1.35);
}

.uvq02-tkt input:checked + .pz .hl {
  transform: scale(1);
}

.uvq02-tkt input:checked + .pz .ch {
  animation: uvq02-tkt calc(0.9s / var(--k)) cubic-bezier(.45,0,.8,.6) forwards;
}

.uvq02-tkt input:checked ~ .bd b {
  color: color-mix(in srgb,var(--c1) 85%,#2b2620);
}

@keyframes uvq02-tkt {
  0% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translate(.7em,3.6em) rotate(220deg) scale(.8);
  }
}

.uvq02-tkt:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq02-tkt,.uvq02-tkt *,.uvq02-tkt *::before,.uvq02-tkt *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

export default function ChkTicket() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#d8452e",
          "--c2": "#f3ead6",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq02-tkt"><input type="checkbox" /><span className="pz" aria-hidden="true"><i className="tg"></i><i className="hl"></i><i className="ch"></i></span><span className="bd"><small aria-hidden="true">MAD → LIS · 08:45</small><b>Validate ticket</b><i className="bc" aria-hidden="true"></i></span></label>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Punched ticket checkbox” block (Checkboxes) from AIMRAN Library to my project.

## What it is
A train ticket where checking the stub punches a clean hole and the paper disc falls away.

## Chosen settings
- Main color: #d8452e
- Secondary color: #f3ead6
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Validar billete"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
import type { CSSProperties } from "react";

const css = `
.uvq02-tkt {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  width: 17em;
  border-radius: .55em;
  background: radial-gradient(120% 90% at 100% 0,rgba(255,255,255,.55),transparent 60%),var(--c2);
  color: #2b2620;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 .1em .15em rgba(0,0,0,.12),0 .9em 1.6em -1em rgba(0,0,0,.55);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq02-tkt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq02-tkt .pz {
  position: relative;
  flex: none;
  width: 4.4em;
  border-right: 2px dashed rgba(43,38,32,.28);
}

.uvq02-tkt .pz::before,.uvq02-tkt .pz::after {
  content: "";
  position: absolute;
  right: -.55em;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: var(--bg);
}

.uvq02-tkt .pz::before {
  top: -.5em;
}

.uvq02-tkt .pz::after {
  bottom: -.5em;
}

.uvq02-tkt .pz i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5em;
  height: 1.5em;
  margin: -.75em;
  border-radius: 50%;
  box-sizing: border-box;
}

.uvq02-tkt .tg {
  border: 2px dashed color-mix(in srgb,var(--c1) 70%,transparent);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-tkt .hl {
  background: var(--bg);
  box-shadow: inset 0 .15em .25em rgba(0,0,0,.4);
  transform: scale(0);
  transition: transform calc(0.16s / var(--k)) cubic-bezier(.5,0,.75,0);
}

.uvq02-tkt .ch {
  background: var(--c2);
  box-shadow: 0 .1em .2em rgba(0,0,0,.25);
  opacity: 0;
}

.uvq02-tkt .bd {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .35em;
  padding: .85em 1em .8em 1.1em;
}

.uvq02-tkt small {
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-size: .66em;
  font-weight: 600;
  letter-spacing: .12em;
  color: rgba(43,38,32,.6);
}

.uvq02-tkt b {
  font-size: 1.05em;
  font-weight: 750;
  letter-spacing: -.01em;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-tkt .bc {
  display: block;
  width: 7em;
  height: .8em;
  opacity: .75;
  background: repeating-linear-gradient(90deg,#2b2620 0 .08em,transparent .08em .16em,#2b2620 .16em .21em,transparent .21em .33em,#2b2620 .33em .45em,transparent .45em .52em);
}

.uvq02-tkt:hover {
  transform: rotate(-1.2deg) translateY(-.1em);
}

.uvq02-tkt:hover .tg {
  transform: scale(1.1);
}

.uvq02-tkt:active .tg {
  transform: scale(.85);
}

.uvq02-tkt input:checked + .pz .tg {
  opacity: 0;
  transform: scale(1.35);
}

.uvq02-tkt input:checked + .pz .hl {
  transform: scale(1);
}

.uvq02-tkt input:checked + .pz .ch {
  animation: uvq02-tkt calc(0.9s / var(--k)) cubic-bezier(.45,0,.8,.6) forwards;
}

.uvq02-tkt input:checked ~ .bd b {
  color: color-mix(in srgb,var(--c1) 85%,#2b2620);
}

@keyframes uvq02-tkt {
  0% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translate(.7em,3.6em) rotate(220deg) scale(.8);
  }
}

.uvq02-tkt:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq02-tkt,.uvq02-tkt *,.uvq02-tkt *::before,.uvq02-tkt *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

export default function ChkTicket() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#d8452e",
          "--c2": "#f3ead6",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq02-tkt"><input type="checkbox" /><span className="pz" aria-hidden="true"><i className="tg"></i><i className="hl"></i><i className="ch"></i></span><span className="bd"><small aria-hidden="true">MAD → LIS · 08:45</small><b>Validate ticket</b><i className="bc" aria-hidden="true"></i></span></label>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
