# Birdhouse toggle

> A wooden birdhouse on a post: switch it on and a bird peeks out of the hole, tilts its head and sings.

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

## Where to use it

This switch is a small wooden birdhouse with a red roof, a round entrance, a perch and a post. Off, the hole stays dark; on, a little bird pops up into the opening with a springy bounce, tilts its head now and then, and music notes float up from the roof. Hovering lets the bird peek a little. It suits wake-up alarms, garden apps and nature sites.

The main color is the roof and the second one is the bird and its notes. A green roof with a yellow bird feels like spring, and a dark roof suits evening themes. Keep the label about sound or mornings.

## Code

### HTML

```html
<label class="uvq03-brd"><input type="checkbox" role="switch"><span class="bh"><span class="nt" aria-hidden="true"><i>♪</i><i>♫</i></span><i class="rf"></i><span class="bx"><span class="hl"><span class="bd"><i class="ey"></i><i class="bk"></i></span></span><i class="pc"></i></span><i class="po"></i></span>Wake up to birdsong</label>
```

### CSS

```css
.uvq03-brd {
  --c1: #d8553b;
  --c2: #4aa3df;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq03-brd {
  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-brd input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-brd .bh {
  position: relative;
  display: block;
  flex: none;
  width: 3.6em;
  height: 4.8em;
  border-radius: .5em;
}

.uvq03-brd .bh > i {
  position: absolute;
  display: block;
}

.uvq03-brd .rf {
  left: .3em;
  top: .55em;
  width: 3em;
  height: 1.25em;
  clip-path: polygon(50% 0,100% 100%,0 100%);
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 70%,#fff),var(--c1) 50%,color-mix(in srgb,var(--c1) 75%,#000));
}

.uvq03-brd .bx {
  position: absolute;
  left: .65em;
  top: 1.7em;
  width: 2.3em;
  height: 2em;
  border-radius: 0 0 .15em .15em;
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.07) 0 .04em,transparent .04em .38em),linear-gradient(180deg,#e3b77e,#c48f52);
  box-shadow: inset 0 .15em .15em -.05em rgba(0,0,0,.25),0 .4em .8em -.4em rgba(0,0,0,.5);
}

.uvq03-brd .hl {
  position: absolute;
  left: 50%;
  top: .35em;
  width: .9em;
  height: .9em;
  margin-left: -.45em;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%,#2a1c12,#120b06);
  box-shadow: inset 0 .1em .15em #000;
}

.uvq03-brd .bd {
  position: absolute;
  left: .08em;
  top: .12em;
  width: .74em;
  height: .74em;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%,color-mix(in srgb,var(--c2) 55%,#fff),var(--c2) 60%,color-mix(in srgb,var(--c2) 75%,#000));
  transform: translateY(110%);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq03-brd .ey {
  position: absolute;
  left: .22em;
  top: .22em;
  width: .13em;
  height: .13em;
  border-radius: 50%;
  background: #111;
  box-shadow: inset .03em .03em 0 #fff;
}

.uvq03-brd .bk {
  position: absolute;
  left: -.06em;
  top: .32em;
  width: .22em;
  height: .16em;
  clip-path: polygon(0 50%,100% 0,100% 100%);
  background: #f2a31b;
}

.uvq03-brd .pc {
  position: absolute;
  left: 50%;
  top: 1.35em;
  width: .6em;
  height: .12em;
  margin-left: -.3em;
  border-radius: 1em;
  background: #7a5230;
}

.uvq03-brd .po {
  left: calc(50% - .14em);
  top: 3.7em;
  width: .28em;
  height: 1.1em;
  background: linear-gradient(90deg,#6b4a2c,#9b7149 50%,#6b4a2c);
}

.uvq03-brd .nt {
  position: absolute;
  left: 2.6em;
  top: .2em;
  width: 1em;
  height: 1.4em;
  pointer-events: none;
}

.uvq03-brd .nt i {
  position: absolute;
  bottom: 0;
  font-style: normal;
  font-size: .7em;
  line-height: 1;
  color: var(--c2);
  opacity: 0;
}

.uvq03-brd .nt i + i {
  left: .6em;
}

.uvq03-brd:hover input:not(:checked) + .bh .bd {
  transform: translateY(80%);
}

.uvq03-brd:active .bh {
  scale: .97;
}

.uvq03-brd input:checked + .bh .bd {
  transform: none;
  animation: uvq03-brd calc(1.4s / var(--k)) ease-in-out calc(0.5s / var(--k)) infinite;
}

.uvq03-brd input:checked + .bh .nt i {
  animation: uvq03-brd-n calc(1.6s / var(--k)) ease-out calc(0.6s / var(--k)) infinite;
}

.uvq03-brd input:checked + .bh .nt i + i {
  animation-delay: calc(1.3s / var(--k));
}

@keyframes uvq03-brd {
  0%,60%,100% {
    rotate: 0deg;
  }
  70% {
    rotate: -14deg;
  }
  85% {
    rotate: 8deg;
  }
}

@keyframes uvq03-brd-n {
  0% {
    opacity: 0;
    transform: translate(0,0);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(.5em,-1.2em) rotate(15deg);
  }
}

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

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

### React

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

const css = `
.uvq03-brd {
  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-brd input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-brd .bh {
  position: relative;
  display: block;
  flex: none;
  width: 3.6em;
  height: 4.8em;
  border-radius: .5em;
}

.uvq03-brd .bh > i {
  position: absolute;
  display: block;
}

.uvq03-brd .rf {
  left: .3em;
  top: .55em;
  width: 3em;
  height: 1.25em;
  clip-path: polygon(50% 0,100% 100%,0 100%);
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 70%,#fff),var(--c1) 50%,color-mix(in srgb,var(--c1) 75%,#000));
}

.uvq03-brd .bx {
  position: absolute;
  left: .65em;
  top: 1.7em;
  width: 2.3em;
  height: 2em;
  border-radius: 0 0 .15em .15em;
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.07) 0 .04em,transparent .04em .38em),linear-gradient(180deg,#e3b77e,#c48f52);
  box-shadow: inset 0 .15em .15em -.05em rgba(0,0,0,.25),0 .4em .8em -.4em rgba(0,0,0,.5);
}

.uvq03-brd .hl {
  position: absolute;
  left: 50%;
  top: .35em;
  width: .9em;
  height: .9em;
  margin-left: -.45em;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%,#2a1c12,#120b06);
  box-shadow: inset 0 .1em .15em #000;
}

.uvq03-brd .bd {
  position: absolute;
  left: .08em;
  top: .12em;
  width: .74em;
  height: .74em;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%,color-mix(in srgb,var(--c2) 55%,#fff),var(--c2) 60%,color-mix(in srgb,var(--c2) 75%,#000));
  transform: translateY(110%);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq03-brd .ey {
  position: absolute;
  left: .22em;
  top: .22em;
  width: .13em;
  height: .13em;
  border-radius: 50%;
  background: #111;
  box-shadow: inset .03em .03em 0 #fff;
}

.uvq03-brd .bk {
  position: absolute;
  left: -.06em;
  top: .32em;
  width: .22em;
  height: .16em;
  clip-path: polygon(0 50%,100% 0,100% 100%);
  background: #f2a31b;
}

.uvq03-brd .pc {
  position: absolute;
  left: 50%;
  top: 1.35em;
  width: .6em;
  height: .12em;
  margin-left: -.3em;
  border-radius: 1em;
  background: #7a5230;
}

.uvq03-brd .po {
  left: calc(50% - .14em);
  top: 3.7em;
  width: .28em;
  height: 1.1em;
  background: linear-gradient(90deg,#6b4a2c,#9b7149 50%,#6b4a2c);
}

.uvq03-brd .nt {
  position: absolute;
  left: 2.6em;
  top: .2em;
  width: 1em;
  height: 1.4em;
  pointer-events: none;
}

.uvq03-brd .nt i {
  position: absolute;
  bottom: 0;
  font-style: normal;
  font-size: .7em;
  line-height: 1;
  color: var(--c2);
  opacity: 0;
}

.uvq03-brd .nt i + i {
  left: .6em;
}

.uvq03-brd:hover input:not(:checked) + .bh .bd {
  transform: translateY(80%);
}

.uvq03-brd:active .bh {
  scale: .97;
}

.uvq03-brd input:checked + .bh .bd {
  transform: none;
  animation: uvq03-brd calc(1.4s / var(--k)) ease-in-out calc(0.5s / var(--k)) infinite;
}

.uvq03-brd input:checked + .bh .nt i {
  animation: uvq03-brd-n calc(1.6s / var(--k)) ease-out calc(0.6s / var(--k)) infinite;
}

.uvq03-brd input:checked + .bh .nt i + i {
  animation-delay: calc(1.3s / var(--k));
}

@keyframes uvq03-brd {
  0%,60%,100% {
    rotate: 0deg;
  }
  70% {
    rotate: -14deg;
  }
  85% {
    rotate: 8deg;
  }
}

@keyframes uvq03-brd-n {
  0% {
    opacity: 0;
    transform: translate(0,0);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(.5em,-1.2em) rotate(15deg);
  }
}

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

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

export default function TgBirdhouse() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#d8553b",
          "--c2": "#4aa3df",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-brd"><input type="checkbox" role="switch" /><span className="bh"><span className="nt" aria-hidden="true"><i>♪</i><i>♫</i></span><i className="rf"></i><span className="bx"><span className="hl"><span className="bd"><i className="ey"></i><i className="bk"></i></span></span><i className="pc"></i></span><i className="po"></i></span>Wake up to birdsong</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 “Birdhouse toggle” block (Toggles) from AIMRAN Library to my project.

## What it is
A wooden birdhouse on a post: switch it on and a bird peeks out of the hole, tilts its head and sings.

## Chosen settings
- Main color: #d8553b
- Secondary color: #4aa3df
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Despertar con pájaros"

## 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 = `
.uvq03-brd {
  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-brd input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-brd .bh {
  position: relative;
  display: block;
  flex: none;
  width: 3.6em;
  height: 4.8em;
  border-radius: .5em;
}

.uvq03-brd .bh > i {
  position: absolute;
  display: block;
}

.uvq03-brd .rf {
  left: .3em;
  top: .55em;
  width: 3em;
  height: 1.25em;
  clip-path: polygon(50% 0,100% 100%,0 100%);
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 70%,#fff),var(--c1) 50%,color-mix(in srgb,var(--c1) 75%,#000));
}

.uvq03-brd .bx {
  position: absolute;
  left: .65em;
  top: 1.7em;
  width: 2.3em;
  height: 2em;
  border-radius: 0 0 .15em .15em;
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.07) 0 .04em,transparent .04em .38em),linear-gradient(180deg,#e3b77e,#c48f52);
  box-shadow: inset 0 .15em .15em -.05em rgba(0,0,0,.25),0 .4em .8em -.4em rgba(0,0,0,.5);
}

.uvq03-brd .hl {
  position: absolute;
  left: 50%;
  top: .35em;
  width: .9em;
  height: .9em;
  margin-left: -.45em;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%,#2a1c12,#120b06);
  box-shadow: inset 0 .1em .15em #000;
}

.uvq03-brd .bd {
  position: absolute;
  left: .08em;
  top: .12em;
  width: .74em;
  height: .74em;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%,color-mix(in srgb,var(--c2) 55%,#fff),var(--c2) 60%,color-mix(in srgb,var(--c2) 75%,#000));
  transform: translateY(110%);
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq03-brd .ey {
  position: absolute;
  left: .22em;
  top: .22em;
  width: .13em;
  height: .13em;
  border-radius: 50%;
  background: #111;
  box-shadow: inset .03em .03em 0 #fff;
}

.uvq03-brd .bk {
  position: absolute;
  left: -.06em;
  top: .32em;
  width: .22em;
  height: .16em;
  clip-path: polygon(0 50%,100% 0,100% 100%);
  background: #f2a31b;
}

.uvq03-brd .pc {
  position: absolute;
  left: 50%;
  top: 1.35em;
  width: .6em;
  height: .12em;
  margin-left: -.3em;
  border-radius: 1em;
  background: #7a5230;
}

.uvq03-brd .po {
  left: calc(50% - .14em);
  top: 3.7em;
  width: .28em;
  height: 1.1em;
  background: linear-gradient(90deg,#6b4a2c,#9b7149 50%,#6b4a2c);
}

.uvq03-brd .nt {
  position: absolute;
  left: 2.6em;
  top: .2em;
  width: 1em;
  height: 1.4em;
  pointer-events: none;
}

.uvq03-brd .nt i {
  position: absolute;
  bottom: 0;
  font-style: normal;
  font-size: .7em;
  line-height: 1;
  color: var(--c2);
  opacity: 0;
}

.uvq03-brd .nt i + i {
  left: .6em;
}

.uvq03-brd:hover input:not(:checked) + .bh .bd {
  transform: translateY(80%);
}

.uvq03-brd:active .bh {
  scale: .97;
}

.uvq03-brd input:checked + .bh .bd {
  transform: none;
  animation: uvq03-brd calc(1.4s / var(--k)) ease-in-out calc(0.5s / var(--k)) infinite;
}

.uvq03-brd input:checked + .bh .nt i {
  animation: uvq03-brd-n calc(1.6s / var(--k)) ease-out calc(0.6s / var(--k)) infinite;
}

.uvq03-brd input:checked + .bh .nt i + i {
  animation-delay: calc(1.3s / var(--k));
}

@keyframes uvq03-brd {
  0%,60%,100% {
    rotate: 0deg;
  }
  70% {
    rotate: -14deg;
  }
  85% {
    rotate: 8deg;
  }
}

@keyframes uvq03-brd-n {
  0% {
    opacity: 0;
    transform: translate(0,0);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(.5em,-1.2em) rotate(15deg);
  }
}

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

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

export default function TgBirdhouse() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#d8553b",
          "--c2": "#4aa3df",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-brd"><input type="checkbox" role="switch" /><span className="bh"><span className="nt" aria-hidden="true"><i>♪</i><i>♫</i></span><i className="rf"></i><span className="bx"><span className="hl"><span className="bd"><i className="ey"></i><i className="bk"></i></span></span><i className="pc"></i></span><i className="po"></i></span>Wake up to birdsong</label>
      </div>
    </>
  );
}
```

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