# GlassBadge

> İçinden yazısı akan küçük bir cam rozet.

```tsx
import { Sparkles } from "lucide-react";

import { GlassBadge } from "@vitrumui/react/badge";

// The badge sits on the tile's corner; the tile shows through the glass, blurred.
// Hover the tile: the text flows faster.
export default function Demo() {
  return (
    <div className="relative w-full max-w-xs rounded-[28px] bg-white p-7 dark:bg-neutral-800">
      <span className="flex size-12 items-center justify-center rounded-2xl bg-neutral-900 text-white dark:bg-white dark:text-neutral-900">
        <Sparkles className="size-5" />
      </span>
      <p className="mt-6 text-xl font-semibold tracking-tight text-neutral-900 dark:text-white">
        Autumn update
      </p>
      <p className="mt-1.5 text-[15px] leading-relaxed text-neutral-500 dark:text-neutral-400">
        Sliders, switches and checkboxes, now in refractive glass.
      </p>
      <GlassBadge className="absolute -top-2.5 -right-2.5" dotColor="#f97316">
        New
      </GlassBadge>
    </div>
  );
}
```

**Şunun için**

- Bir kartta ya da sekmede tek kısa kelime: Yeni, Beta, Canlı.

**Şunun için değil**

- Bir bakışta okunması gereken sayı ya da durum: yazı hareket ediyor.
- Bir ekranda birkaç tane: hareketler yarışır.

```bash
npm install @vitrumui/react # yakında
```

## Kullanım

```tsx
import { GlassBadge } from '@vitrumui/react/badge'

<div className="relative">
  <Card />
  <GlassBadge className="absolute -top-2 -right-2">New</GlassBadge>
</div>
```

## Davranış

Yazı camın altında çizilir; kenar, geçen harfleri büker. Rozetin arkasındaki her şey yumuşakça bulanık görünür. Rozetin konumlu atasının üstüne gelince akış hızlanır. `bg-*` ve `text-*` ile renklendir.

## Örnekler

### Kendi renklerin

```tsx
import { GlassBadge } from "@vitrumui/react/badge";

const apps = [
  {
    name: "Notes",
    tile: "bg-[#ffd60a]",
    badge: "bg-neutral-900 text-white",
    dot: "#ffd60a",
    label: "Beta",
  },
  {
    name: "Radio",
    tile: "bg-[#ff375f]",
    badge: "bg-white text-neutral-900",
    dot: "#ff375f",
    label: "Live",
  },
  {
    name: "Studio",
    tile: "bg-[#0a84ff]",
    badge: "bg-amber-400 text-neutral-900",
    dot: "#ffffff",
    label: "Pro",
  },
];

// `bg-*` is the glass colour, `text-*` the flowing text, `dotColor` the separator.
// Each badge sits on the corner of its own tile, so each tile speeds up its own badge.
export default function Demo() {
  return (
    <div className="flex flex-wrap items-start justify-center gap-10">
      {apps.map((app) => (
        <div key={app.name} className="flex flex-col items-center gap-3">
          <div className={`relative size-28 rounded-[30px] ${app.tile}`}>
            <GlassBadge
              className={`absolute -top-2 -right-3 ${app.badge}`}
              dotColor={app.dot}
            >
              {app.label}
            </GlassBadge>
          </div>
          <p className="text-sm font-medium text-neutral-900 dark:text-white">
            {app.name}
          </p>
        </div>
      ))}
    </div>
  );
}
```

Rozet rengini kendi sınıflarından alır: `bg-*` camın, `text-*` içinden akan yazının, `dotColor` ise tekrarlar arasındaki karenin rengidir. İmleç hangi konumlu atanın üstündeyse yalnız onun rozeti hızlanır.

### Bir palet

```tsx
import { GlassBadge } from "@vitrumui/react/badge";

const swatches = [
  { label: "Open", badge: "bg-emerald-600 text-white", dot: "#a7f3d0" },
  { label: "Sale", badge: "bg-rose-600 text-white", dot: "#fecdd3" },
  { label: "Soon", badge: "bg-amber-400 text-neutral-900", dot: "#78350f" },
  { label: "Beta", badge: "bg-sky-500 text-white", dot: "#e0f2fe" },
  { label: "Pro", badge: "bg-violet-600 text-white", dot: "#ddd6fe" },
  {
    label: "New",
    badge: "bg-neutral-900 text-white dark:bg-white dark:text-neutral-900",
    dot: "#f97316",
  },
];

// One badge, six colours: any `bg-*` with a `text-*` that reads on it, and a `dotColor`
// a shade away. Each cell is `relative`, so hovering a cell speeds up only its badge.
export default function Demo() {
  return (
    <div className="grid w-full max-w-md grid-cols-3 gap-2">
      {swatches.map((swatch) => (
        <div
          key={swatch.label}
          className="relative flex flex-col items-center gap-4 rounded-3xl bg-white px-4 py-7 dark:bg-neutral-800"
        >
          <GlassBadge className={swatch.badge} dotColor={swatch.dot}>
            {swatch.label}
          </GlassBadge>
          <code className="text-xs text-neutral-500 dark:text-neutral-400">
            {swatch.badge.split(" ")[0]}
          </code>
        </div>
      ))}
    </div>
  );
}
```

Her `bg-*` cam rengi olur. Yanına üstünde okunan bir `text-*` (amberde koyu, diğerlerinde beyaz yazı) ve yazıdan bir ton farklı bir `dotColor` koy. Burada yalnız karşılaştırmak için yan yanalar: üründe ekran başına tek rozet kullan.

### Bir ürünün üstünde, indirim için

```tsx
import { GlassBadge } from "@vitrumui/react/badge";

// A rose badge on the corner of a product. Half of it hangs over the yellow cover and
// half over the page, so both show through the glass.
export default function Demo() {
  return (
    <div className="relative w-full max-w-xs">
      <div className="flex aspect-[4/3] items-center justify-center rounded-[28px] bg-[#ffd60a]">
        <span className="flex size-40 items-center justify-center rounded-full bg-neutral-900">
          <span className="flex size-14 items-center justify-center rounded-full bg-[#ff375f]">
            <span className="size-2 rounded-full bg-[#ffd60a]" />
          </span>
        </span>
      </div>
      <div className="mt-4 flex items-baseline justify-between gap-4 px-1">
        <p className="text-[17px] font-semibold tracking-tight text-neutral-900 dark:text-white">
          Night Drive LP
        </p>
        <p className="text-[15px] text-neutral-500 tabular-nums dark:text-neutral-400">
          <s>$26</s>{" "}
          <span className="font-semibold text-neutral-900 dark:text-white">
            $18
          </span>
        </p>
      </div>
      <GlassBadge
        className="absolute -top-2.5 -right-2.5 bg-rose-600"
        dotColor="#ffd60a"
      >
        Sale
      </GlassBadge>
    </div>
  );
}
```

Gül rengi bir rozet kapağın köşesinden taşar. Yarısı sarının, yarısı sayfanın üstündedir; cam ikisini de gösterir.

### Bir dock öğesinin üstünde

```tsx
import { House, Library, Search, ShoppingBag } from "lucide-react";

import { GlassBadge } from "@vitrumui/react/badge";

const items = [
  { label: "Home", icon: House, active: true },
  { label: "Search", icon: Search },
  { label: "Library", icon: Library },
  { label: "Store", icon: ShoppingBag, badge: "New" },
];

// An orange badge on one item of a dock. The button is `relative`: the badge hangs off
// its corner and speeds up when that button is hovered.
export default function Demo() {
  return (
    <nav
      aria-label="Dock"
      className="flex items-center gap-1.5 rounded-full bg-white p-2 dark:bg-neutral-800"
    >
      {items.map((item) => (
        <button
          key={item.label}
          type="button"
          aria-label={item.label}
          className={`relative flex size-14 items-center justify-center rounded-full ${
            item.active
              ? "bg-neutral-900 text-white dark:bg-white dark:text-neutral-900"
              : "text-neutral-500 dark:text-neutral-400"
          }`}
        >
          <item.icon className="size-6" />
          {item.badge && (
            <GlassBadge
              className="absolute -top-3 left-8 bg-orange-500"
              dotColor="#fff7ed"
            >
              {item.badge}
            </GlassBadge>
          )}
        </button>
      ))}
    </nav>
  );
}
```

Rozeti düğmenin içine koy ve düğmeye `relative` ver: turuncu rozet o zaman bütün dock'ta değil, yalnız o öğenin üstüne gelince hızlanır.

### Rengin üstünde daha berrak cam

```tsx
import { GlassBadge } from "@vitrumui/react/badge";

const bands = ["bg-[#0a84ff]", "bg-[#ff375f]", "bg-[#ffd60a]", "bg-[#30d158]"];

// A lower `tint` lets more of the backdrop through: here the bands of the cover show in the
// glass. `speed` sets the pace at rest, and a wider badge (`w-24`) fits a longer word.
export default function Demo() {
  return (
    <div className="relative isolate w-full max-w-sm overflow-hidden rounded-[32px] p-7 pt-36">
      <div aria-hidden className="absolute inset-0 -z-10 flex">
        {bands.map((band) => (
          <span key={band} className={`flex-1 ${band}`} />
        ))}
      </div>
      <p className="text-2xl font-semibold tracking-tight text-white">
        Colour Fields
      </p>
      <p className="mt-1 text-[15px] text-white/80">Tonight, 21:00 · Hall B</p>
      <GlassBadge
        className="absolute top-5 left-5 w-24 bg-black text-white"
        tint={0.35}
        speed={0.25}
        dotColor="#ffd60a"
      >
        Sold out
      </GlassBadge>
    </div>
  );
}
```

`tint`, rozet renginin arkasında kalanı ne kadar örttüğüdür. Varsayılan `0.82` değerinde rozet düz bir renk gibi okunur; renkli bir zeminde düşürürsen zemin camın içinde yumuşakça bulanık görünür. `speed`, dururkenki hızdır (saniyedeki tur sayısı). Rozet varsayılan olarak 64 px genişliğindedir: daha uzun bir kelime için `w-*` sınıfıyla genişlet.

### Satır içinde, bir etiketin yanında

```tsx
import { GlassBadge } from "@vitrumui/react/badge";

const plans = [
  { name: "Starter", price: "$0", note: "One project, community support" },
  {
    name: "Team",
    price: "$24",
    note: "Unlimited projects, shared library",
    badge: "Popular",
  },
  { name: "Scale", price: "$96", note: "Audit log, SSO and priority support" },
];

// Without a position class the badge flows inline, next to a label. One per list:
// it marks the single row worth a second look. Hover that row and the text speeds up.
export default function Demo() {
  return (
    <ul className="flex w-full max-w-md flex-col gap-2">
      {plans.map((plan) => (
        <li
          key={plan.name}
          className="relative flex items-center gap-4 rounded-2xl bg-white px-5 py-4 dark:bg-neutral-800"
        >
          <span className="min-w-0 flex-1">
            <span className="flex items-center gap-2.5">
              <span className="text-[17px] font-semibold tracking-tight text-neutral-900 dark:text-white">
                {plan.name}
              </span>
              {plan.badge && (
                <GlassBadge
                  className="w-[72px] bg-violet-600"
                  dotColor="#c4b5fd"
                >
                  {plan.badge}
                </GlassBadge>
              )}
            </span>
            <span className="mt-0.5 block text-sm text-neutral-500 dark:text-neutral-400">
              {plan.note}
            </span>
          </span>
          <span className="text-xl font-semibold tracking-tight text-neutral-900 tabular-nums dark:text-white">
            {plan.price}
          </span>
        </li>
      ))}
    </ul>
  );
}
```

Konum sınıfı vermezsen rozet, satır içi herhangi bir öğe gibi satırda durur. Yazıyı hızlandıran hover o satıra ait olsun diye satıra `relative` ver.

## API referansı

| Prop | Tür | Varsayılan | Açıklama |
| --- | --- | --- | --- |
| `children` | `string` | — | Yazı: tek kısa kelime. |
| `dotColor` | `string` | `currentColor` | Tekrarlar arasındaki ayracın rengi. |
| `speed` | `number` | `0.4` | Dururken saniyedeki tur sayısı. |
| `tint` | `number` | `0.82` | Rozet renginin arka plan üzerindeki opaklığı. |
| `className` | `string` | — | Konum ve renk (`bg-*`, `text-*`). |

## Erişilebilirlik

- Yazı döngü olarak değil, bir kez okunur.
- Hareketi azalt açıksa yazı ortada durur.

Source: /tr/docs/badge
