Buttons
Print Button
A print button that disappears from the printout itself: its own @media print rule removes it, and the click calls the system dialog.
- button
- document
- utility
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/button-053?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-053" (Print 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-053.json
Registry item: https://vibeui.ru/r/button-053.json
Installs to: components/vibeui/button-053.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 print button that disappears from the printout itself: its own @media print rule removes it, and the click calls the system dialog.
A print button with a printer mark from which a sheet slides out on hover. The click opens the system print dialog, while its own @media print rule removes the button from the printout so it leaves no black rectangle on paper. A monospace shortcut hint sits beside the label. Zero dependencies, one file.
## 3. How to use it
import { Button053 } from "@/components/vibeui/button-053"
<Button053 hint="Ctrl + P">Print invoice</Button053>
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 component's own @media print with display:none — otherwise the button lands on paper
- calling window.print() after the user's onClick and checking defaultPrevented: printing must be cancellable
- the sheet sliding out on hover: it explains the mark without words
- the shortcut hint in monospace and muted — it must not compete with the label
- the light surface with a border: a print button lives among the document, not on a hero
- aria-hidden on the hint: a shortcut is not the button's content
## 6. You may change
- the label
- the shortcut hint through the hint prop — match it to the user's platform
- the accent colour through the accent prop
- the onClick handler: it runs before the dialog and can cancel it
- outer spacing through className
## 7. Rules
- The button does not prepare the page for print: print styles for the rest of the content are your app's job.
- Keep hint in step with the platform: on macOS it is ⌘P, not Ctrl + P.
- Do not call window.print() from server code — the component is deliberately marked 'use client'.
- 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-053.jsonhttps://vibeui.ru/r/button-053.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-053-*. Клиентский компонент: обработчик вызывает window.print(). Пользовательский onClick вызывается первым, и если он сделал preventDefault, диалог не открывается — так печать можно отменить или подменить. В блоке стилей есть собственное @media print с display:none, поэтому прятать кнопку снаружи не нужно. Принтер нарисован тремя фигурами: корпус, лоток и выезжающий лист.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Button053Props = ComponentPropsWithoutRef<"button"> & {
/** Подсказка сочетания рядом с подписью. */
hint?: string
accent?: string
}
// Идея компонента: кнопка печати, которая исчезает с распечатки. Обычная
// кнопка попадает в бумажный вариант чёрным прямоугольником — здесь есть
// собственное @media print с display:none, поэтому её не надо прятать
// снаружи. Клик зовёт window.print(), никакого своего диалога.
const STYLES = `
:where([data-vibeui-block="button-053"]){
--vibeui-button-053-surface:oklch(1 0 0);
--vibeui-button-053-border:oklch(0.88 0.006 265);
--vibeui-button-053-fg:oklch(0.26 0.02 265);
--vibeui-button-053-muted:oklch(0.58 0.014 265);
--vibeui-button-053-accent:oklch(0.5 0.13 245);
--vibeui-button-053-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
--vibeui-button-053-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
}
[data-vibeui-block="button-053"]{
appearance:none;cursor:pointer;box-sizing:border-box;
display:inline-flex;align-items:center;gap:0.625rem;
height:2.625rem;padding:0 0.75rem 0 0.875rem;border-radius:0.625rem;
border:1px solid var(--vibeui-button-053-border);
background:var(--vibeui-button-053-surface);color:var(--vibeui-button-053-fg);
font-family:var(--vibeui-button-053-font);font-size:0.875rem;font-weight:600;line-height:1;
transition:border-color .16s ease,color .16s ease;
}
[data-vibeui-block="button-053"]:hover:not(:disabled){border-color:var(--vibeui-button-053-accent);color:var(--vibeui-button-053-accent)}
[data-vibeui-block="button-053"]:focus-visible{outline:2px solid var(--vibeui-button-053-accent);outline-offset:2px}
[data-vibeui-block="button-053"]:disabled{cursor:not-allowed;opacity:.5}
/* Принтер: корпус, лоток сверху и лист снизу. */
[data-vibeui-block="button-053"] [data-part="printer"]{position:relative;flex:none;width:1.125rem;height:1.125rem}
[data-vibeui-block="button-053"] [data-part="printer"]::before{
content:"";position:absolute;left:0;top:0.3125rem;width:1.125rem;height:0.5625rem;
box-sizing:border-box;border:1.5px solid currentColor;border-radius:0.1875rem;
}
[data-vibeui-block="button-053"] [data-part="printer"]::after{
content:"";position:absolute;left:0.25rem;top:0;width:0.625rem;height:0.375rem;
box-sizing:border-box;border:1.5px solid currentColor;border-bottom:0;
border-radius:0.125rem 0.125rem 0 0;
}
[data-vibeui-block="button-053"] [data-part="sheet"]{
position:absolute;left:0.25rem;bottom:0;width:0.625rem;height:0.375rem;
box-sizing:border-box;border:1.5px solid currentColor;border-top:0;
background:var(--vibeui-button-053-surface);
transition:transform .18s ease;
}
[data-vibeui-block="button-053"]:hover [data-part="sheet"]{transform:translateY(2px)}
[data-vibeui-block="button-053"] [data-part="hint"]{
font-family:var(--vibeui-button-053-mono);font-size:0.6875rem;font-weight:500;
color:var(--vibeui-button-053-muted);
padding:0.1875rem 0.375rem;border-radius:0.3125rem;
background:color-mix(in oklab,var(--vibeui-button-053-accent) 8%,transparent);
}
/* Кнопка не должна попадать на бумагу. */
@media print{[data-vibeui-block="button-053"]{display:none!important}}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="button-053"] *{animation:none!important;transition:none!important}}
`
/**
* Кнопка печати: зовёт системный диалог и прячется от самой распечатки.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Button053({
hint = "Ctrl + P",
accent,
type = "button",
className,
style,
children = "Распечатать счёт",
onClick,
...props
}: Button053Props) {
const palette = {
...(accent ? { "--vibeui-button-053-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-button-053" precedence="medium">
{STYLES}
</style>
<button
{...props}
type={type}
data-vibeui-block="button-053"
className={className}
style={palette}
onClick={(event) => {
onClick?.(event)
if (!event.defaultPrevented) {
window.print()
}
}}
>
<span data-part="printer" aria-hidden="true">
<span data-part="sheet" />
</span>
{children}
{hint ? (
<span data-part="hint" aria-hidden="true">
{hint}
</span>
) : null}
</button>
</>
)
}