# Hanging size tags

> Kraft paper tags hanging from a string: the chosen size turns red and swings for a moment.

- Category: [Radio buttons](https://library.aimran.es/components/radios)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-rd-hang-tags
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Clothing sizes become kraft paper tags threaded on a sagging twine, each with a punched eyelet and a bold letter. Hovering tilts a tag, and choosing one turns it red and sets it swinging with a damped pendulum keyframe, while sold out sizes fade and get crossed out. It brings a handmade shop feel to fashion stores, merch pages and product configurators.

The main color is the chosen tag and the secondary color is the twine. Disabled inputs handle stock: add or remove the disabled attribute per size, and keep the note below in sync so shoppers know why a tag is greyed out.

## Code

### HTML

```html
<fieldset class="uvq04-tag"><legend>Size</legend><div class="rp"><i class="cd" aria-hidden="true"></i><label><input type="radio" name="uvq04-tag" disabled><span class="tg"><b>XS</b></span></label><label><input type="radio" name="uvq04-tag"><span class="tg"><b>S</b></span></label><label><input type="radio" name="uvq04-tag" checked><span class="tg"><b>M</b></span></label><label><input type="radio" name="uvq04-tag"><span class="tg"><b>L</b></span></label><label><input type="radio" name="uvq04-tag"><span class="tg"><b>XL</b></span></label></div><p class="nt">XS is sold out</p></fieldset>
```

### CSS

```css
.uvq04-tag {
  --c1: #c8372d;
  --c2: #8a6a45;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq04-tag {
  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;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  text-align: center;
}

.uvq04-tag legend {
  padding: 0;
  margin: 0 0 .8em;
  font-weight: 700;
  width: 100%;
}

.uvq04-tag .rp {
  position: relative;
  display: flex;
  justify-content: center;
  gap: .6em;
  padding: 0 .8em;
}

.uvq04-tag .cd {
  position: absolute;
  left: 0;
  right: 0;
  top: -.6em;
  height: 1.4em;
  border-bottom: 2px solid var(--c2);
  border-radius: 0 0 50% 50%/0 0 100% 100%;
}

.uvq04-tag label {
  position: relative;
  padding-top: 1.2em;
  transform-origin: 50% 0;
  cursor: pointer;
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq04-tag label::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 1.75em;
  margin-left: -1px;
  background: var(--c2);
}

.uvq04-tag label:nth-of-type(1)::before,.uvq04-tag label:nth-of-type(5)::before {
  top: -.25em;
  height: 2em;
}

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

.uvq04-tag .tg {
  position: relative;
  display: grid;
  place-items: end center;
  width: 2.7em;
  height: 3.9em;
  padding-bottom: .7em;
  box-sizing: border-box;
}

.uvq04-tag .tg::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(26% 0,74% 0,100% 20%,100% 100%,0 100%,0 20%);
  background: radial-gradient(circle at 50% .75em,transparent .2em,#a7804e .21em .3em,transparent .31em),repeating-linear-gradient(100deg,rgba(0,0,0,.035) 0 2px,transparent 2px 5px),#d6b588;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag .tg b {
  position: relative;
  font-size: 1.05em;
  font-weight: 800;
  color: #5a3d1c;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag label:hover {
  transform: rotate(5deg);
}

.uvq04-tag label:active {
  transform: rotate(-4deg);
}

.uvq04-tag label:has(input:checked) {
  animation: uvq04-tag calc(1.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag input:checked + .tg::before {
  background: radial-gradient(circle at 50% .75em,transparent .2em,color-mix(in srgb,var(--c1),#fff 40%) .21em .3em,transparent .31em),repeating-linear-gradient(100deg,rgba(0,0,0,.05) 0 2px,transparent 2px 5px),var(--c1);
}

.uvq04-tag input:checked + .tg b {
  color: #fff;
}

.uvq04-tag label:has(input:disabled) {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
}

.uvq04-tag input:disabled + .tg b {
  text-decoration: line-through;
}

.uvq04-tag input:focus-visible + .tg {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
  border-radius: .3em;
}

.uvq04-tag .nt {
  margin: .9em 0 0;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

@keyframes uvq04-tag {
  0% {
    transform: rotate(0);
  }
  18% {
    transform: rotate(12deg);
  }
  38% {
    transform: rotate(-8deg);
  }
  58% {
    transform: rotate(4.5deg);
  }
  78% {
    transform: rotate(-2deg);
  }
  100% {
    transform: rotate(0);
  }
}

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

### React

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

const css = `
.uvq04-tag {
  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;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  text-align: center;
}

.uvq04-tag legend {
  padding: 0;
  margin: 0 0 .8em;
  font-weight: 700;
  width: 100%;
}

.uvq04-tag .rp {
  position: relative;
  display: flex;
  justify-content: center;
  gap: .6em;
  padding: 0 .8em;
}

.uvq04-tag .cd {
  position: absolute;
  left: 0;
  right: 0;
  top: -.6em;
  height: 1.4em;
  border-bottom: 2px solid var(--c2);
  border-radius: 0 0 50% 50%/0 0 100% 100%;
}

.uvq04-tag label {
  position: relative;
  padding-top: 1.2em;
  transform-origin: 50% 0;
  cursor: pointer;
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq04-tag label::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 1.75em;
  margin-left: -1px;
  background: var(--c2);
}

.uvq04-tag label:nth-of-type(1)::before,.uvq04-tag label:nth-of-type(5)::before {
  top: -.25em;
  height: 2em;
}

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

.uvq04-tag .tg {
  position: relative;
  display: grid;
  place-items: end center;
  width: 2.7em;
  height: 3.9em;
  padding-bottom: .7em;
  box-sizing: border-box;
}

.uvq04-tag .tg::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(26% 0,74% 0,100% 20%,100% 100%,0 100%,0 20%);
  background: radial-gradient(circle at 50% .75em,transparent .2em,#a7804e .21em .3em,transparent .31em),repeating-linear-gradient(100deg,rgba(0,0,0,.035) 0 2px,transparent 2px 5px),#d6b588;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag .tg b {
  position: relative;
  font-size: 1.05em;
  font-weight: 800;
  color: #5a3d1c;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag label:hover {
  transform: rotate(5deg);
}

.uvq04-tag label:active {
  transform: rotate(-4deg);
}

.uvq04-tag label:has(input:checked) {
  animation: uvq04-tag calc(1.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag input:checked + .tg::before {
  background: radial-gradient(circle at 50% .75em,transparent .2em,color-mix(in srgb,var(--c1),#fff 40%) .21em .3em,transparent .31em),repeating-linear-gradient(100deg,rgba(0,0,0,.05) 0 2px,transparent 2px 5px),var(--c1);
}

.uvq04-tag input:checked + .tg b {
  color: #fff;
}

.uvq04-tag label:has(input:disabled) {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
}

.uvq04-tag input:disabled + .tg b {
  text-decoration: line-through;
}

.uvq04-tag input:focus-visible + .tg {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
  border-radius: .3em;
}

.uvq04-tag .nt {
  margin: .9em 0 0;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

@keyframes uvq04-tag {
  0% {
    transform: rotate(0);
  }
  18% {
    transform: rotate(12deg);
  }
  38% {
    transform: rotate(-8deg);
  }
  58% {
    transform: rotate(4.5deg);
  }
  78% {
    transform: rotate(-2deg);
  }
  100% {
    transform: rotate(0);
  }
}

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

export default function RdHangTags() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#c8372d",
          "--c2": "#8a6a45",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <fieldset className="uvq04-tag"><legend>Size</legend><div className="rp"><i className="cd" aria-hidden="true"></i><label><input type="radio" name="uvq04-tag" disabled={true} /><span className="tg"><b>XS</b></span></label><label><input type="radio" name="uvq04-tag" /><span className="tg"><b>S</b></span></label><label><input type="radio" name="uvq04-tag" checked={true} /><span className="tg"><b>M</b></span></label><label><input type="radio" name="uvq04-tag" /><span className="tg"><b>L</b></span></label><label><input type="radio" name="uvq04-tag" /><span className="tg"><b>XL</b></span></label></div><p className="nt">XS is sold out</p></fieldset>
      </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 “Hanging size tags” block (Radio buttons) from AIMRAN Library to my project.

## What it is
Kraft paper tags hanging from a string: the chosen size turns red and swings for a moment.

## Chosen settings
- Main color: #c8372d
- Secondary color: #8a6a45
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Talla"

## 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 = `
.uvq04-tag {
  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;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  text-align: center;
}

.uvq04-tag legend {
  padding: 0;
  margin: 0 0 .8em;
  font-weight: 700;
  width: 100%;
}

.uvq04-tag .rp {
  position: relative;
  display: flex;
  justify-content: center;
  gap: .6em;
  padding: 0 .8em;
}

.uvq04-tag .cd {
  position: absolute;
  left: 0;
  right: 0;
  top: -.6em;
  height: 1.4em;
  border-bottom: 2px solid var(--c2);
  border-radius: 0 0 50% 50%/0 0 100% 100%;
}

.uvq04-tag label {
  position: relative;
  padding-top: 1.2em;
  transform-origin: 50% 0;
  cursor: pointer;
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq04-tag label::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 1.75em;
  margin-left: -1px;
  background: var(--c2);
}

.uvq04-tag label:nth-of-type(1)::before,.uvq04-tag label:nth-of-type(5)::before {
  top: -.25em;
  height: 2em;
}

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

.uvq04-tag .tg {
  position: relative;
  display: grid;
  place-items: end center;
  width: 2.7em;
  height: 3.9em;
  padding-bottom: .7em;
  box-sizing: border-box;
}

.uvq04-tag .tg::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(26% 0,74% 0,100% 20%,100% 100%,0 100%,0 20%);
  background: radial-gradient(circle at 50% .75em,transparent .2em,#a7804e .21em .3em,transparent .31em),repeating-linear-gradient(100deg,rgba(0,0,0,.035) 0 2px,transparent 2px 5px),#d6b588;
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag .tg b {
  position: relative;
  font-size: 1.05em;
  font-weight: 800;
  color: #5a3d1c;
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag label:hover {
  transform: rotate(5deg);
}

.uvq04-tag label:active {
  transform: rotate(-4deg);
}

.uvq04-tag label:has(input:checked) {
  animation: uvq04-tag calc(1.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq04-tag input:checked + .tg::before {
  background: radial-gradient(circle at 50% .75em,transparent .2em,color-mix(in srgb,var(--c1),#fff 40%) .21em .3em,transparent .31em),repeating-linear-gradient(100deg,rgba(0,0,0,.05) 0 2px,transparent 2px 5px),var(--c1);
}

.uvq04-tag input:checked + .tg b {
  color: #fff;
}

.uvq04-tag label:has(input:disabled) {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
}

.uvq04-tag input:disabled + .tg b {
  text-decoration: line-through;
}

.uvq04-tag input:focus-visible + .tg {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
  border-radius: .3em;
}

.uvq04-tag .nt {
  margin: .9em 0 0;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

@keyframes uvq04-tag {
  0% {
    transform: rotate(0);
  }
  18% {
    transform: rotate(12deg);
  }
  38% {
    transform: rotate(-8deg);
  }
  58% {
    transform: rotate(4.5deg);
  }
  78% {
    transform: rotate(-2deg);
  }
  100% {
    transform: rotate(0);
  }
}

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

export default function RdHangTags() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#c8372d",
          "--c2": "#8a6a45",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <fieldset className="uvq04-tag"><legend>Size</legend><div className="rp"><i className="cd" aria-hidden="true"></i><label><input type="radio" name="uvq04-tag" disabled={true} /><span className="tg"><b>XS</b></span></label><label><input type="radio" name="uvq04-tag" /><span className="tg"><b>S</b></span></label><label><input type="radio" name="uvq04-tag" checked={true} /><span className="tg"><b>M</b></span></label><label><input type="radio" name="uvq04-tag" /><span className="tg"><b>L</b></span></label><label><input type="radio" name="uvq04-tag" /><span className="tg"><b>XL</b></span></label></div><p className="nt">XS is sold out</p></fieldset>
      </div>
    </>
  );
}
```

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