Feedback

Step Drawer

A multi-step drawer instead of one long form: one question at a time, a bar showing what is left, and a Back button that steps back rather than closing the panel.

  • drawer
  • wizard
  • steps
  • onboarding

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/drawer-008?lang=en

Шаг 1 из 3

Откуда берём код

Подключим репозиторий, чтобы собирать проект после каждого коммита.

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "drawer-008" (Step Drawer) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/drawer-008.json

Registry item: https://vibeui.ru/r/drawer-008.json
Installs to: components/vibeui/drawer-008.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A multi-step drawer instead of one long form: one question at a time, a bar showing what is left, and a Back button that steps back rather than closing the panel.

A wizard drawer: a segmented progress bar, a "step N of M" counter, one question per screen and separate Back and Close buttons. Zero dependencies, one file, its own palette.

## 3. How to use it
import { Drawer008 } from "@/components/vibeui/drawer-008"

<Drawer008
  triggerLabel="Connect a project"
  title="Project setup"
  steps={steps}
  finishLabel="Done"
/>

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-drawer-008-* palette — do not swap it for your theme tokens
- separate Back and Close: in a wizard these are different operations and must not share a button
- segments instead of a percentage: there are few steps, and a whole number beats a fraction
- role="progressbar" with aria-valuenow — progress has to be readable, not only drawn
- one question per step: two questions on screen turn the wizard back into a form
- resetting to the first step on open: a wizard opening mid-way disorients

## 6. You may change
- title — the drawer heading and its accessible name
- the steps array: step heading, explanation and choices
- triggerLabel and finishLabel — the trigger and final button wording
- the number of steps: the bar adjusts itself
- the fields inside a step — any form can replace the radio buttons

## 7. Rules
- Answers are not collected into an object: lift the form state out if you need it after closing.
- More than five steps is a page with progress, not a drawer.
- The Next button validates nothing: add step validation before advancing.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/drawer-008.json
https://vibeui.ru/r/drawer-008.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-drawer-008-*. Клиентский: "use client", useState держит номер шага, useId — имя группы радиокнопок, useRef — showModal и close. Полоса шагов сделана сегментами и объявлена role="progressbar" с aria-valuenow. Варианты — радиокнопки с подсветкой выбранной карточки через :has(input:checked).

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useId, useRef, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Drawer008Step = {
  title: string
  text: string
  options?: string[]
}

export type Drawer008Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "title"
> & {
  triggerLabel?: string
  title?: string
  steps?: Drawer008Step[]
  finishLabel?: string
  accent?: string
}

// Идея компонента: ящик с несколькими шагами вместо длинной формы. За раз
// виден один вопрос, полоса сверху показывает, сколько осталось, а «Назад»
// не закрывает панель, а возвращает на шаг: у мастера две разные операции
// отмены, и их нельзя вешать на одну кнопку.
const STYLES = `
:where([data-vibeui-block="drawer-008"]){
--vibeui-drawer-008-bg:oklch(1 0 0);
--vibeui-drawer-008-fg:oklch(0.21 0.014 265);
--vibeui-drawer-008-muted:oklch(0.55 0.014 265);
--vibeui-drawer-008-border:oklch(0.91 0.006 265);
--vibeui-drawer-008-accent:oklch(0.55 0.17 265);
--vibeui-drawer-008-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="drawer-008"]{
display:inline-block;font-family:var(--vibeui-drawer-008-font);color:var(--vibeui-drawer-008-fg);
}
[data-vibeui-block="drawer-008"] [data-part="trigger"]{
appearance:none;cursor:pointer;height:2.25rem;padding:0 0.875rem;
border:1px solid var(--vibeui-drawer-008-border);border-radius:0.625rem;
background:var(--vibeui-drawer-008-bg);color:inherit;
font:inherit;font-size:0.8125rem;font-weight:600;
}
[data-vibeui-block="drawer-008"] [data-part="trigger"]:focus-visible{outline:2px solid var(--vibeui-drawer-008-accent);outline-offset:2px}
[data-vibeui-block="drawer-008"] dialog{
position:fixed;inset:0 0 0 auto;margin:0;
width:min(25rem,100vw);max-width:100vw;height:100dvh;max-height:100dvh;
padding:0;border:0;background:var(--vibeui-drawer-008-bg);color:inherit;
box-shadow:-24px 0 60px -30px oklch(0.2 0.02 265 / 55%);
translate:100% 0;transition:translate .22s ease,overlay .22s allow-discrete,display .22s allow-discrete;
}
[data-vibeui-block="drawer-008"] dialog[open]{translate:0 0}
@starting-style{
[data-vibeui-block="drawer-008"] dialog[open]{translate:100% 0}
}
[data-vibeui-block="drawer-008"] dialog::backdrop{background:oklch(0.19 0.02 265 / 45%)}
[data-vibeui-block="drawer-008"] [data-part="panel"]{display:flex;flex-direction:column;height:100%;box-sizing:border-box}
/* Полоса шагов: сегменты, а не проценты — шагов заведомо немного. */
[data-vibeui-block="drawer-008"] [data-part="progress"]{display:flex;gap:0.25rem;padding:0.875rem 1rem 0}
[data-vibeui-block="drawer-008"] [data-part="segment"]{
flex:1;height:0.25rem;border-radius:9999px;background:var(--vibeui-drawer-008-border);
transition:background-color .2s ease;
}
[data-vibeui-block="drawer-008"] [data-part="segment"][data-done="true"]{background:var(--vibeui-drawer-008-accent)}
[data-vibeui-block="drawer-008"] [data-part="head"]{padding:0.75rem 1rem 0.5rem}
[data-vibeui-block="drawer-008"] [data-part="counter"]{
display:block;margin-bottom:0.25rem;
font-size:0.6875rem;font-weight:700;letter-spacing:0.06em;text-transform:uppercase;
color:var(--vibeui-drawer-008-muted);
}
[data-vibeui-block="drawer-008"] [data-part="title"]{margin:0;font-size:1.0625rem;font-weight:680;line-height:1.25}
[data-vibeui-block="drawer-008"] [data-part="body"]{flex:1;min-height:0;overflow-y:auto;padding:0.5rem 1rem 1rem}
[data-vibeui-block="drawer-008"] [data-part="text"]{margin:0 0 0.875rem;font-size:0.875rem;line-height:1.5;color:var(--vibeui-drawer-008-muted)}
[data-vibeui-block="drawer-008"] [data-part="options"]{display:flex;flex-direction:column;gap:0.5rem}
[data-vibeui-block="drawer-008"] [data-part="option"]{
display:flex;align-items:center;gap:0.625rem;cursor:pointer;
padding:0.625rem 0.75rem;border:1px solid var(--vibeui-drawer-008-border);border-radius:0.75rem;
font-size:0.875rem;
}
[data-vibeui-block="drawer-008"] [data-part="option"]:has(input:checked){
border-color:var(--vibeui-drawer-008-accent);
background:color-mix(in oklab,var(--vibeui-drawer-008-accent) 8%,transparent);
}
[data-vibeui-block="drawer-008"] [data-part="option"] input{
appearance:none;flex:none;width:1.0625rem;height:1.0625rem;margin:0;
border:1.5px solid var(--vibeui-drawer-008-border);border-radius:9999px;cursor:pointer;position:relative;
}
[data-vibeui-block="drawer-008"] [data-part="option"] input:checked{border-color:var(--vibeui-drawer-008-accent)}
[data-vibeui-block="drawer-008"] [data-part="option"] input:checked::after{
content:"";position:absolute;inset:0.1875rem;border-radius:9999px;background:var(--vibeui-drawer-008-accent);
}
[data-vibeui-block="drawer-008"] [data-part="option"] input:focus-visible{outline:2px solid var(--vibeui-drawer-008-accent);outline-offset:2px}
[data-vibeui-block="drawer-008"] [data-part="foot"]{
display:flex;gap:0.5rem;
padding:0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom,0px));
border-top:1px solid var(--vibeui-drawer-008-border);
}
[data-vibeui-block="drawer-008"] [data-part="foot"] button{
appearance:none;cursor:pointer;height:2.5rem;border-radius:0.625rem;
border:1px solid var(--vibeui-drawer-008-border);background:transparent;color:inherit;
font:inherit;font-size:0.875rem;font-weight:600;padding:0 1rem;
}
[data-vibeui-block="drawer-008"] [data-part="foot"] button[data-primary="true"]{
flex:1;border-color:transparent;background:var(--vibeui-drawer-008-accent);color:oklch(0.99 0.01 265);
}
[data-vibeui-block="drawer-008"] [data-part="foot"] button:focus-visible{outline:2px solid var(--vibeui-drawer-008-accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="drawer-008"] *{animation:none!important;transition:none!important}
[data-vibeui-block="drawer-008"] dialog{translate:0 0}
}
`

const DEFAULT_STEPS: Drawer008Step[] = [
  {
    title: "Откуда берём код",
    text: "Подключим репозиторий, чтобы собирать проект после каждого коммита.",
    options: ["GitHub", "GitLab", "Загрузить архив"],
  },
  {
    title: "Как собирать",
    text: "Команда сборки определится сама, но её можно поменять позже в настройках.",
    options: ["Определить автоматически", "Задать вручную"],
  },
  {
    title: "Куда публиковать",
    text: "Адрес можно сменить в любой момент — старый продолжит работать месяц.",
    options: ["Домен проекта", "Свой домен"],
  },
]

/**
 * Ящик с шагами: один вопрос за раз, полоса прогресса и раздельные «Назад»
 * и «Закрыть». Один файл, ноль зависимостей, собственная палитра.
 */
export function Drawer008({
  triggerLabel = "Подключить проект",
  title = "Подключение проекта",
  steps = DEFAULT_STEPS,
  finishLabel = "Готово",
  accent,
  className,
  style,
  ...props
}: Drawer008Props) {
  const drawer = useRef<HTMLDialogElement>(null)
  const group = useId()
  const [step, setStep] = useState(0)

  const palette = {
    ...(accent ? { "--vibeui-drawer-008-accent": accent } : null),
    ...style,
  } as CSSProperties

  const current = steps[Math.min(step, steps.length - 1)]
  const last = step >= steps.length - 1

  function open() {
    setStep(0)
    drawer.current?.showModal()
  }

  return (
    <>
      <style href="vibeui-drawer-008" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="drawer-008"
        className={className}
        style={palette}
      >
        <button type="button" data-part="trigger" onClick={open}>
          {triggerLabel}
        </button>
        <dialog ref={drawer} aria-label={title}>
          <div data-part="panel">
            <div
              data-part="progress"
              role="progressbar"
              aria-valuemin={1}
              aria-valuemax={steps.length}
              aria-valuenow={step + 1}
              aria-label={`Шаг ${step + 1} из ${steps.length}`}
            >
              {steps.map((item, index) => (
                <span
                  key={item.title}
                  data-part="segment"
                  data-done={index <= step}
                />
              ))}
            </div>
            <div data-part="head">
              <span data-part="counter">
                Шаг {step + 1} из {steps.length}
              </span>
              <h2 data-part="title">{current.title}</h2>
            </div>
            <div data-part="body">
              <p data-part="text">{current.text}</p>
              {current.options ? (
                <div data-part="options">
                  {current.options.map((option, index) => (
                    <label key={option} data-part="option">
                      <input
                        type="radio"
                        name={`${group}-${step}`}
                        defaultChecked={index === 0}
                      />
                      <span>{option}</span>
                    </label>
                  ))}
                </div>
              ) : null}
            </div>
            <div data-part="foot">
              {step > 0 ? (
                <button type="button" onClick={() => setStep(step - 1)}>
                  Назад
                </button>
              ) : (
                <button type="button" onClick={() => drawer.current?.close()}>
                  Закрыть
                </button>
              )}
              <button
                type="button"
                data-primary="true"
                onClick={() =>
                  last ? drawer.current?.close() : setStep(step + 1)
                }
              >
                {last ? finishLabel : "Далее"}
              </button>
            </div>
          </div>
        </dialog>
      </div>
    </>
  )
}