Feedback
Quick Add
A quick action without leaving the page: the popover holds a real two-field form, and submitting closes the panel through the native popovertargetaction.
- popover
- form
- quick add
- anchor
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/popover-002?lang=en
Быстрая задача
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 "popover-002" (Quick Add) 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/popover-002.json
Registry item: https://vibeui.ru/r/popover-002.json
Installs to: components/vibeui/popover-002.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 quick action without leaving the page: the popover holds a real two-field form, and submitting closes the panel through the native popovertargetaction.
A popover with a quick-action form: a field, a list and a submit. Zero dependencies, one file, the browser owns the state.
## 3. How to use it
import { Popover002 } from "@/components/vibeui/popover-002"
<Popover002
label="New task"
fieldLabel="What to do"
submitLabel="Add"
lists={["Inbox", "This week"]}
/>
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-popover-002-* palette — do not swap it for your theme tokens
- the panel layout only inside the :popover-open rule — display in the plain rule overrides the browser's display:none and the panel stays open forever
- closing through popovertargetaction: a custom close would have to be kept in sync with Escape and outside clicks
- the positioning fallback under @supports not (anchor-name) — without it the panel drifts in older browsers
- the field labels with htmlFor: a popover with a form must stay fillable from the keyboard
- the panel's own light surface: without it the dark text disappears on a dark background
## 6. You may change
- the button caption through label and the field caption through fieldLabel
- the placeholder through placeholder and the submit caption through submitLabel
- the dropdown contents through lists
- the accent through the --vibeui-popover-002-accent variable
## 7. Rules
- The form submits nothing: the caller attaches the submit handler.
- Two fields is deliberate — a third turns the panel into a dialog that needs its own heading.
- An outside click closes the panel and discards unfinished input: warn the user or keep a draft.
- 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/popover-002.jsonhttps://vibeui.ru/r/popover-002.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-popover-002-*. Серверный: слой, Escape и клик вне достаются от HTML popover, идентификаторы разводит useId. Раскладка панели объявлена только в :popover-open, иначе display перебил бы встроенный display:none. Позиционирование сделано CSS anchor positioning с откатом на absolute под @supports not. Кнопка отправки закрывает панель через popovertargetaction="hide", поэтому обработчик закрытия не нужен.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import { useId } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Popover002Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "title"
> & {
label?: string
title?: string
fieldLabel?: string
placeholder?: string
submitLabel?: string
/** Варианты списка, куда попадёт запись. */
lists?: string[]
}
// Идея компонента: быстрое действие без ухода со страницы. В поповере живёт
// настоящая форма из двух полей — поле и список, — а кнопка отправки закрывает
// панель штатным popovertargetaction, поэтому обработчик закрытия не нужен.
const STYLES = `
:where([data-vibeui-block="popover-002"]){
--vibeui-popover-002-bg:oklch(1 0 0);
--vibeui-popover-002-fg:oklch(0.23 0.014 265);
--vibeui-popover-002-muted:oklch(0.54 0.014 265);
--vibeui-popover-002-border:oklch(0.89 0.006 265);
--vibeui-popover-002-field:oklch(0.985 0.002 265);
--vibeui-popover-002-accent:oklch(0.56 0.16 155);
--vibeui-popover-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="popover-002"]{
position:relative;display:inline-block;
font-family:var(--vibeui-popover-002-font);color:var(--vibeui-popover-002-fg);
}
[data-vibeui-block="popover-002"] [data-part="trigger"]{
appearance:none;cursor:pointer;
display:inline-flex;align-items:center;gap:0.4375rem;
height:2.25rem;padding:0 0.9375rem;border:0;border-radius:0.625rem;
background:var(--vibeui-popover-002-accent);color:oklch(0.99 0.01 155);
font:inherit;font-size:0.8125rem;font-weight:650;
anchor-name:--vibeui-popover-002-anchor;
}
[data-vibeui-block="popover-002"] [data-part="trigger"]:focus-visible{outline:2px solid var(--vibeui-popover-002-accent);outline-offset:2px}
/* Панель под popover: раскладка задаётся ТОЛЬКО в :popover-open, иначе
display в обычном правиле перебьёт браузерный display:none. */
[data-vibeui-block="popover-002"] [data-part="panel"]{
position:fixed;margin:0;padding:0.875rem;
width:min(19rem,100vw - 2rem);box-sizing:border-box;
border:1px solid var(--vibeui-popover-002-border);border-radius:1rem;
background:var(--vibeui-popover-002-bg);color:inherit;
box-shadow:0 24px 50px -28px oklch(0.2 0.02 265 / 60%);
position-anchor:--vibeui-popover-002-anchor;
top:anchor(bottom);left:anchor(left);margin-top:0.5rem;
transition:opacity .16s ease,translate .16s ease;
}
[data-vibeui-block="popover-002"] [data-part="panel"]:popover-open{
display:flex;flex-direction:column;gap:0.625rem;opacity:1;translate:0 0;
}
@starting-style{
[data-vibeui-block="popover-002"] [data-part="panel"]:popover-open{opacity:0;translate:0 -0.375rem}
}
@supports not (anchor-name: --a){
[data-vibeui-block="popover-002"] [data-part="panel"]{position:absolute;inset:auto;top:calc(100% + 0.5rem);left:0}
}
[data-vibeui-block="popover-002"] [data-part="title"]{margin:0;font-size:0.875rem;font-weight:650}
[data-vibeui-block="popover-002"] [data-part="row"]{display:flex;flex-direction:column;gap:0.25rem}
[data-vibeui-block="popover-002"] [data-part="row"] label{font-size:0.75rem;font-weight:600;color:var(--vibeui-popover-002-muted)}
[data-vibeui-block="popover-002"] input,
[data-vibeui-block="popover-002"] select{
width:100%;box-sizing:border-box;height:2.125rem;padding:0 0.5625rem;
border:1px solid var(--vibeui-popover-002-border);border-radius:0.5rem;
background:var(--vibeui-popover-002-field);color:inherit;
font:inherit;font-size:0.8125rem;
}
[data-vibeui-block="popover-002"] input:focus-visible,
[data-vibeui-block="popover-002"] select:focus-visible{outline:2px solid var(--vibeui-popover-002-accent);outline-offset:1px}
[data-vibeui-block="popover-002"] [data-part="submit"]{
appearance:none;cursor:pointer;border:0;
height:2.125rem;border-radius:0.5rem;
background:var(--vibeui-popover-002-accent);color:oklch(0.99 0.01 155);
font:inherit;font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="popover-002"] [data-part="submit"]:focus-visible{outline:2px solid var(--vibeui-popover-002-accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="popover-002"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_LISTS = ["Входящие", "На неделю", "Когда-нибудь"]
/**
* Поповер с формой быстрого действия: поле, список и отправка.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Popover002({
label = "Новая задача",
title = "Быстрая задача",
fieldLabel = "Что сделать",
placeholder = "Собрать отчёт за август",
submitLabel = "Добавить",
lists = DEFAULT_LISTS,
className,
style,
...props
}: Popover002Props) {
const id = useId().replace(/:/g, "")
return (
<>
<style href="vibeui-popover-002" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="popover-002"
className={className}
style={style as CSSProperties}
>
<button type="button" data-part="trigger" popoverTarget={`${id}-panel`}>
<span aria-hidden="true">+</span>
{label}
</button>
<div
data-part="panel"
id={`${id}-panel`}
popover="auto"
aria-label={title}
>
<p data-part="title">{title}</p>
<div data-part="row">
<label htmlFor={`${id}-what`}>{fieldLabel}</label>
<input id={`${id}-what`} type="text" placeholder={placeholder} />
</div>
<div data-part="row">
<label htmlFor={`${id}-list`}>Список</label>
<select id={`${id}-list`} defaultValue={lists[0]}>
{lists.map((list) => (
<option key={list} value={list}>
{list}
</option>
))}
</select>
</div>
<button
type="button"
data-part="submit"
popoverTarget={`${id}-panel`}
popoverTargetAction="hide"
>
{submitLabel}
</button>
</div>
</div>
</>
)
}