Badge
Badge and label
Status as neutral text with an optional small flat dot; semantic color appears only on the dot and only for real error or success.
실제로 돌아가는 부품입니다. 눌러 보고 입력해 보세요.
내 앱에 넣기
아직 npm 패키지가 없어서 Taster 리포를 받아 그 안의 명령을 씁니다. 내 앱 폴더가 들어 있는 폴더에서 한 번만 받습니다.
git clone https://github.com/makim-414/taster.git && npm ci --prefix taster/packages/engine내 앱 폴더에서 이 부품을 넣습니다. 부품 파일과 토큰 파일이
src/components/taster에 들어갑니다.node ../taster/packages/engine/cli.mjs add blocks/badge --from https://taster-six.vercel.app --dir src/components/taster부품은 Tailwind 클래스로 그리고, Taster 프리셋이 그 클래스를 토큰에 연결합니다. Tailwind CSS 를 설치하고,
tokens.css를 앱 루트에서 한 번 불러온 뒤, 앱 루트에 이 설정을 둡니다. 프리셋이 없으면 빌드는 되어도 부품이 스타일 없이 나옵니다.// tailwind.config.cjs module.exports = { presets: [require('./src/components/taster/tailwind-preset.cjs')], content: ['./index.html', './src/**/*.{ts,tsx}'], };Tailwind v3 는 이 파일을 그대로 읽습니다. v4 는 Tailwind 를 불러오는
src/의 스타일시트 맨 위에 이 두 줄을 넣습니다.@import "tailwindcss"; @config "../tailwind.config.cjs";tokens.css는:root에--bg,--text,--border,--accent를 정의합니다. 내 앱의 스타일시트가 같은 이름을 뒤에서 다시 정의하면 그쪽 색이 이깁니다. 새 Vite 앱의 스타터 CSS 처럼 그런 변수가 있으면 지우거나 이름을 바꾸세요.
언제 쓰나요
- Status labelStatus as neutral text with an optional small flat dot; semantic color appears only on the dot and only for real error or success.
- Data honesty labelEvery figure carries a plain label: measured, estimated, pending or concept, set apart by ink tone only.
- Status without side barSeverity is told with a text label and a brighter full border, not a thick colored bar on the left edge of the card.
- Media tile cardThe result, product or article image is the tile; the caption is thin and sits below or on a bottom scrim. Hub cards and article cards follow the same shape.
- Plan cardsOne card per real plan with aligned slots for name, price, billing note and features. A monthly or yearly toggle updates every price. Recommended is a text label and a stronger border, not a scaled center card.
- Monochrome logo and proof stripReal customer or integration logos in one neutral color on a single row, plus bordered neutral chips for certifications. Omit the strip when there is nothing real to show.
- Filter chipA scrolling row of chips that filter a list; selected chips invert tone and unselected stay quiet.
대신 없애 주는 AI 티
- Tinted pill badge (AC-04)
- Colored outline pill badge (AC-05)
- Orange 'processing' pill with a glow (AC-07)
- Colored status dot (AC-08)
- Row of three big stats (CMP-06)
- Fake trust signals (CMP-08)
- Empty value traces on screen (CPY-02)
- Thick colored accent bar on one edge of a card (AC-10)
- Drawn mockup instead of the real thing (AC-17)
- Stretched image (CMP-12)
- Three icon cards in a row (LAY-02)
- Flat gray card with a hairline border, everywhere (AC-14)
- Three pricing tiers with the middle one raised (CMP-09)
- Glyph inside a filled circle (AC-11)
정보
코드 보기
import * as React from 'react'
import { cn } from './_cn'
// Badge / Status chip. Thin neutral border, pill shape, text always neutral.
// Meaning color appears only on the small leading dot, and only for real outcomes: `up` and `down` use the
// page's --delta-up and --delta-down (set by a brand theme), which the AC-08 rule accepts. `warn` and `info` are
// states, not outcomes, so their dot stays neutral and the word carries the meaning. No filled tint backgrounds.
export type BadgeVariant = 'neutral' | 'up' | 'down' | 'warn' | 'info'
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
variant?: BadgeVariant
withDot?: boolean
}
const DOT: Record<BadgeVariant, string> = {
neutral: 'bg-text-subtle',
up: 'bg-delta-up',
down: 'bg-delta-down',
warn: 'bg-text-subtle',
info: 'bg-text-subtle',
}
export const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
({ variant = 'neutral', withDot = true, className, children, ...props }, ref) => (
<span
ref={ref}
className={cn(
'inline-flex items-center gap-1.5 h-6 px-2 rounded-full',
'border border-border bg-transparent',
'text-xs font-medium text-text-muted whitespace-nowrap',
className,
)}
{...props}
>
{withDot && (
<span className={cn('shrink-0 size-1.5 rounded-full', DOT[variant])} aria-hidden="true" />
)}
<span className="text-text">{children}</span>
</span>
),
)
Badge.displayName = 'Badge'