# Do not disturb door hanger toggle

> A sign hanging from the knob of a wooden door flips over and swings from Come in to Do not disturb.

- Category: [Toggles](https://library.aimran.es/components/toggles)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-tg-door-hanger
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

This switch is a wooden door with a raised panel, a brass knob and a card hanging from it, like the signs in hotel rooms. Off, the green side says Come in; on, the card flips over in 3D to the red Do not disturb side and swings on the knob before settling. It fits focus modes, meeting rooms and hotel apps.

The main color is the do not disturb side and the second one the welcome side. The card texts are in the HTML, so you can write Busy and Free or Recording and Open instead, keeping them short.

## Code

### HTML

```html
<label class="uvq03-dhg"><input type="checkbox" role="switch"><span class="dr"><i class="pn"></i><i class="kb"></i><span class="cd" aria-hidden="true"><b class="f a"><span>Come in</span></b><b class="f b"><span>Do Not Disturb</span></b></span></span>Focus mode</label>
```

### CSS

```css
.uvq03-dhg {
  --c1: #d94a4a;
  --c2: #3fa66b;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq03-dhg {
  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: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

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

.uvq03-dhg .dr {
  position: relative;
  display: block;
  flex: none;
  perspective: 14em;
  width: 3.6em;
  height: 4.8em;
  border-radius: .3em .3em 0 0;
  background: repeating-linear-gradient(92deg,rgba(0,0,0,.06) 0 .05em,transparent .05em .35em),linear-gradient(90deg,#9b6a3f,#b8834f 50%,#8f6038);
  box-shadow: inset 0 0 0 .14em rgba(0,0,0,.12),0 .5em 1em -.5em rgba(0,0,0,.5);
}

.uvq03-dhg .pn {
  position: absolute;
  left: .4em;
  right: .4em;
  top: .35em;
  height: 1.2em;
  border-radius: .12em;
  box-shadow: inset .06em .06em .1em rgba(0,0,0,.3),inset -.04em -.04em .06em rgba(255,255,255,.2);
}

.uvq03-dhg .kb {
  position: absolute;
  right: .7em;
  top: 2.05em;
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,#fff3c4,#d9a63c 50%,#7d5412);
  box-shadow: 0 .12em .2em rgba(0,0,0,.45);
}

.uvq03-dhg .cd {
  position: absolute;
  right: .1em;
  top: 1.9em;
  width: 1.8em;
  height: 2.4em;
  transform-origin: 50% .45em;
  transform-style: preserve-3d;
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-dhg .f {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  box-sizing: border-box;
  padding: 0 .1em .42em;
  border-radius: .6em .6em .25em .25em;
  color: #fff;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-mask: radial-gradient(circle at 50% .45em,#0000 .27em,#000 .3em);
  mask: radial-gradient(circle at 50% .45em,#0000 .27em,#000 .3em);
  box-shadow: inset 0 -.2em 0 rgba(0,0,0,.15);
}

.uvq03-dhg .f span {
  font: 800 .3em/1.15 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  letter-spacing: .02em;
  text-align: center;
  text-transform: uppercase;
}

.uvq03-dhg .a {
  background: var(--c2);
}

.uvq03-dhg .b {
  background: var(--c1);
  transform: rotateY(180deg);
}

.uvq03-dhg:hover .cd {
  rotate: 6deg;
}

.uvq03-dhg:active .dr {
  scale: .98;
}

.uvq03-dhg input:checked + .dr .cd {
  transform: rotateY(180deg);
}

.uvq03-dhg.sw .cd {
  animation: uvq03-dhg calc(1.1s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq03-dhg {
  20% {
    rotate: 14deg;
  }
  45% {
    rotate: -9deg;
  }
  70% {
    rotate: 4deg;
  }
  100% {
    rotate: 0deg;
  }
}

.uvq03-dhg input:focus-visible + .dr {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

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

### JavaScript

```js
document.querySelectorAll(".uvq03-dhg").forEach(el => {
  const i=el.querySelector("input"),t=el;const f=()=>{t.classList.remove("sw");void t.offsetWidth;t.classList.add("sw")};i.addEventListener("change",f);return()=>i.removeEventListener("change",f)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq03-dhg {
  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: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

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

.uvq03-dhg .dr {
  position: relative;
  display: block;
  flex: none;
  perspective: 14em;
  width: 3.6em;
  height: 4.8em;
  border-radius: .3em .3em 0 0;
  background: repeating-linear-gradient(92deg,rgba(0,0,0,.06) 0 .05em,transparent .05em .35em),linear-gradient(90deg,#9b6a3f,#b8834f 50%,#8f6038);
  box-shadow: inset 0 0 0 .14em rgba(0,0,0,.12),0 .5em 1em -.5em rgba(0,0,0,.5);
}

.uvq03-dhg .pn {
  position: absolute;
  left: .4em;
  right: .4em;
  top: .35em;
  height: 1.2em;
  border-radius: .12em;
  box-shadow: inset .06em .06em .1em rgba(0,0,0,.3),inset -.04em -.04em .06em rgba(255,255,255,.2);
}

.uvq03-dhg .kb {
  position: absolute;
  right: .7em;
  top: 2.05em;
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,#fff3c4,#d9a63c 50%,#7d5412);
  box-shadow: 0 .12em .2em rgba(0,0,0,.45);
}

.uvq03-dhg .cd {
  position: absolute;
  right: .1em;
  top: 1.9em;
  width: 1.8em;
  height: 2.4em;
  transform-origin: 50% .45em;
  transform-style: preserve-3d;
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-dhg .f {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  box-sizing: border-box;
  padding: 0 .1em .42em;
  border-radius: .6em .6em .25em .25em;
  color: #fff;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-mask: radial-gradient(circle at 50% .45em,#0000 .27em,#000 .3em);
  mask: radial-gradient(circle at 50% .45em,#0000 .27em,#000 .3em);
  box-shadow: inset 0 -.2em 0 rgba(0,0,0,.15);
}

.uvq03-dhg .f span {
  font: 800 .3em/1.15 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  letter-spacing: .02em;
  text-align: center;
  text-transform: uppercase;
}

.uvq03-dhg .a {
  background: var(--c2);
}

.uvq03-dhg .b {
  background: var(--c1);
  transform: rotateY(180deg);
}

.uvq03-dhg:hover .cd {
  rotate: 6deg;
}

.uvq03-dhg:active .dr {
  scale: .98;
}

.uvq03-dhg input:checked + .dr .cd {
  transform: rotateY(180deg);
}

.uvq03-dhg.sw .cd {
  animation: uvq03-dhg calc(1.1s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq03-dhg {
  20% {
    rotate: 14deg;
  }
  45% {
    rotate: -9deg;
  }
  70% {
    rotate: 4deg;
  }
  100% {
    rotate: 0deg;
  }
}

.uvq03-dhg input:focus-visible + .dr {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

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

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const i=el.querySelector("input"),t=el;const f=()=>{t.classList.remove("sw");void t.offsetWidth;t.classList.add("sw")};i.addEventListener("change",f);return()=>i.removeEventListener("change",f)
}

export default function TgDoorHanger() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#d94a4a",
          "--c2": "#3fa66b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-dhg"><input type="checkbox" role="switch" /><span className="dr"><i className="pn"></i><i className="kb"></i><span className="cd" aria-hidden="true"><b className="f a"><span>Come in</span></b><b className="f b"><span>Do Not Disturb</span></b></span></span>Focus mode</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 “Do not disturb door hanger toggle” block (Toggles) from AIMRAN Library to my project.

## What it is
A sign hanging from the knob of a wooden door flips over and swings from Come in to Do not disturb.

## Chosen settings
- Main color: #d94a4a
- Secondary color: #3fa66b
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Focus mode"

## 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
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq03-dhg {
  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: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

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

.uvq03-dhg .dr {
  position: relative;
  display: block;
  flex: none;
  perspective: 14em;
  width: 3.6em;
  height: 4.8em;
  border-radius: .3em .3em 0 0;
  background: repeating-linear-gradient(92deg,rgba(0,0,0,.06) 0 .05em,transparent .05em .35em),linear-gradient(90deg,#9b6a3f,#b8834f 50%,#8f6038);
  box-shadow: inset 0 0 0 .14em rgba(0,0,0,.12),0 .5em 1em -.5em rgba(0,0,0,.5);
}

.uvq03-dhg .pn {
  position: absolute;
  left: .4em;
  right: .4em;
  top: .35em;
  height: 1.2em;
  border-radius: .12em;
  box-shadow: inset .06em .06em .1em rgba(0,0,0,.3),inset -.04em -.04em .06em rgba(255,255,255,.2);
}

.uvq03-dhg .kb {
  position: absolute;
  right: .7em;
  top: 2.05em;
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,#fff3c4,#d9a63c 50%,#7d5412);
  box-shadow: 0 .12em .2em rgba(0,0,0,.45);
}

.uvq03-dhg .cd {
  position: absolute;
  right: .1em;
  top: 1.9em;
  width: 1.8em;
  height: 2.4em;
  transform-origin: 50% .45em;
  transform-style: preserve-3d;
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-dhg .f {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  box-sizing: border-box;
  padding: 0 .1em .42em;
  border-radius: .6em .6em .25em .25em;
  color: #fff;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-mask: radial-gradient(circle at 50% .45em,#0000 .27em,#000 .3em);
  mask: radial-gradient(circle at 50% .45em,#0000 .27em,#000 .3em);
  box-shadow: inset 0 -.2em 0 rgba(0,0,0,.15);
}

.uvq03-dhg .f span {
  font: 800 .3em/1.15 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  letter-spacing: .02em;
  text-align: center;
  text-transform: uppercase;
}

.uvq03-dhg .a {
  background: var(--c2);
}

.uvq03-dhg .b {
  background: var(--c1);
  transform: rotateY(180deg);
}

.uvq03-dhg:hover .cd {
  rotate: 6deg;
}

.uvq03-dhg:active .dr {
  scale: .98;
}

.uvq03-dhg input:checked + .dr .cd {
  transform: rotateY(180deg);
}

.uvq03-dhg.sw .cd {
  animation: uvq03-dhg calc(1.1s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq03-dhg {
  20% {
    rotate: 14deg;
  }
  45% {
    rotate: -9deg;
  }
  70% {
    rotate: 4deg;
  }
  100% {
    rotate: 0deg;
  }
}

.uvq03-dhg input:focus-visible + .dr {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

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

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const i=el.querySelector("input"),t=el;const f=()=>{t.classList.remove("sw");void t.offsetWidth;t.classList.add("sw")};i.addEventListener("change",f);return()=>i.removeEventListener("change",f)
}

export default function TgDoorHanger() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#d94a4a",
          "--c2": "#3fa66b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-dhg"><input type="checkbox" role="switch" /><span className="dr"><i className="pn"></i><i className="kb"></i><span className="cd" aria-hidden="true"><b className="f a"><span>Come in</span></b><b className="f b"><span>Do Not Disturb</span></b></span></span>Focus mode</label>
      </div>
    </>
  );
}
```

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