Buttons

Modifier Guard Button

A dangerous action guarded by a held key: the button stays locked until Alt is held down, and the label explains what to do.

  • button
  • danger
  • guard
  • keyboard

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/button-055?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 "button-055" (Modifier Guard Button) 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/button-055.json

Registry item: https://vibeui.ru/r/button-055.json
Installs to: components/vibeui/button-055.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 dangerous action guarded by a held key: the button stays locked until Alt is held down, and the label explains what to do.

A button for an irreversible action with a safety catch. At rest it is grey, unclickable and labelled 'Hold to erase', with a keycap on the right. Hold the modifier and the palette turns to warning, the padlock opens and the label becomes the action itself. Cheaper than a modal and it steals no focus. Zero dependencies, one file.

## 3. How to use it
import { Button055 } from "@/components/vibeui/button-055"

<Button055 modifier="Alt" onConfirm={wipeWorkspace}>
  Erase all data
</Button055>

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
- reading the modifier flag from the event rather than from event.key: the state then survives a keyboard layout switch
- the window blur listener: without it a key released outside the tab leaves the button armed
- aria-disabled and cancelling the click while locked — the button stays in the tab order but must not fire
- the label swap between 'hold' and the action itself: the user must know what will happen
- the warning palette only in the armed state — the grey resting colour is the safety catch
- the visible kbd key: without it the hold rule is written nowhere

## 6. You may change
- the children and lockedLabel labels
- the guard key through the modifier prop (Alt, Shift or Control)
- the onConfirm handler: it fires only in the armed state
- the danger colour through the --vibeui-button-055-danger variable
- outer spacing through className

## 7. Rules
- A key guard is unavailable on a touch screen: keep a separate confirmation path for mobile.
- Do not pick Control as the modifier on macOS: there it is taken by system shortcuts.
- Do not replace aria-disabled with a real disabled: a button out of the tab order cannot explain why it is locked.
- 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/button-055.json
https://vibeui.ru/r/button-055.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-055-*. Клиентский компонент: слушатели keydown и keyup висят на window и читают флаг модификатора (altKey, shiftKey или ctrlKey) прямо из события, поэтому состояние не рассинхронизируется при переключении раскладки. Дополнительно слушается blur окна: отпущенная вне вкладки клавиша иначе оставила бы кнопку взведённой. Взведённость объявляется через aria-disabled, а клик в заблокированном состоянии отменяется.

Component source

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

"use client"

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

export type Button055Props = Omit<
  ComponentPropsWithoutRef<"button">,
  "children"
> & {
  children?: string
  /** Клавиша-предохранитель: без неё кнопка заблокирована. */
  modifier?: "Alt" | "Shift" | "Control"
  /** Подпись в заблокированном состоянии: она объясняет, что делать. */
  lockedLabel?: string
  onConfirm?: () => void
}

// Идея компонента: предохранитель на клавише. Опасное действие остаётся
// недоступным, пока пользователь не удерживает модификатор — это дешевле
// модального подтверждения и не крадёт фокус. Слушатели висят на window,
// а blur окна сбрасывает состояние: иначе отпущенная вне вкладки клавиша
// оставила бы кнопку взведённой.
const STYLES = `
:where([data-vibeui-block="button-055"]){
--vibeui-button-055-locked:oklch(0.93 0.004 265);
--vibeui-button-055-locked-fg:oklch(0.52 0.014 265);
--vibeui-button-055-border:oklch(0.86 0.006 265);
--vibeui-button-055-danger:oklch(0.55 0.2 25);
--vibeui-button-055-fg:oklch(0.99 0.02 25);
--vibeui-button-055-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
--vibeui-button-055-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
}
[data-vibeui-block="button-055"]{
appearance:none;cursor:not-allowed;box-sizing:border-box;
display:inline-flex;align-items:center;gap:0.625rem;
height:2.75rem;padding:0 0.75rem 0 1rem;border-radius:0.625rem;
border:1px solid var(--vibeui-button-055-border);
background:var(--vibeui-button-055-locked);color:var(--vibeui-button-055-locked-fg);
font-family:var(--vibeui-button-055-font);font-size:0.875rem;font-weight:650;line-height:1;
transition:background-color .16s ease,color .16s ease,border-color .16s ease;
}
[data-vibeui-block="button-055"][data-armed="true"]{
cursor:pointer;
background:var(--vibeui-button-055-danger);color:var(--vibeui-button-055-fg);
border-color:color-mix(in oklab,var(--vibeui-button-055-danger) 75%,black);
}
[data-vibeui-block="button-055"]:focus-visible{outline:2px solid var(--vibeui-button-055-danger);outline-offset:3px}
[data-vibeui-block="button-055"] kbd{
font-family:var(--vibeui-button-055-mono);font-size:0.6875rem;font-weight:600;line-height:1;
padding:0.3125rem 0.4375rem;border-radius:0.3125rem;
border:1px solid currentColor;
background:transparent;color:inherit;opacity:.8;
transition:opacity .16s ease,transform .12s ease;
}
[data-vibeui-block="button-055"][data-armed="true"] kbd{opacity:1;transform:translateY(1px)}
[data-vibeui-block="button-055"] [data-part="lock"]{position:relative;flex:none;width:0.875rem;height:1rem}
[data-vibeui-block="button-055"] [data-part="lock"]::before{
content:"";position:absolute;left:0;bottom:0;width:0.875rem;height:0.5625rem;
box-sizing:border-box;border:1.5px solid currentColor;border-radius:0.1875rem;
}
[data-vibeui-block="button-055"] [data-part="lock"]::after{
content:"";position:absolute;left:0.1875rem;top:0;width:0.5rem;height:0.5rem;
box-sizing:border-box;border:1.5px solid currentColor;border-bottom:0;
border-radius:0.25rem 0.25rem 0 0;
transition:transform .18s ease;
}
[data-vibeui-block="button-055"][data-armed="true"] [data-part="lock"]::after{transform:translateX(0.1875rem) rotate(12deg)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="button-055"] *{animation:none!important;transition:none!important}}
`

const FLAG = {
  Alt: "altKey",
  Shift: "shiftKey",
  Control: "ctrlKey",
} as const

/**
 * Опасное действие с предохранителем: доступно, только пока держат клавишу.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Button055({
  children = "Стереть все данные",
  modifier = "Alt",
  lockedLabel = "Удерживайте, чтобы стереть",
  onConfirm,
  type = "button",
  className,
  style,
  ...props
}: Button055Props) {
  const [armed, setArmed] = useState(false)

  useEffect(() => {
    const flag = FLAG[modifier]
    const sync = (event: KeyboardEvent) => setArmed(event[flag])
    const drop = () => setArmed(false)

    window.addEventListener("keydown", sync)
    window.addEventListener("keyup", sync)
    window.addEventListener("blur", drop)

    return () => {
      window.removeEventListener("keydown", sync)
      window.removeEventListener("keyup", sync)
      window.removeEventListener("blur", drop)
    }
  }, [modifier])

  return (
    <>
      <style href="vibeui-button-055" precedence="medium">
        {STYLES}
      </style>
      <button
        {...props}
        type={type}
        data-vibeui-block="button-055"
        data-armed={String(armed)}
        className={className}
        style={style as CSSProperties}
        aria-disabled={!armed}
        onClick={(event) => {
          if (!armed) {
            event.preventDefault()
            return
          }

          onConfirm?.()
        }}
      >
        <span data-part="lock" aria-hidden="true" />
        {armed ? children : lockedLabel}
        <kbd>{modifier}</kbd>
      </button>
    </>
  )
}