ivt
Version:
Ivt Components Library
58 lines (55 loc) • 2.76 kB
JavaScript
import { Slot } from '@radix-ui/react-slot';
import { cva } from 'class-variance-authority';
import React__default from 'react';
import { c as cn } from './utils-BDcRwQMd.mjs';
const badgeVariants = cva("inline-flex items-center justify-center rounded-md border px-1.5 py-0.5 text-xs cursor-default font-medium w-fit whitespace-nowrap shrink-0 gap-1 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", {
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",
positive: "border-transparent bg-positive text-positive-foreground shadow hover:bg-positive/80",
warning: "border-transparent bg-warning text-warning-foreground shadow hover:bg-warning/80",
info: "border-transparent bg-info text-info-foreground shadow hover:bg-info/80",
outline: "text-foreground"
},
subtle: {
true: "",
false: ""
}
},
defaultVariants: {
variant: "default"
}
});
function Badge({ className, variant, subtle = false, asChild = false, ...props }) {
const Comp = asChild ? Slot : "span";
const subtleStyles = (variant)=>{
if (variant === "default") {
return "border-transparent bg-accent text-primary hover:bg-accent/80";
}
if (variant === "destructive") {
return "border-transparent bg-destructive-foreground text-destructive hover:bg-destructive-foreground/80";
}
if (variant === "positive") {
return "border-transparent bg-positive-foreground text-positive hover:bg-positive-foreground/80";
}
if (variant === "warning") {
return "border-transparent bg-warning-foreground text-warning hover:bg-warning-foreground/80";
}
if (variant === "info") {
return "border-transparent bg-info-foreground text-info hover:bg-info-foreground/80";
}
return "";
};
const finalSubtleStyles = subtleStyles(variant);
return /*#__PURE__*/ React__default.createElement(Comp, {
"data-slot": "badge",
className: cn(badgeVariants({
variant
}), subtle && finalSubtleStyles, className),
...props
});
}
export { Badge as B, badgeVariants as b };
//# sourceMappingURL=badge-ZU62MOiS.mjs.map