Actions JS behaviour

Flowing gradient button

The gradient is painted at 220% under the button and hover slides it across while the label leans out of its way — three palettes, three sizes, a link mode and an always-flowing switch for heroes.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

The upgrade row

The gradient is painted at 220% and hover slides it across while the label steps out of its way. The switch keeps the current flowing with no pointer — the hero treatment.

Compare the plans

Pro starts at the top of next month — the invoice lands in your inbox.

Three sizes, three palettes

sm keeps a quiet corner action, md is the workhorse and lg carries the hero; the palettes only swap three colour stops, nothing else moves.

aurora · ocean · meadow

حالت لینک و جهت دیگر

لینک هم همان دکمه است — گرادیان در راست‌به‌چپ از سوی مقابل سُر می‌خورد و برچسب به سمت دیگرِ مسیر خم می‌شود.

آزمایش رایگان 14 روزه — بدون کارت بانکی

Important props

Important props
Prop Type Default What it does
--ghb-a · --ghb-b · --ghb-c color '#7c3aed · #db2777 · #f59e0b' The three stops of the flowing gradient; the palettes (aurora, ocean, meadow) swap exactly these variables.
background-size technique '220% 220%' The gradient is painted larger than the button and hover only moves background-position — no math, no layer juggling.
labelOffset px '2 · -1' On hover the label steps 2px forward and 1px up; in RTL it leans the other way.
size string 'md' Sizes: sm · md · lg.
flow boolean false With data-flow the gradient keeps drifting with no pointer — for banners and heroes.

Snippet

<div class="ghb" x-data="{ flow: false, palette: 'aurora' }">
    <div class="ghb-chips" role="group" aria-label="Gradient palette">
        <button type="button" class="ghb-chip" x-bind:aria-pressed="palette === 'aurora'" x-on:click="palette = 'aurora'">Aurora</button>
        <button type="button" class="ghb-chip" x-bind:aria-pressed="palette === 'ocean'" x-on:click="palette = 'ocean'">Ocean</button>
        <button type="button" class="ghb-chip" x-bind:aria-pressed="palette === 'meadow'" x-on:click="palette = 'meadow'">Meadow</button>
    </div>
    <label class="ghb-switch">
        <input type="checkbox" x-model="flow">
        Keep it flowing
    </label>
    <button type="button" class="ghb-btn" data-size="lg" x-bind:data-palette="palette" x-bind:data-flow="flow">
        <span class="ghb-label">Upgrade to the Pro plan</span>
    </button>
    <a class="ghb-btn" data-palette="ocean" href="/plans">
        <span class="ghb-label">See all plans</span>
    </a>
</div>

<style>
.ghb { display: grid; gap: 1rem; justify-items: center; }
.ghb-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.ghb-chip { padding: .4rem .9rem; border: 1px solid #e2e8f0; border-radius: 999px;
            background: #fff; color: #0f172a; cursor: pointer; font-size: .8rem; }
.ghb-chip[aria-pressed='true'] { border-color: #7c3aed; color: #7c3aed; }
.ghb-switch { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; color: #475569; }
.ghb-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .7rem 1.6rem; border: 0; border-radius: 999px; cursor: pointer;
    color: #fff; font-weight: 600; font-size: .95rem; line-height: 1; text-decoration: none;
    --ghb-a: #7c3aed; --ghb-b: #db2777; --ghb-c: #f59e0b;
    background-image: linear-gradient(115deg, var(--ghb-a), var(--ghb-b) 45%, var(--ghb-c));
    background-size: 220% 220%; background-position: 12% 50%;
    transition: background-position .6s ease, box-shadow .35s ease;
}
.ghb-btn[data-palette='ocean'] { --ghb-a: #06b6d4; --ghb-b: #3b82f6; --ghb-c: #6366f1; }
.ghb-btn[data-palette='meadow'] { --ghb-a: #10b981; --ghb-b: #84cc16; --ghb-c: #facc15; }
.ghb-btn[data-size='lg'] { padding: .95rem 2.1rem; font-size: 1.1rem; }
.ghb-btn:hover, .ghb-btn:focus-visible { background-position: 88% 50%; box-shadow: 0 12px 32px -12px var(--ghb-b); }
.ghb-btn:focus-visible { outline: 2px solid var(--ghb-b); outline-offset: 3px; }
.ghb-label { transition: translate .35s ease; }
.ghb-btn:hover .ghb-label, .ghb-btn:focus-visible .ghb-label { translate: 2px -1px; }
html[dir='rtl'] .ghb-btn:hover .ghb-label,
html[dir='rtl'] .ghb-btn:focus-visible .ghb-label { translate: -2px -1px; }
.ghb-btn[data-flow='true'] { animation: ghb-flow 3.2s ease-in-out infinite alternate; }
@keyframes ghb-flow { from { background-position: 12% 50%; } to { background-position: 88% 50%; } }
@media (prefers-reduced-motion: reduce) {
    .ghb-btn, .ghb-label { transition: none; }
    .ghb-btn[data-flow='true'] { animation: none; }
}
</style>
// app/Pages/Pricing.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import UpgradeRow from '@/components/UpgradeRow';

export default function Pricing() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <UpgradeRow />
      </main>
    </NabuXUIProvider>
  );
}
// UpgradeRow.jsx — the flowing gradient button: palette chips, sizes, link
import { useState } from 'react';
import '@nabuxai/ui-core/css';

const PALETTES = {
  aurora: ['#7c3aed', '#db2777', '#f59e0b'],
  ocean: ['#06b6d4', '#3b82f6', '#6366f1'],
  meadow: ['#10b981', '#84cc16', '#facc15'],
};

export default function UpgradeRow() {
  const [palette, setPalette] = useState('aurora');
  const [flow, setFlow] = useState(false);
  const [a, b, c] = PALETTES[palette];

  return (
    <>
      <style>{`
        .ghb { display: grid; gap: 1rem; justify-items: center; }
        .ghb-btn { display: inline-flex; align-items: center; justify-content: center;
                   padding: .7rem 1.6rem; border: 0; border-radius: 999px; cursor: pointer;
                   color: #fff; font: 600 .95rem/1 system-ui; text-decoration: none;
                   background-image: linear-gradient(115deg, var(--ghb-a), var(--ghb-b) 45%, var(--ghb-c));
                   background-size: 220% 220%; background-position: 12% 50%;
                   transition: background-position .6s ease, box-shadow .35s ease; }
        .ghb-btn[data-size='lg'] { padding: .95rem 2.1rem; font-size: 1.1rem; }
        .ghb-btn:hover, .ghb-btn:focus-visible { background-position: 88% 50%;
                                                 box-shadow: 0 12px 32px -12px var(--ghb-b); }
        .ghb-btn:focus-visible { outline: 2px solid var(--ghb-b); outline-offset: 3px; }
        .ghb-label { transition: translate .35s ease; }
        .ghb-btn:hover .ghb-label, .ghb-btn:focus-visible .ghb-label { translate: 2px -1px; }
        .ghb-btn[data-flow='true'] { animation: ghb-flow 3.2s ease-in-out infinite alternate; }
        @keyframes ghb-flow { from { background-position: 12% 50%; } to { background-position: 88% 50%; } }
        @media (prefers-reduced-motion: reduce) {
          .ghb-btn, .ghb-label { transition: none; }
          .ghb-btn[data-flow='true'] { animation: none; }
        }
      `}</style>
      <div className="ghb" style={{ '--ghb-a': a, '--ghb-b': b, '--ghb-c': c }}>
        {Object.keys(PALETTES).map((name) => (
          <button key={name} type="button" aria-pressed={palette === name} onClick={() => setPalette(name)}>
            {name}
          </button>
        ))}
        <label>
          <input type="checkbox" checked={flow} onChange={(e) => setFlow(e.target.checked)} /> Keep it flowing
        </label>
        <button type="button" className="ghb-btn" data-size="lg" data-flow={flow}>
          <span className="ghb-label">Upgrade to the Pro plan</span>
        </button>
        <a className="ghb-btn" href="/plans"><span className="ghb-label">See all plans</span></a>
      </div>
    </>
  );
}
<!-- UpgradeRow.vue — the flowing gradient button: palette chips, sizes, link -->
<script setup lang="ts">
import { computed, ref } from 'vue';
import '@nabuxai/ui-core/css';

const PALETTES: Record<string, string[]> = {
  aurora: ['#7c3aed', '#db2777', '#f59e0b'],
  ocean: ['#06b6d4', '#3b82f6', '#6366f1'],
  meadow: ['#10b981', '#84cc16', '#facc15'],
};
const palette = ref<string>('aurora');
const flow = ref(false);
const stops = computed(() => PALETTES[palette.value]);
</script>

<template>
  <div class="ghb" :style="{ '--ghb-a': stops[0], '--ghb-b': stops[1], '--ghb-c': stops[2] }">
    <button v-for="(s, name) in PALETTES" :key="name" type="button"
            :aria-pressed="palette === name" @click="palette = String(name)">
      {{ name }}
    </button>
    <label><input v-model="flow" type="checkbox" /> Keep it flowing</label>
    <button type="button" class="ghb-btn" data-size="lg" :data-flow="flow">
      <span class="ghb-label">Upgrade to the Pro plan</span>
    </button>
    <a class="ghb-btn" href="/plans"><span class="ghb-label">See all plans</span></a>
  </div>
</template>

<style scoped>
.ghb { display: grid; gap: 1rem; justify-items: center; }
.ghb-btn { display: inline-flex; align-items: center; justify-content: center;
           padding: .7rem 1.6rem; border: 0; border-radius: 999px; cursor: pointer;
           color: #fff; font: 600 .95rem/1 system-ui; text-decoration: none;
           background-image: linear-gradient(115deg, var(--ghb-a), var(--ghb-b) 45%, var(--ghb-c));
           background-size: 220% 220%; background-position: 12% 50%;
           transition: background-position .6s ease, box-shadow .35s ease; }
.ghb-btn[data-size='lg'] { padding: .95rem 2.1rem; font-size: 1.1rem; }
.ghb-btn:hover, .ghb-btn:focus-visible { background-position: 88% 50%;
                                         box-shadow: 0 12px 32px -12px var(--ghb-b); }
.ghb-btn:focus-visible { outline: 2px solid var(--ghb-b); outline-offset: 3px; }
.ghb-label { transition: translate .35s ease; }
.ghb-btn:hover .ghb-label, .ghb-btn:focus-visible .ghb-label { translate: 2px -1px; }
.ghb-btn[data-flow='true'] { animation: ghb-flow 3.2s ease-in-out infinite alternate; }
@keyframes ghb-flow { from { background-position: 12% 50%; } to { background-position: 88% 50%; } }
@media (prefers-reduced-motion: reduce) {
  .ghb-btn, .ghb-label { transition: none; }
  .ghb-btn[data-flow='true'] { animation: none; }
}
</style>
<!-- UpgradeRow.svelte — the flowing gradient button: palette chips, sizes, link -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  const PALETTES: Record<string, string[]> = {
    aurora: ['#7c3aed', '#db2777', '#f59e0b'],
    ocean: ['#06b6d4', '#3b82f6', '#6366f1'],
    meadow: ['#10b981', '#84cc16', '#facc15'],
  };
  let palette = $state('aurora');
  let flow = $state(false);
  const stops = $derived(PALETTES[palette]);
</script>

<div class="ghb" style={`--ghb-a:${stops[0]};--ghb-b:${stops[1]};--ghb-c:${stops[2]}`}>
  {#each Object.entries(PALETTES) as [name] (name)}
    <button type="button" aria-pressed={palette === name} onclick={() => (palette = name)}>{name}</button>
  {/each}
  <label><input type="checkbox" bind:checked={flow} /> Keep it flowing</label>
  <button type="button" class="ghb-btn" data-size="lg" data-flow={flow}>
    <span class="ghb-label">Upgrade to the Pro plan</span>
  </button>
  <a class="ghb-btn" href="/plans"><span class="ghb-label">See all plans</span></a>
</div>

<style>
  .ghb { display: grid; gap: 1rem; justify-items: center; }
  .ghb-btn { display: inline-flex; align-items: center; justify-content: center;
             padding: .7rem 1.6rem; border: 0; border-radius: 999px; cursor: pointer;
             color: #fff; font: 600 .95rem/1 system-ui; text-decoration: none;
             background-image: linear-gradient(115deg, var(--ghb-a), var(--ghb-b) 45%, var(--ghb-c));
             background-size: 220% 220%; background-position: 12% 50%;
             transition: background-position .6s ease, box-shadow .35s ease; }
  .ghb-btn[data-size='lg'] { padding: .95rem 2.1rem; font-size: 1.1rem; }
  .ghb-btn:hover, .ghb-btn:focus-visible { background-position: 88% 50%;
                                           box-shadow: 0 12px 32px -12px var(--ghb-b); }
  .ghb-btn:focus-visible { outline: 2px solid var(--ghb-b); outline-offset: 3px; }
  .ghb-label { transition: translate .35s ease; }
  .ghb-btn:hover .ghb-label, .ghb-btn:focus-visible .ghb-label { translate: 2px -1px; }
  .ghb-btn[data-flow='true'] { animation: ghb-flow 3.2s ease-in-out infinite alternate; }
  @keyframes ghb-flow { from { background-position: 12% 50%; } to { background-position: 88% 50%; } }
  @media (prefers-reduced-motion: reduce) {
    .ghb-btn, .ghb-label { transition: none; }
    .ghb-btn[data-flow='true'] { animation: none; }
  }
</style>