Real flows JS behaviour

Onboarding flow

Four real steps from welcome to a ready workspace: role pick, personalization chips and a summary confirm — the progress bar fills per step, back is always there, and steps slide in from a side that mirrors itself in Persian.

Documentation

Real scenarios

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

From hello to a ready workspace

A real four-step wizard with Alpine state only: the progress bar fills as you move, Continue stays locked until the step is honest, Back works from anywhere, and the final screen draws its check while the steps slide in a direction that mirrors in Persian.

Step of 4 Pick one One or more Last look
Meridian

Welcome to your team’s new home

Four short steps and the workspace fits how you work — no credit card, no admin tickets.

  • Dashboards tuned to your role
  • Starter kits picked from real projects
  • Editable any time from settings

What do you do here?

We use this once — to choose which dashboard greets you first.

Tune your feed

Pick what you want landing on your desk every Monday.

Last look before we build it

Everything below is editable later — this is just the honest summary.

Role
Interests
Time to finish
under 5 seconds

Your workspace is ready

Meridian tuned itself for s — your first digest lands Monday 9:00.

Try it in Persian too: the steps arrive from the mirrored side, the numbers go Persian, and nothing else changes.

Important props

Important props
Prop Type Default What it does
steps count '4' welcome → role → personalization → confirm; the frame’s top bar has four segments and fills the current step’s share instantly.
slide translate '28px · 340ms' The next step enters from ahead while the previous exits behind; RTL mirrors both sides so the journey always feels forward.
min-picks number '1' The personalization step keeps Continue locked until at least one chip is picked.
summary slot 'role · picks' The confirm step gathers the role and the picks side by side; the finish message with its big check then takes over the frame.

Snippet

<div class="flwb" x-data="{ step: 0, role: null, picks: [] }">
    <header class="flwb-top">
        <div class="flwb-bar">
            <i data-on></i><i :data-on="step >= 1"></i><i :data-on="step >= 2"></i><i :data-on="step >= 3"></i>
        </div>
        <small>Step <span x-text="step + 1"></span> of 4</small>
    </header>

    <div class="flwb-stage">
        <section class="flwb-step" :data-pos="step === 0 ? 'now' : 'before'">
            <h3>Welcome to Meridian</h3>
            <p>Your team workspace is ready in two minutes.</p>
        </section>
        <section class="flwb-step" :data-pos="step === 1 ? 'now' : (step < 1 ? 'after' : 'before')">
            <button class="flwb-role" :data-on="role === 'designer'" @click="role = 'designer'">Product designer</button>
        </section>
        <section class="flwb-step" :data-pos="step === 2 ? 'now' : (step < 2 ? 'after' : 'before')">
            <button class="flwb-chip" :data-on="picks.includes('motion')" @click="picks.push('motion')">Motion</button>
        </section>
    </div>

    <footer class="flwb-nav">
        <button @click="step--" :disabled="step === 0">Back</button>
        <button :disabled="step === 1 && !role" @click="step++">Continue</button>
    </footer>
</div>

<style>
.flwb-stage { display: grid; } .flwb-step { grid-area: 1 / 1; transition: translate .34s, opacity .34s; }
.flwb-step[data-pos='before'] { translate: -28px 0; opacity: 0; visibility: hidden; }
.flwb-step[data-pos='after']  { translate: 28px 0;  opacity: 0; visibility: hidden; }
.flwb-bar { display: flex; gap: 4px; } .flwb-bar i { flex: 1; block-size: 4px; border-radius: 999px; background: #e4e6ef; }
.flwb-bar i[data-on] { background: #4f46e5; }
</style>
// app/Pages/Onboarding.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 OnboardingWizard from '@/components/OnboardingWizard';

export default function Onboarding() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <OnboardingWizard />
      </main>
    </NabuXUIProvider>
  );
}
// OnboardingWizard.jsx — the four-step onboarding: welcome → role → chips → confirm
import { useState } from 'react';
import '@nabuxai/ui-core/css';

const ROLES = [
  { id: 'designer', name: 'Product designer', note: 'Shapes the interface' },
  { id: 'engineer', name: 'Engineer', note: 'Ships the code' },
  { id: 'manager', name: 'Product manager', note: 'Owns the roadmap' },
  { id: 'marketer', name: 'Marketer', note: 'Tells the story' },
];
const TOPICS = ['Design systems', 'Motion', 'Accessibility', 'Performance', 'Tokens', 'Handoff'];

export default function OnboardingWizard() {
  const [step, setStep] = useState(0);
  const [role, setRole] = useState(null);
  const [topics, setTopics] = useState([]);
  const [done, setDone] = useState(false);
  const flip = (t) => setTopics((s) => (s.includes(t) ? s.filter((x) => x !== t) : [...s, t]));
  const pos = (i) => (i === step ? 'now' : i < step ? 'before' : 'after');
  const canNext = step === 1 ? !!role : step === 2 ? topics.length > 0 : true;

  if (done) return (
    <>
      <style>{FLWB_CSS}</style>
      <div className="flwb flwb-done">
        <span className="flwb-check" aria-hidden="true">✓</span>
        <h3>Your workspace is ready</h3>
        <p>Meridian tuned itself for {ROLES.find((r) => r.id === role).name}s.</p>
        <button type="button" className="flwb-go"
          onClick={() => { setStep(0); setRole(null); setTopics([]); setDone(false); }}>
          Enter the dashboard
        </button>
      </div>
    </>
  );

  return (
    <>
      <style>{FLWB_CSS}</style>
      <div className="flwb">
        <header className="flwb-top">
          <div className="flwb-bar">
            {[0, 1, 2, 3].map((i) => <i data-on={i <= step ? '' : undefined} key={i} />)}
          </div>
          <small>Step {step + 1} of 4</small>
        </header>

        <div className="flwb-stage">
          <section className="flwb-step" data-pos={pos(0)}>
            <h3>Welcome to Meridian</h3>
            <p>Two minutes, four steps — and the workspace fits your team.</p>
            <ul className="flwb-list">
              <li>Role-aware dashboards</li><li>Hand-picked starter kits</li>
            </ul>
          </section>
          <section className="flwb-step" data-pos={pos(1)}>
            <h3>What do you do?</h3>
            <div className="flwb-roles" role="radiogroup" aria-label="Your role">
              {ROLES.map((r) => (
                <button type="button" className="flwb-role" data-on={role === r.id || undefined}
                  key={r.id} onClick={() => setRole(r.id)}>
                  <b>{r.name}</b><small>{r.note}</small><i aria-hidden="true">✓</i>
                </button>
              ))}
            </div>
          </section>
          <section className="flwb-step" data-pos={pos(2)}>
            <h3>Tune your feed</h3>
            <div className="flwb-chips">
              {TOPICS.map((t) => (
                <button type="button" className="flwb-chip" data-on={topics.includes(t) || undefined}
                  key={t} onClick={() => flip(t)}>{t}</button>
              ))}
            </div>
          </section>
          <section className="flwb-step" data-pos={pos(3)}>
            <h3>All set?</h3>
            <dl className="flwb-sum">
              <div><dt>Role</dt><dd>{ROLES.find((r) => r.id === role)?.name}</dd></div>
              <div><dt>Interests</dt><dd>{topics.join(' · ')}</dd></div>
            </dl>
          </section>
        </div>

        <footer className="flwb-nav">
          <button type="button" onClick={() => setStep((s) => s - 1)} disabled={step === 0}>Back</button>
          {step < 3
            ? <button type="button" className="flwb-go" disabled={!canNext} onClick={() => setStep((s) => s + 1)}>Continue</button>
            : <button type="button" className="flwb-go" onClick={() => setDone(true)}>Create workspace</button>}
        </footer>
      </div>
    </>
  );
}

const FLWB_CSS = `
  .flwb { display: grid; gap: 1.25rem; max-inline-size: 26rem; padding: 1.5rem; border: 1px solid #e4e6ef;
          border-radius: 1.25rem; background: #fff; color: #191b2a; }
  .flwb-bar { display: flex; gap: .25rem; }
  .flwb-bar i { flex: 1; block-size: 4px; border-radius: 999px; background: #e4e6ef; }
  .flwb-bar i[data-on] { background: #4f46e5; }
  .flwb-stage { display: grid; }
  .flwb-step { grid-area: 1 / 1; transition: translate .34s cubic-bezier(.2, 0, 0, 1), opacity .34s; }
  .flwb-step[data-pos='before'] { translate: -28px 0; opacity: 0; visibility: hidden; }
  .flwb-step[data-pos='after'] { translate: 28px 0; opacity: 0; visibility: hidden; }
  .flwb-roles { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .flwb-role { position: relative; display: grid; gap: .2rem; padding: .8rem; text-align: start;
               border: 1px solid #e4e6ef; border-radius: .9rem; background: #fff; cursor: pointer; }
  .flwb-role[data-on] { border-color: #4f46e5; box-shadow: inset 0 0 0 1px #4f46e5; }
  .flwb-role i { position: absolute; inset-block-start: .4rem; inset-inline-end: .4rem; display: none;
                 color: #4f46e5; font-style: normal; }
  .flwb-role[data-on] i { display: block; }
  .flwb-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
  .flwb-chip { padding: .45rem .9rem; border: 1px solid #e4e6ef; border-radius: 999px; background: #fff; cursor: pointer; }
  .flwb-chip[data-on] { background: #4f46e5; border-color: #4f46e5; color: #fff; }
  .flwb-sum { display: grid; margin: 0; }
  .flwb-sum div { display: flex; justify-content: space-between; gap: 1rem; padding-block: .5rem;
                  border-block-start: 1px solid #e4e6ef; }
  .flwb-nav { display: flex; justify-content: space-between; gap: .75rem; }
  .flwb-go { padding: .65rem 1.2rem; border: none; border-radius: 999px; background: #4f46e5; color: #fff; cursor: pointer; }
  .flwb-go:disabled { opacity: .45; cursor: not-allowed; }
  .flwb-done { justify-items: center; text-align: center; }
  .flwb-check { display: grid; place-items: center; inline-size: 3.5rem; aspect-ratio: 1; border-radius: 50%;
                background: #e7f6ec; color: #0f8a43; font-size: 1.5rem; }
`;
<!-- OnboardingWizard.vue — the four-step onboarding: welcome → role → chips → confirm -->
<script setup lang="ts">
import { computed, ref } from 'vue';
import '@nabuxai/ui-core/css';

const roles = [
  { id: 'designer', name: 'Product designer', note: 'Shapes the interface' },
  { id: 'engineer', name: 'Engineer', note: 'Ships the code' },
  { id: 'manager', name: 'Product manager', note: 'Owns the roadmap' },
  { id: 'marketer', name: 'Marketer', note: 'Tells the story' },
];
const topics = ['Design systems', 'Motion', 'Accessibility', 'Performance', 'Tokens', 'Handoff'];
const step = ref(0);
const role = ref<string | null>(null);
const picks = ref<string[]>([]);
const done = ref(false);
const flip = (t: string) => {
  picks.value = picks.value.includes(t) ? picks.value.filter((x) => x !== t) : [...picks.value, t];
};
const pos = (i: number) => (i === step.value ? 'now' : i < step.value ? 'before' : 'after');
const roleName = computed(() => roles.find((r) => r.id === role.value)?.name);
const canNext = computed(() =>
  step.value === 1 ? !!role.value : step.value === 2 ? picks.value.length > 0 : true);
const next = () => (step.value < 3 ? step.value++ : (done.value = true));
</script>

<template>
  <div class="flwb" v-if="!done">
    <header class="flwb-top">
      <div class="flwb-bar"><i v-for="i in 4" :key="i" :data-on="i - 1 <= step || undefined"></i></div>
      <small>Step {{ step + 1 }} of 4</small>
    </header>

    <div class="flwb-stage">
      <section class="flwb-step" :data-pos="pos(0)">
        <h3>Welcome to Meridian</h3>
        <p>Two minutes, four steps — and the workspace fits your team.</p>
      </section>
      <section class="flwb-step" :data-pos="pos(1)">
        <h3>What do you do?</h3>
        <div class="flwb-roles" role="radiogroup" aria-label="Your role">
          <button v-for="r in roles" :key="r.id" type="button" class="flwb-role"
            :data-on="role === r.id || undefined" @click="role = r.id">
            <b>{{ r.name }}</b><small>{{ r.note }}</small><i aria-hidden="true">✓</i>
          </button>
        </div>
      </section>
      <section class="flwb-step" :data-pos="pos(2)">
        <h3>Tune your feed</h3>
        <div class="flwb-chips">
          <button v-for="t in topics" :key="t" type="button" class="flwb-chip"
            :data-on="picks.includes(t) || undefined" @click="flip(t)">{{ t }}</button>
        </div>
      </section>
      <section class="flwb-step" :data-pos="pos(3)">
        <h3>All set?</h3>
        <dl class="flwb-sum">
          <div><dt>Role</dt><dd>{{ roleName }}</dd></div>
          <div><dt>Interests</dt><dd>{{ picks.join(' · ') }}</dd></div>
        </dl>
      </section>
    </div>

    <footer class="flwb-nav">
      <button type="button" :disabled="step === 0" @click="step--">Back</button>
      <button type="button" class="flwb-go" :disabled="!canNext" @click="next()">
        {{ step < 3 ? 'Continue' : 'Create workspace' }}
      </button>
    </footer>
  </div>

  <div class="flwb flwb-done" v-else>
    <span class="flwb-check" aria-hidden="true">✓</span>
    <h3>Your workspace is ready</h3>
    <p>Meridian tuned itself for {{ roleName }}s.</p>
    <button type="button" class="flwb-go"
      @click="step = 0; role = null; picks = []; done = false">Enter the dashboard</button>
  </div>
</template>

<style scoped>
.flwb { display: grid; gap: 1.25rem; max-inline-size: 26rem; padding: 1.5rem; border: 1px solid #e4e6ef;
        border-radius: 1.25rem; background: #fff; color: #191b2a; }
.flwb-bar { display: flex; gap: .25rem; }
.flwb-bar i { flex: 1; block-size: 4px; border-radius: 999px; background: #e4e6ef; }
.flwb-bar i[data-on] { background: #4f46e5; }
.flwb-stage { display: grid; }
.flwb-step { grid-area: 1 / 1; transition: translate .34s cubic-bezier(.2, 0, 0, 1), opacity .34s; }
.flwb-step[data-pos='before'] { translate: -28px 0; opacity: 0; visibility: hidden; }
.flwb-step[data-pos='after'] { translate: 28px 0; opacity: 0; visibility: hidden; }
.flwb-roles { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.flwb-role { position: relative; display: grid; gap: .2rem; padding: .8rem; text-align: start;
             border: 1px solid #e4e6ef; border-radius: .9rem; background: #fff; cursor: pointer; }
.flwb-role[data-on] { border-color: #4f46e5; box-shadow: inset 0 0 0 1px #4f46e5; }
.flwb-role i { position: absolute; inset-block-start: .4rem; inset-inline-end: .4rem; display: none;
               color: #4f46e5; font-style: normal; }
.flwb-role[data-on] i { display: block; }
.flwb-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.flwb-chip { padding: .45rem .9rem; border: 1px solid #e4e6ef; border-radius: 999px; background: #fff; cursor: pointer; }
.flwb-chip[data-on] { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.flwb-sum { display: grid; margin: 0; }
.flwb-sum div { display: flex; justify-content: space-between; gap: 1rem; padding-block: .5rem;
                border-block-start: 1px solid #e4e6ef; }
.flwb-nav { display: flex; justify-content: space-between; gap: .75rem; }
.flwb-go { padding: .65rem 1.2rem; border: none; border-radius: 999px; background: #4f46e5; color: #fff; cursor: pointer; }
.flwb-go:disabled { opacity: .45; cursor: not-allowed; }
.flwb-done { justify-items: center; text-align: center; }
.flwb-check { display: grid; place-items: center; inline-size: 3.5rem; aspect-ratio: 1; border-radius: 50%;
              background: #e7f6ec; color: #0f8a43; font-size: 1.5rem; }
</style>
<!-- OnboardingWizard.svelte — the four-step onboarding: welcome → role → chips → confirm -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  const roles = [
    { id: 'designer', name: 'Product designer', note: 'Shapes the interface' },
    { id: 'engineer', name: 'Engineer', note: 'Ships the code' },
    { id: 'manager', name: 'Product manager', note: 'Owns the roadmap' },
    { id: 'marketer', name: 'Marketer', note: 'Tells the story' },
  ];
  const topics = ['Design systems', 'Motion', 'Accessibility', 'Performance', 'Tokens', 'Handoff'];
  let step = $state(0);
  let role = $state<string | null>(null);
  let picks = $state<string[]>([]);
  let done = $state(false);

  const flip = (t: string) => {
    picks = picks.includes(t) ? picks.filter((x) => x !== t) : [...picks, t];
  };
  const pos = (i: number) => (i === step ? 'now' : i < step ? 'before' : 'after');
  const roleName = $derived(roles.find((r) => r.id === role)?.name);
  const canNext = $derived(
    step === 1 ? !!role : step === 2 ? picks.length > 0 : true);
  const next = () => (step < 3 ? step++ : (done = true));
</script>

{#if !done}
  <div class="flwb">
    <header class="flwb-top">
      <div class="flwb-bar">
        {#each [0, 1, 2, 3] as i (i)}
          <i data-on={i <= step || undefined}></i>
        {/each}
      </div>
      <small>Step {step + 1} of 4</small>
    </header>

    <div class="flwb-stage">
      <section class="flwb-step" data-pos={pos(0)}>
        <h3>Welcome to Meridian</h3>
        <p>Two minutes, four steps — and the workspace fits your team.</p>
      </section>
      <section class="flwb-step" data-pos={pos(1)}>
        <h3>What do you do?</h3>
        <div class="flwb-roles" role="radiogroup" aria-label="Your role">
          {#each roles as r (r.id)}
            <button type="button" class="flwb-role" data-on={role === r.id || undefined}
              onclick={() => (role = r.id)}>
              <b>{r.name}</b><small>{r.note}</small><i aria-hidden="true">✓</i>
            </button>
          {/each}
        </div>
      </section>
      <section class="flwb-step" data-pos={pos(2)}>
        <h3>Tune your feed</h3>
        <div class="flwb-chips">
          {#each topics as t (t)}
            <button type="button" class="flwb-chip" data-on={picks.includes(t) || undefined}
              onclick={() => flip(t)}>{t}</button>
          {/each}
        </div>
      </section>
      <section class="flwb-step" data-pos={pos(3)}>
        <h3>All set?</h3>
        <dl class="flwb-sum">
          <div><dt>Role</dt><dd>{roleName}</dd></div>
          <div><dt>Interests</dt><dd>{picks.join(' · ')}</dd></div>
        </dl>
      </section>
    </div>

    <footer class="flwb-nav">
      <button type="button" disabled={step === 0} onclick={() => step--}>Back</button>
      <button type="button" class="flwb-go" disabled={!canNext} onclick={next}>
        {step < 3 ? 'Continue' : 'Create workspace'}
      </button>
    </footer>
  </div>
{:else}
  <div class="flwb flwb-done">
    <span class="flwb-check" aria-hidden="true">✓</span>
    <h3>Your workspace is ready</h3>
    <p>Meridian tuned itself for {roleName}s.</p>
    <button type="button" class="flwb-go"
      onclick={() => { step = 0; role = null; picks = []; done = false; }}>Enter the dashboard</button>
  </div>
{/if}

<style>
  .flwb { display: grid; gap: 1.25rem; max-inline-size: 26rem; padding: 1.5rem; border: 1px solid #e4e6ef;
          border-radius: 1.25rem; background: #fff; color: #191b2a; }
  .flwb-bar { display: flex; gap: .25rem; }
  .flwb-bar i { flex: 1; block-size: 4px; border-radius: 999px; background: #e4e6ef; }
  .flwb-bar i[data-on] { background: #4f46e5; }
  .flwb-stage { display: grid; }
  .flwb-step { grid-area: 1 / 1; transition: translate .34s cubic-bezier(.2, 0, 0, 1), opacity .34s; }
  .flwb-step[data-pos='before'] { translate: -28px 0; opacity: 0; visibility: hidden; }
  .flwb-step[data-pos='after'] { translate: 28px 0; opacity: 0; visibility: hidden; }
  .flwb-roles { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .flwb-role { position: relative; display: grid; gap: .2rem; padding: .8rem; text-align: start;
               border: 1px solid #e4e6ef; border-radius: .9rem; background: #fff; cursor: pointer; }
  .flwb-role[data-on] { border-color: #4f46e5; box-shadow: inset 0 0 0 1px #4f46e5; }
  .flwb-role i { position: absolute; inset-block-start: .4rem; inset-inline-end: .4rem; display: none;
                 color: #4f46e5; font-style: normal; }
  .flwb-role[data-on] i { display: block; }
  .flwb-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
  .flwb-chip { padding: .45rem .9rem; border: 1px solid #e4e6ef; border-radius: 999px; background: #fff; cursor: pointer; }
  .flwb-chip[data-on] { background: #4f46e5; border-color: #4f46e5; color: #fff; }
  .flwb-sum { display: grid; margin: 0; }
  .flwb-sum div { display: flex; justify-content: space-between; gap: 1rem; padding-block: .5rem;
                  border-block-start: 1px solid #e4e6ef; }
  .flwb-nav { display: flex; justify-content: space-between; gap: .75rem; }
  .flwb-go { padding: .65rem 1.2rem; border: none; border-radius: 999px; background: #4f46e5; color: #fff; cursor: pointer; }
  .flwb-go:disabled { opacity: .45; cursor: not-allowed; }
  .flwb-done { justify-items: center; text-align: center; }
  .flwb-check { display: grid; place-items: center; inline-size: 3.5rem; aspect-ratio: 1; border-radius: 50%;
                background: #e7f6ec; color: #0f8a43; font-size: 1.5rem; }
</style>