# Waking sunflower toggle

> When the sun comes out, the sunflower lifts its drooping head and opens its petals one after another.

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

## Where to use it

This switch is a sunflower on a tall stem with two leaves, drooping and dull when off. Turning it on brings the sun up in the corner, the head lifts with a springy swing towards it, the colours warm up and twelve petals open one by one around the seeded centre. It suits solar energy apps, daylight modes and gardening sites.

The main color is the petals and the second one is the sun. Deep gold with a red sun gives a late summer look, pale lemon a spring one. A label about the sun or energy fits it best.

## Code

### HTML

```html
<label class="uvq03-snf"><input type="checkbox" role="switch"><span class="gd"><i class="sn"></i><i class="st"></i><i class="lf a"></i><i class="lf b"></i><span class="hd"><i class="pt" style="--i:0"></i><i class="pt" style="--i:1"></i><i class="pt" style="--i:2"></i><i class="pt" style="--i:3"></i><i class="pt" style="--i:4"></i><i class="pt" style="--i:5"></i><i class="pt" style="--i:6"></i><i class="pt" style="--i:7"></i><i class="pt" style="--i:8"></i><i class="pt" style="--i:9"></i><i class="pt" style="--i:10"></i><i class="pt" style="--i:11"></i><i class="cn"></i></span></span>Solar mode</label>
```

### CSS

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

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

.uvq03-snf .gd {
  position: relative;
  display: block;
  flex: none;
  width: 3.8em;
  height: 4.6em;
  border-radius: .5em;
}

.uvq03-snf .gd > i {
  position: absolute;
  display: block;
}

.uvq03-snf .sn {
  right: -.1em;
  top: -.1em;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: var(--c2);
  box-shadow: 0 0 0 .14em color-mix(in srgb,var(--c2) 30%,transparent),0 0 .9em .2em color-mix(in srgb,var(--c2) 55%,transparent);
  opacity: 0;
  transform: translateY(.8em) scale(.6);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-snf .st {
  left: calc(50% - .09em);
  top: 2.3em;
  width: .18em;
  height: 2.3em;
  border-radius: 1em;
  background: linear-gradient(90deg,#3f7d2c,#6cb34a 50%,#3f7d2c);
}

.uvq03-snf .lf {
  top: 3em;
  width: 1em;
  height: .45em;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg,#7cc35a,#3f7d2c);
}

.uvq03-snf .lf.a {
  left: .95em;
  transform: rotate(20deg) scaleX(-1);
}

.uvq03-snf .lf.b {
  left: 1.95em;
  top: 2.55em;
  transform: rotate(-20deg);
}

.uvq03-snf .hd {
  position: absolute;
  left: calc(50% - .9em);
  top: .65em;
  width: 1.8em;
  height: 1.8em;
  transform-origin: 50% 100%;
  transform: rotate(70deg) scale(.85);
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  filter: saturate(.55) brightness(.92);
}

.uvq03-snf .pt {
  position: absolute;
  left: 50%;
  top: 50%;
  width: .42em;
  height: .85em;
  margin: -.425em 0 0 -.21em;
  border-radius: 50%;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 60%,#fff),var(--c1));
  transform: rotate(calc(var(--i) * 30deg)) translateY(-.62em) scaleY(.35);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  transition-delay: calc((11 - var(--i)) * calc(0.02s / var(--k)));
}

.uvq03-snf .cn {
  position: absolute;
  left: 50%;
  top: 50%;
  width: .95em;
  height: .95em;
  margin: -.475em;
  border-radius: 50%;
  background: radial-gradient(circle,#3a2412 30%,transparent 34%) 0 0/.16em .16em,radial-gradient(circle,#7a4a22,#4a2c12);
  box-shadow: 0 0 0 .05em #3a2412;
}

.uvq03-snf:hover input:not(:checked) + .gd .hd {
  transform: rotate(55deg) scale(.85);
}

.uvq03-snf:active .gd {
  scale: .97;
}

.uvq03-snf input:checked + .gd .sn {
  opacity: 1;
  transform: none;
}

.uvq03-snf input:checked + .gd .hd {
  transform: rotate(-10deg) scale(1);
  filter: none;
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1) calc(0.2s / var(--k)),filter calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.2s / var(--k));
}

.uvq03-snf input:checked + .gd .pt {
  transform: rotate(calc(var(--i) * 30deg)) translateY(-.62em) scaleY(1);
  transition-delay: calc(calc(0.5s / var(--k)) + var(--i) * calc(0.04s / var(--k)));
}

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

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

### React

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

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

.uvq03-snf .gd {
  position: relative;
  display: block;
  flex: none;
  width: 3.8em;
  height: 4.6em;
  border-radius: .5em;
}

.uvq03-snf .gd > i {
  position: absolute;
  display: block;
}

.uvq03-snf .sn {
  right: -.1em;
  top: -.1em;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: var(--c2);
  box-shadow: 0 0 0 .14em color-mix(in srgb,var(--c2) 30%,transparent),0 0 .9em .2em color-mix(in srgb,var(--c2) 55%,transparent);
  opacity: 0;
  transform: translateY(.8em) scale(.6);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-snf .st {
  left: calc(50% - .09em);
  top: 2.3em;
  width: .18em;
  height: 2.3em;
  border-radius: 1em;
  background: linear-gradient(90deg,#3f7d2c,#6cb34a 50%,#3f7d2c);
}

.uvq03-snf .lf {
  top: 3em;
  width: 1em;
  height: .45em;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg,#7cc35a,#3f7d2c);
}

.uvq03-snf .lf.a {
  left: .95em;
  transform: rotate(20deg) scaleX(-1);
}

.uvq03-snf .lf.b {
  left: 1.95em;
  top: 2.55em;
  transform: rotate(-20deg);
}

.uvq03-snf .hd {
  position: absolute;
  left: calc(50% - .9em);
  top: .65em;
  width: 1.8em;
  height: 1.8em;
  transform-origin: 50% 100%;
  transform: rotate(70deg) scale(.85);
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  filter: saturate(.55) brightness(.92);
}

.uvq03-snf .pt {
  position: absolute;
  left: 50%;
  top: 50%;
  width: .42em;
  height: .85em;
  margin: -.425em 0 0 -.21em;
  border-radius: 50%;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 60%,#fff),var(--c1));
  transform: rotate(calc(var(--i) * 30deg)) translateY(-.62em) scaleY(.35);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  transition-delay: calc((11 - var(--i)) * calc(0.02s / var(--k)));
}

.uvq03-snf .cn {
  position: absolute;
  left: 50%;
  top: 50%;
  width: .95em;
  height: .95em;
  margin: -.475em;
  border-radius: 50%;
  background: radial-gradient(circle,#3a2412 30%,transparent 34%) 0 0/.16em .16em,radial-gradient(circle,#7a4a22,#4a2c12);
  box-shadow: 0 0 0 .05em #3a2412;
}

.uvq03-snf:hover input:not(:checked) + .gd .hd {
  transform: rotate(55deg) scale(.85);
}

.uvq03-snf:active .gd {
  scale: .97;
}

.uvq03-snf input:checked + .gd .sn {
  opacity: 1;
  transform: none;
}

.uvq03-snf input:checked + .gd .hd {
  transform: rotate(-10deg) scale(1);
  filter: none;
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1) calc(0.2s / var(--k)),filter calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.2s / var(--k));
}

.uvq03-snf input:checked + .gd .pt {
  transform: rotate(calc(var(--i) * 30deg)) translateY(-.62em) scaleY(1);
  transition-delay: calc(calc(0.5s / var(--k)) + var(--i) * calc(0.04s / var(--k)));
}

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

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

export default function TgSunflower() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#ffc400",
          "--c2": "#ff8a1f",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-snf"><input type="checkbox" role="switch" /><span className="gd"><i className="sn"></i><i className="st"></i><i className="lf a"></i><i className="lf b"></i><span className="hd"><i className="pt" style={{ "--i": "0" } as CSSProperties}></i><i className="pt" style={{ "--i": "1" } as CSSProperties}></i><i className="pt" style={{ "--i": "2" } as CSSProperties}></i><i className="pt" style={{ "--i": "3" } as CSSProperties}></i><i className="pt" style={{ "--i": "4" } as CSSProperties}></i><i className="pt" style={{ "--i": "5" } as CSSProperties}></i><i className="pt" style={{ "--i": "6" } as CSSProperties}></i><i className="pt" style={{ "--i": "7" } as CSSProperties}></i><i className="pt" style={{ "--i": "8" } as CSSProperties}></i><i className="pt" style={{ "--i": "9" } as CSSProperties}></i><i className="pt" style={{ "--i": "10" } as CSSProperties}></i><i className="pt" style={{ "--i": "11" } as CSSProperties}></i><i className="cn"></i></span></span>Solar 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 “Waking sunflower toggle” block (Toggles) from AIMRAN Library to my project.

## What it is
When the sun comes out, the sunflower lifts its drooping head and opens its petals one after another.

## Chosen settings
- Main color: #ffc400
- Secondary color: #ff8a1f
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Modo solar"

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

.uvq03-snf .gd {
  position: relative;
  display: block;
  flex: none;
  width: 3.8em;
  height: 4.6em;
  border-radius: .5em;
}

.uvq03-snf .gd > i {
  position: absolute;
  display: block;
}

.uvq03-snf .sn {
  right: -.1em;
  top: -.1em;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: var(--c2);
  box-shadow: 0 0 0 .14em color-mix(in srgb,var(--c2) 30%,transparent),0 0 .9em .2em color-mix(in srgb,var(--c2) 55%,transparent);
  opacity: 0;
  transform: translateY(.8em) scale(.6);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-snf .st {
  left: calc(50% - .09em);
  top: 2.3em;
  width: .18em;
  height: 2.3em;
  border-radius: 1em;
  background: linear-gradient(90deg,#3f7d2c,#6cb34a 50%,#3f7d2c);
}

.uvq03-snf .lf {
  top: 3em;
  width: 1em;
  height: .45em;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg,#7cc35a,#3f7d2c);
}

.uvq03-snf .lf.a {
  left: .95em;
  transform: rotate(20deg) scaleX(-1);
}

.uvq03-snf .lf.b {
  left: 1.95em;
  top: 2.55em;
  transform: rotate(-20deg);
}

.uvq03-snf .hd {
  position: absolute;
  left: calc(50% - .9em);
  top: .65em;
  width: 1.8em;
  height: 1.8em;
  transform-origin: 50% 100%;
  transform: rotate(70deg) scale(.85);
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  filter: saturate(.55) brightness(.92);
}

.uvq03-snf .pt {
  position: absolute;
  left: 50%;
  top: 50%;
  width: .42em;
  height: .85em;
  margin: -.425em 0 0 -.21em;
  border-radius: 50%;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c1) 60%,#fff),var(--c1));
  transform: rotate(calc(var(--i) * 30deg)) translateY(-.62em) scaleY(.35);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  transition-delay: calc((11 - var(--i)) * calc(0.02s / var(--k)));
}

.uvq03-snf .cn {
  position: absolute;
  left: 50%;
  top: 50%;
  width: .95em;
  height: .95em;
  margin: -.475em;
  border-radius: 50%;
  background: radial-gradient(circle,#3a2412 30%,transparent 34%) 0 0/.16em .16em,radial-gradient(circle,#7a4a22,#4a2c12);
  box-shadow: 0 0 0 .05em #3a2412;
}

.uvq03-snf:hover input:not(:checked) + .gd .hd {
  transform: rotate(55deg) scale(.85);
}

.uvq03-snf:active .gd {
  scale: .97;
}

.uvq03-snf input:checked + .gd .sn {
  opacity: 1;
  transform: none;
}

.uvq03-snf input:checked + .gd .hd {
  transform: rotate(-10deg) scale(1);
  filter: none;
  transition: transform calc(0.9s / var(--k)) cubic-bezier(.34,1.56,.64,1) calc(0.2s / var(--k)),filter calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.2s / var(--k));
}

.uvq03-snf input:checked + .gd .pt {
  transform: rotate(calc(var(--i) * 30deg)) translateY(-.62em) scaleY(1);
  transition-delay: calc(calc(0.5s / var(--k)) + var(--i) * calc(0.04s / var(--k)));
}

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

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

export default function TgSunflower() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#ffc400",
          "--c2": "#ff8a1f",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-snf"><input type="checkbox" role="switch" /><span className="gd"><i className="sn"></i><i className="st"></i><i className="lf a"></i><i className="lf b"></i><span className="hd"><i className="pt" style={{ "--i": "0" } as CSSProperties}></i><i className="pt" style={{ "--i": "1" } as CSSProperties}></i><i className="pt" style={{ "--i": "2" } as CSSProperties}></i><i className="pt" style={{ "--i": "3" } as CSSProperties}></i><i className="pt" style={{ "--i": "4" } as CSSProperties}></i><i className="pt" style={{ "--i": "5" } as CSSProperties}></i><i className="pt" style={{ "--i": "6" } as CSSProperties}></i><i className="pt" style={{ "--i": "7" } as CSSProperties}></i><i className="pt" style={{ "--i": "8" } as CSSProperties}></i><i className="pt" style={{ "--i": "9" } as CSSProperties}></i><i className="pt" style={{ "--i": "10" } as CSSProperties}></i><i className="pt" style={{ "--i": "11" } as CSSProperties}></i><i className="cn"></i></span></span>Solar 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.
````
