Alert Dialog

Muteable Confirm

A confirmation you can switch off: the checkbox is about next time, and where to switch it back on is stated right away.

  • alert-dialog
  • confirm
  • preferences
  • reversible

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/alertdialog-014?lang=en

Move to archive?

Блок исчезнет из каталога, но останется в архиве — вернуть его можно в любой момент.

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 "alertdialog-014" (Muteable Confirm) 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/alertdialog-014.json

Registry item: https://vibeui.ru/r/alertdialog-014.json
Installs to: components/vibeui/alertdialog-014.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 confirmation you can switch off: the checkbox is about next time, and where to switch it back on is stated right away.

A confirmation with a "don't ask again" checkbox and a visible way to bring it back. Zero dependencies, one file.

## 3. How to use it
import { Alertdialog014 } from "@/components/vibeui/alertdialog-014"

<Alertdialog014 rememberLabel="Don't ask again" confirm="Archive" />

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-alertdialog-014-* palette — do not swap it for your theme tokens
- the checkbox only for reversible actions: for deletion it turns protection into a formality
- telling where the confirmation can be restored — otherwise switching it off feels risky
- the visible way to re-enable it after muting
- the checkbox unchecked by default
- the wording that the checkbox is about next time, not this one

## 6. You may change
- rememberLabel and rememberHint
- title, text, confirm and the button labels
- the accent through the accent prop
- persisting the choice in your own state

## 7. Rules
- The choice lives inside the component: persisting it to a profile is the caller's job.
- Never allow muting a confirmation for an irreversible action.
- With the confirmation muted, the action must stay undoable for at least a few seconds.
- 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/alertdialog-014.json
https://vibeui.ru/r/alertdialog-014.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-alertdialog-014-*. Клиентский: "use client" ради состояния галочки и отключения. После отключения рядом с кнопкой появляется строка с возвратом подтверждения, поэтому решение обратимо в один клик.

Component source

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

"use client"

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

export type Alertdialog014Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "title"
> & {
  triggerLabel?: string
  title?: string
  text?: string
  rememberLabel?: string
  rememberHint?: string
  confirm?: string
  cancel?: string
  accent?: string
}

// Идея компонента: подтверждение, которое можно отключить. Галочка «больше не
// спрашивать» уместна только для обратимых действий — для удаления она
// превращает защиту в одноразовую формальность. Отключение показано честно:
// сказано, где вернуть подтверждение обратно, иначе человек боится нажимать.
// Галочка выключена по умолчанию и не влияет на текущее действие: она про
// следующий раз, и подпись это проговаривает.
const STYLES = `
:where([data-vibeui-block="alertdialog-014"]){
--vibeui-alertdialog-014-bg:oklch(1 0 0);
--vibeui-alertdialog-014-panel:oklch(0.97 0.003 265);
--vibeui-alertdialog-014-fg:oklch(0.22 0.014 265);
--vibeui-alertdialog-014-muted:oklch(0.55 0.014 265);
--vibeui-alertdialog-014-border:oklch(0.9 0.006 265);
--vibeui-alertdialog-014-accent:oklch(0.55 0.2 262);
--vibeui-alertdialog-014-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="alertdialog-014"]{
font-family:var(--vibeui-alertdialog-014-font);color:var(--vibeui-alertdialog-014-fg);
}
[data-vibeui-block="alertdialog-014"] *{box-sizing:border-box}
[data-vibeui-block="alertdialog-014"] [data-part="open"]{
appearance:none;cursor:pointer;height:2.25rem;padding:0 0.875rem;
border:1px solid var(--vibeui-alertdialog-014-border);border-radius:0.625rem;
background:var(--vibeui-alertdialog-014-bg);color:inherit;
font:inherit;font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="alertdialog-014"] [data-part="open"]:focus-visible{outline:2px solid var(--vibeui-alertdialog-014-accent);outline-offset:2px}
[data-vibeui-block="alertdialog-014"] [data-part="state"]{
margin:0.5rem 0 0;font-size:0.6875rem;color:var(--vibeui-alertdialog-014-muted);
}
[data-vibeui-block="alertdialog-014"] [data-part="reset"]{
appearance:none;border:0;background:none;cursor:pointer;padding:0;
color:var(--vibeui-alertdialog-014-accent);font:inherit;font-size:0.6875rem;font-weight:650;
text-decoration:underline;
}
/* margin:auto — без него модалка липнет к левому верхнему углу. */
[data-vibeui-block="alertdialog-014"] dialog{
margin:auto;width:min(22rem,calc(100vw - 2rem));padding:1.125rem;
border:1px solid var(--vibeui-alertdialog-014-border);border-radius:0.875rem;
background:var(--vibeui-alertdialog-014-bg);color:var(--vibeui-alertdialog-014-fg);
box-shadow:0 24px 60px -24px oklch(0.2 0.03 265 / 55%);
font-family:var(--vibeui-alertdialog-014-font);
}
[data-vibeui-block="alertdialog-014"] dialog::backdrop{background:oklch(0.2 0.02 265 / 45%)}
[data-vibeui-block="alertdialog-014"] h2{margin:0 0 0.375rem;font-size:1rem;font-weight:700;line-height:1.3}
[data-vibeui-block="alertdialog-014"] [data-part="text"]{margin:0 0 0.875rem;font-size:0.8125rem;line-height:1.55;color:var(--vibeui-alertdialog-014-muted)}
/* Галочка про следующий раз, а не про текущее действие — так и подписана. */
[data-vibeui-block="alertdialog-014"] [data-part="remember"]{
display:flex;align-items:flex-start;gap:0.625rem;cursor:pointer;
padding:0.625rem 0.75rem;margin-bottom:0.875rem;border-radius:0.625rem;
background:var(--vibeui-alertdialog-014-panel);
}
[data-vibeui-block="alertdialog-014"] input{
appearance:none;position:relative;flex:none;cursor:pointer;margin-top:0.0625rem;
width:1.0625rem;height:1.0625rem;border-radius:0.3125rem;
border:1.5px solid var(--vibeui-alertdialog-014-muted);background:var(--vibeui-alertdialog-014-bg);
}
[data-vibeui-block="alertdialog-014"] input:checked{
background:var(--vibeui-alertdialog-014-accent);border-color:var(--vibeui-alertdialog-014-accent);
}
[data-vibeui-block="alertdialog-014"] input:checked::after{
content:"";position:absolute;left:0.3rem;top:0.1rem;
width:0.2rem;height:0.45rem;
border:solid oklch(1 0 0);border-width:0 2px 2px 0;transform:rotate(45deg);
}
[data-vibeui-block="alertdialog-014"] input:focus-visible{outline:2px solid var(--vibeui-alertdialog-014-accent);outline-offset:2px}
[data-vibeui-block="alertdialog-014"] [data-part="rlabel"]{display:flex;flex-direction:column;gap:0.125rem;font-size:0.8125rem;font-weight:600}
[data-vibeui-block="alertdialog-014"] [data-part="rhint"]{font-size:0.75rem;font-weight:400;color:var(--vibeui-alertdialog-014-muted)}
[data-vibeui-block="alertdialog-014"] [data-part="actions"]{display:flex;flex-direction:row-reverse;gap:0.5rem}
[data-vibeui-block="alertdialog-014"] [data-part="actions"] button{
flex:1 1 0;appearance:none;cursor:pointer;height:2.375rem;border-radius:0.625rem;
font:inherit;font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="alertdialog-014"] [data-part="confirm"]{border:0;background:var(--vibeui-alertdialog-014-accent);color:oklch(1 0 0)}
[data-vibeui-block="alertdialog-014"] [data-part="cancel"]{
border:1px solid var(--vibeui-alertdialog-014-border);background:var(--vibeui-alertdialog-014-bg);color:inherit;
}
[data-vibeui-block="alertdialog-014"] dialog button:focus-visible{outline:2px solid var(--vibeui-alertdialog-014-accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="alertdialog-014"] *{animation:none!important;transition:none!important}}
`

/**
 * Подтверждение, которое можно отключить: галочка про следующий раз.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Alertdialog014({
  triggerLabel = "Отправить блок в архив",
  title = "Отправить в архив?",
  text = "Блок исчезнет из каталога, но останется в архиве — вернуть его можно в любой момент.",
  rememberLabel = "Больше не спрашивать",
  rememberHint = "Следующие блоки уйдут в архив сразу. Подтверждение вернётся в настройках проекта.",
  confirm = "В архив",
  cancel = "Отменить",
  accent,
  className,
  style,
  ...props
}: Alertdialog014Props) {
  const box = useRef<HTMLDialogElement>(null)
  const [remember, setRemember] = useState(false)
  const [muted, setMuted] = useState(false)

  const run = () => {
    if (remember) setMuted(true)
    box.current?.close()
  }

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

  return (
    <>
      <style href="vibeui-alertdialog-014" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="alertdialog-014"
        className={className}
        style={palette}
      >
        <button
          type="button"
          data-part="open"
          onClick={() => {
            if (muted) return
            setRemember(false)
            box.current?.showModal()
          }}
        >
          {triggerLabel}
        </button>

        {muted ? (
          <p data-part="state">
            Подтверждение отключено.{" "}
            <button
              type="button"
              data-part="reset"
              onClick={() => setMuted(false)}
            >
              Включить снова
            </button>
          </p>
        ) : null}

        <dialog ref={box} aria-labelledby="vibeui-alertdialog-014-title">
          <h2 id="vibeui-alertdialog-014-title">{title}</h2>
          <p data-part="text">{text}</p>

          <label data-part="remember">
            <input
              type="checkbox"
              checked={remember}
              onChange={(event) => setRemember(event.target.checked)}
            />
            <span data-part="rlabel">
              {rememberLabel}
              <span data-part="rhint">{rememberHint}</span>
            </span>
          </label>

          <div data-part="actions">
            <button type="button" data-part="confirm" onClick={run}>
              {confirm}
            </button>
            <button
              type="button"
              data-part="cancel"
              autoFocus
              onClick={() => box.current?.close()}
            >
              {cancel}
            </button>
          </div>
        </dialog>
      </div>
    </>
  )
}