Buttons

Favorite Toggle

A round favourite toggle: the heart is built from two circles and a rotated square, and switching it on sends a ring flashing outward.

  • button
  • favorite
  • toggle
  • icon

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-050?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-050" (Favorite Toggle) 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-050.json

Registry item: https://vibeui.ru/r/button-050.json
Installs to: components/vibeui/button-050.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 round favourite toggle: the heart is built from two circles and a rotated square, and switching it on sends a ring flashing outward.

A label-less icon button. At rest the heart is an outline; switched on it fills, grows slightly, and a ring flashes outward — a short press confirmation that costs no layout. The state is announced through aria-pressed and the button's name changes with it. Zero dependencies, one file.

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

<Button050 defaultPressed={false} onChange={setFavorite} label="Add to favourites" />

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
- aria-pressed as the carrier of state: the button has no label, and colour alone does not convey it
- the aria-label changing with the state — 'add to favourites' and 'remove from favourites' are different actions
- the pseudo-element heart: it inherits currentColor and pulls in no icon library
- filling the heart in the on state rather than only recolouring its outline
- the ring flash as press confirmation, and the prefers-reduced-motion rule that kills it
- the round shape and constant size: this button usually sits in the corner of a product card

## 6. You may change
- the state names through the label and activeLabel props
- the initial state through the defaultPressed prop
- the onChange handler: it receives the new state
- the on-state colour through the accent prop
- the size through the --vibeui-button-050-size variable in the style block

## 7. Rules
- Do not add a counter to this button: a 'like with a number' needs a different component with room for the digits.
- Do not pass onClick: the component owns the toggle, and changes arrive through onChange.
- Do not leave label and activeLabel identical — the state then is not announced at all.
- 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-050.json
https://vibeui.ru/r/button-050.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-050-*. Клиентский компонент: состояние внутреннее, наружу уходит через onChange. Состояние объявлено через aria-pressed, а имя кнопки меняется вместе с ним — подписи нет, поэтому aria-label единственный носитель смысла. Сердце нарисовано двумя псевдоэлементами с общим transform-origin, заливка приходит через background-color. Кольцо-вспышка — отдельная анимация, привязанная к aria-pressed.

Component source

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

"use client"

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

export type Button050Props = Omit<
  ComponentPropsWithoutRef<"button">,
  "children" | "onChange"
> & {
  label?: string
  /** Подпись во включённом состоянии: она уходит в aria-label. */
  activeLabel?: string
  defaultPressed?: boolean
  onChange?: (pressed: boolean) => void
  accent?: string
}

// Идея компонента: переключатель избранного без счётчика и без подписи.
// Сердце собрано из двух кругов и повёрнутого квадрата, поэтому не нужен
// ни SVG, ни иконочный шрифт. При включении из-под сердца расходится кольцо
// — короткая вспышка, которая подтверждает нажатие без смены раскладки.
const STYLES = `
:where([data-vibeui-block="button-050"]){
--vibeui-button-050-surface:oklch(1 0 0);
--vibeui-button-050-border:oklch(0.9 0.006 265);
--vibeui-button-050-idle:oklch(0.6 0.014 265);
--vibeui-button-050-accent:oklch(0.6 0.22 20);
--vibeui-button-050-size:2.75rem;
--vibeui-button-050-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="button-050"]{
position:relative;appearance:none;cursor:pointer;box-sizing:border-box;
display:inline-flex;align-items:center;justify-content:center;
width:var(--vibeui-button-050-size);height:var(--vibeui-button-050-size);
border:1px solid var(--vibeui-button-050-border);border-radius:50%;
background:var(--vibeui-button-050-surface);color:var(--vibeui-button-050-idle);
font-family:var(--vibeui-button-050-font);
transition:border-color .16s ease,color .16s ease;
}
[data-vibeui-block="button-050"]:hover{border-color:var(--vibeui-button-050-accent);color:var(--vibeui-button-050-accent)}
[data-vibeui-block="button-050"][aria-pressed="true"]{color:var(--vibeui-button-050-accent);border-color:var(--vibeui-button-050-accent)}
[data-vibeui-block="button-050"]:focus-visible{outline:2px solid var(--vibeui-button-050-accent);outline-offset:3px}
/* Сердце: два круга сверху и повёрнутый квадрат снизу. */
[data-vibeui-block="button-050"] [data-part="heart"]{
position:relative;width:1.125rem;height:1rem;
transition:transform .2s cubic-bezier(0.34,1.56,0.64,1);
}
[data-vibeui-block="button-050"] [data-part="heart"]::before,
[data-vibeui-block="button-050"] [data-part="heart"]::after{
content:"";position:absolute;top:0;width:0.5625rem;height:0.875rem;
box-sizing:border-box;border-radius:0.5rem 0.5rem 0 0;
border:1.75px solid currentColor;background:transparent;
transition:background-color .18s ease;
}
[data-vibeui-block="button-050"] [data-part="heart"]::before{left:0;transform:rotate(-45deg);transform-origin:100% 100%}
[data-vibeui-block="button-050"] [data-part="heart"]::after{right:0;transform:rotate(45deg);transform-origin:0 100%}
[data-vibeui-block="button-050"][aria-pressed="true"] [data-part="heart"]::before,
[data-vibeui-block="button-050"][aria-pressed="true"] [data-part="heart"]::after{background:currentColor}
[data-vibeui-block="button-050"][aria-pressed="true"] [data-part="heart"]{transform:scale(1.08)}
/* Кольцо-вспышка: рисуется только во включённом состоянии. */
[data-vibeui-block="button-050"] [data-part="burst"]{
position:absolute;inset:0;border-radius:50%;pointer-events:none;
border:2px solid var(--vibeui-button-050-accent);opacity:0;
}
[data-vibeui-block="button-050"][aria-pressed="true"] [data-part="burst"]{
animation:vibeui-button-050-burst .45s ease-out 1;
}
@keyframes vibeui-button-050-burst{
from{opacity:.65;transform:scale(1)}
to{opacity:0;transform:scale(1.6)}
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="button-050"] *{animation:none!important;transition:none!important}}
`

/**
 * Кнопка избранного с переключением: сердце на CSS и кольцо-вспышка.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Button050({
  label = "В избранное",
  activeLabel = "Убрать из избранного",
  defaultPressed = false,
  onChange,
  accent,
  type = "button",
  className,
  style,
  ...props
}: Button050Props) {
  const [pressed, setPressed] = useState(defaultPressed)

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

  return (
    <>
      <style href="vibeui-button-050" precedence="medium">
        {STYLES}
      </style>
      <button
        {...props}
        type={type}
        data-vibeui-block="button-050"
        className={className}
        style={palette}
        aria-pressed={pressed}
        aria-label={pressed ? activeLabel : label}
        onClick={() => {
          const next = !pressed

          setPressed(next)
          onChange?.(next)
        }}
      >
        <span data-part="burst" aria-hidden="true" />
        <span data-part="heart" aria-hidden="true" />
      </button>
    </>
  )
}