# Mailbox flag checkbox

> A post mailbox whose red flag springs up when checked while a letter peeks out of the door.

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

## Where to use it

Inspired by roadside post mailboxes, this checkbox is a small inline SVG with a rounded box, a wooden post and a red flag on the side. Checking it raises the flag with a springy overshoot and slides a letter halfway out of the door, the old signal that there is mail to collect. Hovering nudges the flag. It fits messaging apps, newsletters, outbox settings and delivery tools.

The main color is the flag and the secondary color the mailbox, so a classic red on steel blue or a brand pairing both work. The label next to it should describe the pending action, such as sending or collecting mail.

## Code

### HTML

```html
<label class="uvq02-mbx"><input type="checkbox"><span class="bx"><svg viewBox="0 0 56 48" aria-hidden="true"><ellipse class="gd" cx="27" cy="46.5" rx="14" ry="1.5"/><rect class="po" x="24" y="29" width="6" height="18" rx="1"/><g class="lt"><rect x="3" y="19.5" width="10" height="7" rx="1"/><path d="M3.5 20l4.5 3.6L12.5 20"/></g><path class="bo" d="M8 30V20a10 10 0 0 1 10-10h20a10 10 0 0 1 10 10v10z"/><path class="dr" d="M14.5 30V20a6.5 6.5 0 0 1 3.5-5.8"/><rect class="sh" x="8" y="28" width="40" height="2"/><g class="fl"><rect class="pl" x="41" y="7" width="2" height="15" rx="1"/><path class="fg" d="M43 7h8.5l-1.6 3 1.6 3H43z"/><circle class="pv" cx="42" cy="22" r="1.7"/></g></svg></span>Letters to send</label>
```

### CSS

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

.uvq02-mbx {
  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;
  align-items: center;
  gap: .75em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  font-weight: 550;
  gap: .9em;
}

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

.uvq02-mbx .bx {
  display: grid;
  place-items: center;
  flex: none;
  width: 4.8em;
  height: 4.3em;
  border-radius: .8em;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-mbx svg {
  width: 4.4em;
  height: 3.8em;
  overflow: visible;
}

.uvq02-mbx svg * {
  transform-box: view-box;
}

.uvq02-mbx .gd {
  fill: color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq02-mbx .po {
  fill: #7a5a40;
}

.uvq02-mbx .bo {
  fill: var(--c2);
}

.uvq02-mbx .dr {
  fill: none;
  stroke: rgba(0,0,0,.28);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.uvq02-mbx .sh {
  fill: rgba(0,0,0,.18);
}

.uvq02-mbx .lt {
  transform: translateX(7px);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq02-mbx .lt rect {
  fill: #fffdf5;
  stroke: rgba(0,0,0,.25);
  stroke-width: .6;
}

.uvq02-mbx .lt path {
  fill: none;
  stroke: rgba(0,0,0,.35);
  stroke-width: .7;
  stroke-linejoin: round;
}

.uvq02-mbx .fl {
  transform-origin: 42px 22px;
  transform: rotate(-90deg);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.3,1.7,.55,1);
}

.uvq02-mbx .pl {
  fill: #3b3f45;
}

.uvq02-mbx .fg {
  fill: var(--c1);
}

.uvq02-mbx .pv {
  fill: #2a2d31;
}

.uvq02-mbx:hover .bx {
  background: color-mix(in srgb,var(--c2) 10%,transparent);
}

.uvq02-mbx:hover input:not(:checked) + .bx .fl {
  transform: rotate(-76deg);
}

.uvq02-mbx:active .fl {
  scale: .94;
}

.uvq02-mbx input:checked + .bx .fl {
  transform: none;
}

.uvq02-mbx input:checked + .bx .lt {
  transform: none;
  transition-delay: calc(0.2s / var(--k));
}

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

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

### React

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

const css = `
.uvq02-mbx {
  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;
  align-items: center;
  gap: .75em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  font-weight: 550;
  gap: .9em;
}

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

.uvq02-mbx .bx {
  display: grid;
  place-items: center;
  flex: none;
  width: 4.8em;
  height: 4.3em;
  border-radius: .8em;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-mbx svg {
  width: 4.4em;
  height: 3.8em;
  overflow: visible;
}

.uvq02-mbx svg * {
  transform-box: view-box;
}

.uvq02-mbx .gd {
  fill: color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq02-mbx .po {
  fill: #7a5a40;
}

.uvq02-mbx .bo {
  fill: var(--c2);
}

.uvq02-mbx .dr {
  fill: none;
  stroke: rgba(0,0,0,.28);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.uvq02-mbx .sh {
  fill: rgba(0,0,0,.18);
}

.uvq02-mbx .lt {
  transform: translateX(7px);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq02-mbx .lt rect {
  fill: #fffdf5;
  stroke: rgba(0,0,0,.25);
  stroke-width: .6;
}

.uvq02-mbx .lt path {
  fill: none;
  stroke: rgba(0,0,0,.35);
  stroke-width: .7;
  stroke-linejoin: round;
}

.uvq02-mbx .fl {
  transform-origin: 42px 22px;
  transform: rotate(-90deg);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.3,1.7,.55,1);
}

.uvq02-mbx .pl {
  fill: #3b3f45;
}

.uvq02-mbx .fg {
  fill: var(--c1);
}

.uvq02-mbx .pv {
  fill: #2a2d31;
}

.uvq02-mbx:hover .bx {
  background: color-mix(in srgb,var(--c2) 10%,transparent);
}

.uvq02-mbx:hover input:not(:checked) + .bx .fl {
  transform: rotate(-76deg);
}

.uvq02-mbx:active .fl {
  scale: .94;
}

.uvq02-mbx input:checked + .bx .fl {
  transform: none;
}

.uvq02-mbx input:checked + .bx .lt {
  transform: none;
  transition-delay: calc(0.2s / var(--k));
}

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

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

export default function ChkMailbox() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e2412f",
          "--c2": "#5d7f9c",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq02-mbx"><input type="checkbox" /><span className="bx"><svg viewBox="0 0 56 48" aria-hidden="true"><ellipse className="gd" cx="27" cy="46.5" rx="14" ry="1.5" /><rect className="po" x="24" y="29" width="6" height="18" rx="1" /><g className="lt"><rect x="3" y="19.5" width="10" height="7" rx="1" /><path d="M3.5 20l4.5 3.6L12.5 20" /></g><path className="bo" d="M8 30V20a10 10 0 0 1 10-10h20a10 10 0 0 1 10 10v10z" /><path className="dr" d="M14.5 30V20a6.5 6.5 0 0 1 3.5-5.8" /><rect className="sh" x="8" y="28" width="40" height="2" /><g className="fl"><rect className="pl" x="41" y="7" width="2" height="15" rx="1" /><path className="fg" d="M43 7h8.5l-1.6 3 1.6 3H43z" /><circle className="pv" cx="42" cy="22" r="1.7" /></g></svg></span>Letters to send</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 “Mailbox flag checkbox” block (Checkboxes) from AIMRAN Library to my project.

## What it is
A post mailbox whose red flag springs up when checked while a letter peeks out of the door.

## Chosen settings
- Main color: #e2412f
- Secondary color: #5d7f9c
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Hay cartas para enviar"

## 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-mbx {
  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;
  align-items: center;
  gap: .75em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  font-weight: 550;
  gap: .9em;
}

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

.uvq02-mbx .bx {
  display: grid;
  place-items: center;
  flex: none;
  width: 4.8em;
  height: 4.3em;
  border-radius: .8em;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq02-mbx svg {
  width: 4.4em;
  height: 3.8em;
  overflow: visible;
}

.uvq02-mbx svg * {
  transform-box: view-box;
}

.uvq02-mbx .gd {
  fill: color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq02-mbx .po {
  fill: #7a5a40;
}

.uvq02-mbx .bo {
  fill: var(--c2);
}

.uvq02-mbx .dr {
  fill: none;
  stroke: rgba(0,0,0,.28);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.uvq02-mbx .sh {
  fill: rgba(0,0,0,.18);
}

.uvq02-mbx .lt {
  transform: translateX(7px);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq02-mbx .lt rect {
  fill: #fffdf5;
  stroke: rgba(0,0,0,.25);
  stroke-width: .6;
}

.uvq02-mbx .lt path {
  fill: none;
  stroke: rgba(0,0,0,.35);
  stroke-width: .7;
  stroke-linejoin: round;
}

.uvq02-mbx .fl {
  transform-origin: 42px 22px;
  transform: rotate(-90deg);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.3,1.7,.55,1);
}

.uvq02-mbx .pl {
  fill: #3b3f45;
}

.uvq02-mbx .fg {
  fill: var(--c1);
}

.uvq02-mbx .pv {
  fill: #2a2d31;
}

.uvq02-mbx:hover .bx {
  background: color-mix(in srgb,var(--c2) 10%,transparent);
}

.uvq02-mbx:hover input:not(:checked) + .bx .fl {
  transform: rotate(-76deg);
}

.uvq02-mbx:active .fl {
  scale: .94;
}

.uvq02-mbx input:checked + .bx .fl {
  transform: none;
}

.uvq02-mbx input:checked + .bx .lt {
  transform: none;
  transition-delay: calc(0.2s / var(--k));
}

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

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

export default function ChkMailbox() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e2412f",
          "--c2": "#5d7f9c",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq02-mbx"><input type="checkbox" /><span className="bx"><svg viewBox="0 0 56 48" aria-hidden="true"><ellipse className="gd" cx="27" cy="46.5" rx="14" ry="1.5" /><rect className="po" x="24" y="29" width="6" height="18" rx="1" /><g className="lt"><rect x="3" y="19.5" width="10" height="7" rx="1" /><path d="M3.5 20l4.5 3.6L12.5 20" /></g><path className="bo" d="M8 30V20a10 10 0 0 1 10-10h20a10 10 0 0 1 10 10v10z" /><path className="dr" d="M14.5 30V20a6.5 6.5 0 0 1 3.5-5.8" /><rect className="sh" x="8" y="28" width="40" height="2" /><g className="fl"><rect className="pl" x="41" y="7" width="2" height="15" rx="1" /><path className="fg" d="M43 7h8.5l-1.6 3 1.6 3H43z" /><circle className="pv" cx="42" cy="22" r="1.7" /></g></svg></span>Letters to send</label>
      </div>
    </>
  );
}
```

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