Badge

Link Badge

A link badge: it detects an external address itself, sets target and rel, and adds to the accessible name that a new tab will open.

  • badge
  • link
  • external
  • a11y

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/badge-016?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 "badge-016" (Link Badge) 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/badge-016.json

Registry item: https://vibeui.ru/r/badge-016.json
Installs to: components/vibeui/badge-016.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 link badge: it detects an external address itself, sets target and rel, and adds to the accessible name that a new tab will open.

A link badge that detects an external address by itself and announces the new tab to screen readers. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Badge016 } from "@/components/vibeui/badge-016"

<Badge016
  href="https://example.com/changelog"
  hint="opens in a new tab"
>
  Changelog
</Badge016>

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-badge-016-* palette — do not swap it for your theme tokens
- the a element instead of a button with a handler: otherwise open-in-new-tab and copy-link break
- rel=noreferrer noopener on external links — target=_blank without it hands over window access
- the hidden note about the new tab: the arrow does not exist for a screen reader
- the visible focus ring: a link badge is operated from the keyboard like any button
- the different marks for internal and external links: they promise different behaviour

## 6. You may change
- the address through href
- the new-tab note through hint
- the link text through children
- the hue and surface in the block variables

## 7. Rules
- Only http and https addresses count as external: protocol-relative links like //example.com are not detected.
- The arrow shift is hover feedback, not decoration: with animation off it honestly disappears.
- In Next.js wrap the component in Link or pass a router href — the component knows nothing about navigation.
- 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/badge-016.json
https://vibeui.ru/r/badge-016.json

Один файл, ноль зависимостей, палитра в локальных переменных --vibeui-badge-016-*. Серверный: хуков нет. Корень — настоящий тег a, поэтому нажатие средней кнопкой, «открыть в новой вкладке» и предпросмотр адреса в строке состояния работают сами. Внешняя ссылка определяется по схеме http(s) в href: у неё меняется знак (стрелка наружу вместо стрелки вправо), добавляются target=_blank и rel=noreferrer noopener, а в доступное имя уходит скрытая подпись hint — иконку скринридер не читает. Стрелка сдвигается при наведении на один пиксель: движение отключено правилом prefers-reduced-motion.

Component source

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

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Badge016Props = Omit<ComponentPropsWithoutRef<"a">, "href"> & {
  href?: string
  hint?: string
}

// Идея компонента: плашка-ссылка. Внешний адрес компонент определяет сам по
// схеме, сам ставит target и rel и сам дописывает в доступное имя, что
// откроется новая вкладка: иконка-стрелка видна зрячим, но скринридеру она
// ничего не говорит. Стрелка отъезжает при наведении — это подтверждение
// нажатия, поэтому движение выключается вместе с prefers-reduced-motion.
const STYLES = `
:where([data-vibeui-block="badge-016"]){
--vibeui-badge-016-bg:oklch(0.97 0.008 265);
--vibeui-badge-016-bg-hover:oklch(0.94 0.018 265);
--vibeui-badge-016-fg:oklch(0.42 0.11 265);
--vibeui-badge-016-border:oklch(0.9 0.02 265);
--vibeui-badge-016-ring:oklch(0.55 0.16 265);
--vibeui-badge-016-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="badge-016"]{
display:inline-flex;align-items:center;gap:0.375rem;
box-sizing:border-box;height:1.75rem;padding:0 0.625rem 0 0.75rem;
border:1px solid var(--vibeui-badge-016-border);border-radius:9999px;
background:var(--vibeui-badge-016-bg);color:var(--vibeui-badge-016-fg);
font-family:var(--vibeui-badge-016-font);font-size:0.75rem;font-weight:600;line-height:1;
text-decoration:none;vertical-align:middle;
transition:background-color .16s ease,border-color .16s ease;
}
[data-vibeui-block="badge-016"]:hover{
background:var(--vibeui-badge-016-bg-hover);
border-color:color-mix(in oklab,var(--vibeui-badge-016-ring) 40%,oklch(1 0 0));
}
[data-vibeui-block="badge-016"]:focus-visible{
outline:2px solid var(--vibeui-badge-016-ring);outline-offset:2px;
}
[data-vibeui-block="badge-016"] [data-part="arrow"]{
width:0.75rem;height:0.75rem;flex:none;
transition:transform .16s ease;
}
[data-vibeui-block="badge-016"]:hover [data-part="arrow"]{transform:translateX(1px)}
[data-vibeui-block="badge-016"][data-external="true"]:hover [data-part="arrow"]{transform:translate(1px,-1px)}
/* Подпись только для скринридера: визуально стрелка уже всё сказала. */
[data-vibeui-block="badge-016"] [data-part="sr"]{
position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;
clip-path:inset(50%);white-space:nowrap;border:0;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="badge-016"] *{animation:none!important;transition:none!important}}
`

/**
 * Плашка-ссылка: внешний адрес распознаётся сам и объявляется скринридеру.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Badge016({
  href = "https://example.com/changelog",
  hint = "откроется в новой вкладке",
  className,
  style,
  children = "Список изменений",
  ...props
}: Badge016Props) {
  const external = /^https?:\/\//i.test(href)

  return (
    <>
      <style href="vibeui-badge-016" precedence="medium">
        {STYLES}
      </style>
      <a
        {...props}
        href={href}
        data-vibeui-block="badge-016"
        data-external={external}
        className={className}
        style={style as CSSProperties}
        target={external ? "_blank" : undefined}
        rel={external ? "noreferrer noopener" : undefined}
      >
        {children}
        {external ? <span data-part="sr"> ({hint})</span> : null}
        <svg
          data-part="arrow"
          viewBox="0 0 16 16"
          fill="none"
          stroke="currentColor"
          strokeWidth="2"
          strokeLinecap="round"
          strokeLinejoin="round"
          aria-hidden="true"
          focusable="false"
        >
          {external ? (
            <path d="M5.5 10.5 10.5 5.5M6 5.5h4.5V10" />
          ) : (
            <path d="M3.5 8h9M9 4.5 12.5 8 9 11.5" />
          )}
        </svg>
      </a>
    </>
  )
}