# Golf putt button

> On click the ball rolls across the green, drops into the cup and the flagstick lifts for a moment.

- Category: [Buttons](https://library.aimran.es/components/buttons)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-btn-golf-putt
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A pill of mown grass with lighter stripes, a cup, a flag that flutters in the breeze and a dimpled ball waiting on the right. Hovering draws the putting line, and a click sends the ball rolling with a slowing curve until it lips into the hole and the flagstick pops up. Ideal for golf clubs, tee time bookings and sports clubs.

The main color is the grass and the secondary color is the flag, so a links course in deep green or a mini golf in turquoise and yellow are one change away. Speed sets how long the putt takes, and the ball returns by itself.

## Code

### HTML

```html
<button class="uvq01-glf" type="button"><span class="t">Book a tee time</span><span class="gr" aria-hidden="true"><span class="ln"></span><span class="cup"></span><span class="pole"><i></i></span><span class="ball"></span></span></button>
```

### CSS

```css
.uvq01-glf {
  --c1: #2f8f4e;
  --c2: #e63946;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq01-glf {
  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;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  justify-content: flex-start;
  width: 15.5em;
  height: 3.8em;
  padding: 0 1.4em;
  border-radius: 999px;
  overflow: hidden;
  color: #fff;
  font-weight: 750;
  background: repeating-linear-gradient(90deg,rgba(255,255,255,.07) 0 1.2em,transparent 1.2em 2.4em),radial-gradient(120% 160% at 80% 50%,color-mix(in srgb,var(--c1) 82%,#fff),var(--c1) 60%,color-mix(in srgb,var(--c1) 72%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25),inset 0 -.2em .4em rgba(0,0,0,.2),0 12px 24px -12px color-mix(in srgb,var(--c1) 80%,#000);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-glf .t {
  position: relative;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.uvq01-glf .gr {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 7em;
}

.uvq01-glf .ln {
  position: absolute;
  right: 1.65em;
  top: 62%;
  width: 4em;
  border-top: .1em dashed rgba(255,255,255,.75);
  opacity: 0;
  transform: scaleX(.15);
  transform-origin: 0 0;
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.4s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq01-glf .cup {
  position: absolute;
  right: 1.1em;
  top: 62%;
  width: 1em;
  height: .42em;
  margin-top: -.21em;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%,#0b1a10 40%,#1c3a24);
  box-shadow: inset 0 .08em .1em #000,0 .06em 0 rgba(255,255,255,.3);
}

.uvq01-glf .pole {
  position: absolute;
  right: 1.56em;
  top: .45em;
  width: .09em;
  height: calc(62% - .45em);
  background: linear-gradient(90deg,#cfd3d6,#fff,#a9aeb3);
}

.uvq01-glf .pole i {
  position: absolute;
  left: 100%;
  top: 0;
  width: 1.05em;
  height: .7em;
  background: var(--c2);
  clip-path: polygon(0 0,100% 50%,0 100%);
  transform-origin: 0 50%;
  animation: uvq01-glf-fl calc(1.6s / var(--k)) ease-in-out infinite alternate;
}

.uvq01-glf .ball {
  position: absolute;
  right: 5.4em;
  top: 62%;
  width: .62em;
  height: .62em;
  margin-top: -.42em;
  border-radius: 50%;
  background: radial-gradient(circle at 26% 38%,rgba(0,0,0,.12) 0 .05em,transparent .07em),radial-gradient(circle at 56% 62%,rgba(0,0,0,.12) 0 .05em,transparent .07em),radial-gradient(circle at 35% 30%,#fff,#e9ecef 55%,#b9bec4);
  box-shadow: 0 .12em .12em rgba(0,0,0,.35);
  animation: uvq01-glf-in calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-glf:hover .ln,.uvq01-glf:focus-visible .ln {
  opacity: 1;
  transform: none;
}

.uvq01-glf:hover .ball {
  animation: uvq01-glf-wig calc(0.5s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-glf.is-putt .ln {
  opacity: 0;
}

.uvq01-glf.is-putt .ball {
  animation: uvq01-glf-roll calc(1.3s / var(--k)) forwards;
}

.uvq01-glf.is-putt .pole {
  animation: uvq01-glf-up calc(0.6s / var(--k)) cubic-bezier(.34,1.56,.64,1) calc(0.95s / var(--k)) both;
}

.uvq01-glf:active {
  transform: scale(.98);
}

.uvq01-glf:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq01-glf-fl {
  0% {
    transform: skewY(-6deg) scaleX(.9);
  }
  100% {
    transform: skewY(5deg) scaleX(1);
  }
}

@keyframes uvq01-glf-in {
  0% {
    opacity: 0;
    transform: scale(.4);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes uvq01-glf-wig {
  30% {
    transform: translateX(-.08em);
  }
  60% {
    transform: translateX(.05em);
  }
}

@keyframes uvq01-glf-roll {
  0% {
    transform: none;
    animation-timing-function: cubic-bezier(.15,.6,.35,1);
  }
  62% {
    transform: translateX(3.95em);
    opacity: 1;
    animation-timing-function: ease-in;
  }
  74% {
    transform: translateX(4.1em) translateY(.18em) scale(.55);
    opacity: 1;
  }
  82%,100% {
    transform: translateX(4.1em) translateY(.22em) scale(.4);
    opacity: 0;
  }
}

@keyframes uvq01-glf-up {
  0%,100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -.4em;
  }
}

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

### JavaScript

```js
document.querySelectorAll(".uvq01-glf").forEach(el => {
  let tm=0,busy=false;const k=()=>parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;
el.addEventListener("click",()=>{if(busy)return;busy=true;el.classList.add("is-putt");tm=setTimeout(()=>{el.classList.remove("is-putt");busy=false},2300/k())});
return()=>clearTimeout(tm)
});
```

### 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 = `
.uvq01-glf {
  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;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  justify-content: flex-start;
  width: 15.5em;
  height: 3.8em;
  padding: 0 1.4em;
  border-radius: 999px;
  overflow: hidden;
  color: #fff;
  font-weight: 750;
  background: repeating-linear-gradient(90deg,rgba(255,255,255,.07) 0 1.2em,transparent 1.2em 2.4em),radial-gradient(120% 160% at 80% 50%,color-mix(in srgb,var(--c1) 82%,#fff),var(--c1) 60%,color-mix(in srgb,var(--c1) 72%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25),inset 0 -.2em .4em rgba(0,0,0,.2),0 12px 24px -12px color-mix(in srgb,var(--c1) 80%,#000);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-glf .t {
  position: relative;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.uvq01-glf .gr {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 7em;
}

.uvq01-glf .ln {
  position: absolute;
  right: 1.65em;
  top: 62%;
  width: 4em;
  border-top: .1em dashed rgba(255,255,255,.75);
  opacity: 0;
  transform: scaleX(.15);
  transform-origin: 0 0;
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.4s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq01-glf .cup {
  position: absolute;
  right: 1.1em;
  top: 62%;
  width: 1em;
  height: .42em;
  margin-top: -.21em;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%,#0b1a10 40%,#1c3a24);
  box-shadow: inset 0 .08em .1em #000,0 .06em 0 rgba(255,255,255,.3);
}

.uvq01-glf .pole {
  position: absolute;
  right: 1.56em;
  top: .45em;
  width: .09em;
  height: calc(62% - .45em);
  background: linear-gradient(90deg,#cfd3d6,#fff,#a9aeb3);
}

.uvq01-glf .pole i {
  position: absolute;
  left: 100%;
  top: 0;
  width: 1.05em;
  height: .7em;
  background: var(--c2);
  clip-path: polygon(0 0,100% 50%,0 100%);
  transform-origin: 0 50%;
  animation: uvq01-glf-fl calc(1.6s / var(--k)) ease-in-out infinite alternate;
}

.uvq01-glf .ball {
  position: absolute;
  right: 5.4em;
  top: 62%;
  width: .62em;
  height: .62em;
  margin-top: -.42em;
  border-radius: 50%;
  background: radial-gradient(circle at 26% 38%,rgba(0,0,0,.12) 0 .05em,transparent .07em),radial-gradient(circle at 56% 62%,rgba(0,0,0,.12) 0 .05em,transparent .07em),radial-gradient(circle at 35% 30%,#fff,#e9ecef 55%,#b9bec4);
  box-shadow: 0 .12em .12em rgba(0,0,0,.35);
  animation: uvq01-glf-in calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-glf:hover .ln,.uvq01-glf:focus-visible .ln {
  opacity: 1;
  transform: none;
}

.uvq01-glf:hover .ball {
  animation: uvq01-glf-wig calc(0.5s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-glf.is-putt .ln {
  opacity: 0;
}

.uvq01-glf.is-putt .ball {
  animation: uvq01-glf-roll calc(1.3s / var(--k)) forwards;
}

.uvq01-glf.is-putt .pole {
  animation: uvq01-glf-up calc(0.6s / var(--k)) cubic-bezier(.34,1.56,.64,1) calc(0.95s / var(--k)) both;
}

.uvq01-glf:active {
  transform: scale(.98);
}

.uvq01-glf:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq01-glf-fl {
  0% {
    transform: skewY(-6deg) scaleX(.9);
  }
  100% {
    transform: skewY(5deg) scaleX(1);
  }
}

@keyframes uvq01-glf-in {
  0% {
    opacity: 0;
    transform: scale(.4);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes uvq01-glf-wig {
  30% {
    transform: translateX(-.08em);
  }
  60% {
    transform: translateX(.05em);
  }
}

@keyframes uvq01-glf-roll {
  0% {
    transform: none;
    animation-timing-function: cubic-bezier(.15,.6,.35,1);
  }
  62% {
    transform: translateX(3.95em);
    opacity: 1;
    animation-timing-function: ease-in;
  }
  74% {
    transform: translateX(4.1em) translateY(.18em) scale(.55);
    opacity: 1;
  }
  82%,100% {
    transform: translateX(4.1em) translateY(.22em) scale(.4);
    opacity: 0;
  }
}

@keyframes uvq01-glf-up {
  0%,100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -.4em;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-glf,.uvq01-glf *,.uvq01-glf *::before,.uvq01-glf *::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) {
  let tm=0,busy=false;const k=()=>parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;
el.addEventListener("click",()=>{if(busy)return;busy=true;el.classList.add("is-putt");tm=setTimeout(()=>{el.classList.remove("is-putt");busy=false},2300/k())});
return()=>clearTimeout(tm)
}

export default function BtnGolfPutt() {
  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": "#2f8f4e",
          "--c2": "#e63946",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uvq01-glf" type="button"><span className="t">Book a tee time</span><span className="gr" aria-hidden="true"><span className="ln"></span><span className="cup"></span><span className="pole"><i></i></span><span className="ball"></span></span></button>
      </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 “Golf putt button” block (Buttons) from AIMRAN Library to my project.

## What it is
On click the ball rolls across the green, drops into the cup and the flagstick lifts for a moment.

## Chosen settings
- Main color: #2f8f4e
- Secondary color: #e63946
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Reservar tee"

## 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 = `
.uvq01-glf {
  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;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  justify-content: flex-start;
  width: 15.5em;
  height: 3.8em;
  padding: 0 1.4em;
  border-radius: 999px;
  overflow: hidden;
  color: #fff;
  font-weight: 750;
  background: repeating-linear-gradient(90deg,rgba(255,255,255,.07) 0 1.2em,transparent 1.2em 2.4em),radial-gradient(120% 160% at 80% 50%,color-mix(in srgb,var(--c1) 82%,#fff),var(--c1) 60%,color-mix(in srgb,var(--c1) 72%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25),inset 0 -.2em .4em rgba(0,0,0,.2),0 12px 24px -12px color-mix(in srgb,var(--c1) 80%,#000);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-glf .t {
  position: relative;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.uvq01-glf .gr {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 7em;
}

.uvq01-glf .ln {
  position: absolute;
  right: 1.65em;
  top: 62%;
  width: 4em;
  border-top: .1em dashed rgba(255,255,255,.75);
  opacity: 0;
  transform: scaleX(.15);
  transform-origin: 0 0;
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.4s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq01-glf .cup {
  position: absolute;
  right: 1.1em;
  top: 62%;
  width: 1em;
  height: .42em;
  margin-top: -.21em;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%,#0b1a10 40%,#1c3a24);
  box-shadow: inset 0 .08em .1em #000,0 .06em 0 rgba(255,255,255,.3);
}

.uvq01-glf .pole {
  position: absolute;
  right: 1.56em;
  top: .45em;
  width: .09em;
  height: calc(62% - .45em);
  background: linear-gradient(90deg,#cfd3d6,#fff,#a9aeb3);
}

.uvq01-glf .pole i {
  position: absolute;
  left: 100%;
  top: 0;
  width: 1.05em;
  height: .7em;
  background: var(--c2);
  clip-path: polygon(0 0,100% 50%,0 100%);
  transform-origin: 0 50%;
  animation: uvq01-glf-fl calc(1.6s / var(--k)) ease-in-out infinite alternate;
}

.uvq01-glf .ball {
  position: absolute;
  right: 5.4em;
  top: 62%;
  width: .62em;
  height: .62em;
  margin-top: -.42em;
  border-radius: 50%;
  background: radial-gradient(circle at 26% 38%,rgba(0,0,0,.12) 0 .05em,transparent .07em),radial-gradient(circle at 56% 62%,rgba(0,0,0,.12) 0 .05em,transparent .07em),radial-gradient(circle at 35% 30%,#fff,#e9ecef 55%,#b9bec4);
  box-shadow: 0 .12em .12em rgba(0,0,0,.35);
  animation: uvq01-glf-in calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-glf:hover .ln,.uvq01-glf:focus-visible .ln {
  opacity: 1;
  transform: none;
}

.uvq01-glf:hover .ball {
  animation: uvq01-glf-wig calc(0.5s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-glf.is-putt .ln {
  opacity: 0;
}

.uvq01-glf.is-putt .ball {
  animation: uvq01-glf-roll calc(1.3s / var(--k)) forwards;
}

.uvq01-glf.is-putt .pole {
  animation: uvq01-glf-up calc(0.6s / var(--k)) cubic-bezier(.34,1.56,.64,1) calc(0.95s / var(--k)) both;
}

.uvq01-glf:active {
  transform: scale(.98);
}

.uvq01-glf:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq01-glf-fl {
  0% {
    transform: skewY(-6deg) scaleX(.9);
  }
  100% {
    transform: skewY(5deg) scaleX(1);
  }
}

@keyframes uvq01-glf-in {
  0% {
    opacity: 0;
    transform: scale(.4);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes uvq01-glf-wig {
  30% {
    transform: translateX(-.08em);
  }
  60% {
    transform: translateX(.05em);
  }
}

@keyframes uvq01-glf-roll {
  0% {
    transform: none;
    animation-timing-function: cubic-bezier(.15,.6,.35,1);
  }
  62% {
    transform: translateX(3.95em);
    opacity: 1;
    animation-timing-function: ease-in;
  }
  74% {
    transform: translateX(4.1em) translateY(.18em) scale(.55);
    opacity: 1;
  }
  82%,100% {
    transform: translateX(4.1em) translateY(.22em) scale(.4);
    opacity: 0;
  }
}

@keyframes uvq01-glf-up {
  0%,100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -.4em;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-glf,.uvq01-glf *,.uvq01-glf *::before,.uvq01-glf *::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) {
  let tm=0,busy=false;const k=()=>parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;
el.addEventListener("click",()=>{if(busy)return;busy=true;el.classList.add("is-putt");tm=setTimeout(()=>{el.classList.remove("is-putt");busy=false},2300/k())});
return()=>clearTimeout(tm)
}

export default function BtnGolfPutt() {
  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": "#2f8f4e",
          "--c2": "#e63946",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uvq01-glf" type="button"><span className="t">Book a tee time</span><span className="gr" aria-hidden="true"><span className="ln"></span><span className="cup"></span><span className="pole"><i></i></span><span className="ball"></span></span></button>
      </div>
    </>
  );
}
```

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