Badge
Overview
Badge is a design-system component intended for reusable, product-agnostic UI composition.
Import
import { Badge, badgeVariants } from "@tesseract-nexus/tesserix-ui"Exports
export { Badge, badgeVariants } from './badge'
export type { BadgeProps } from './badge'Props
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
)
}Variations
const badgeVariants = cva(
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
outline: "text-foreground border-border",
success:
"border-transparent bg-green-700 text-white shadow hover:bg-green-800",
warning:
"border-transparent bg-yellow-700 text-white shadow hover:bg-yellow-800",
},
},
defaultVariants: {Usage Patterns
Basic
import { Badge, badgeVariants } from "@tesseract-nexus/tesserix-ui"
export function Example() {
return <Badge />
}Do / Don’t
Do
// Compose with domain wrappers in product code
<Badge className="w-full" />Don’t
// Avoid one-off hardcoded values that bypass tokens
<Badge className="bg-[#123456] text-[#fafafa] px-[13px]" />Token / Theming Mapping
- Color tokens: —primary, —secondary, —muted, —destructive, —foreground, —background
- Shape tokens: —radius
- Border/input tokens: —border, —input, —ring
- Spacing and typography: Tailwind scale via design-system preset
Interaction Test Checklist
- Interaction: click/keyboard activation for primary paths.
- Focus: visible focus styles and logical tab order.
- Variants: core variants and sizes render correctly.
- Disabled/error states: behavior and ARIA attributes are correct.
- Regression: Storybook visual check for primary states.
Accessibility
- Verify keyboard behavior for all interactive states.
- Ensure labels and semantic roles are present in consuming screens.
- Validate focus treatment and screen-reader output during QA.