Feat: Badge component

This commit is contained in:
Daniel Hougaard
2024-04-09 00:21:13 -07:00
parent f038b28c1c
commit 6aab28c4c7
2 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { cva, VariantProps } from "cva";
import { twMerge } from "tailwind-merge";
interface IProps {
children: React.ReactNode;
className?: string;
}
const badgeVariants = cva(
[
"inline-block cursor-default rounded-md bg-yellow/20 px-1.5 pb-[0.03rem] pt-[0.04rem] text-xs text-yellow opacity-80 hover:opacity-100"
],
{
variants: {
variant: {
primary: "bg-yellow/20 text-yellow",
danger: "bg-red/20 text-red",
success: "bg-green/20 text-green"
}
}
}
);
export type BadgeProps = VariantProps<typeof badgeVariants> & IProps;
export const Badge = ({ children, className, variant }: BadgeProps) => {
return (
<div className={twMerge(badgeVariants({ variant: variant || "primary" }), className)}>
{children}
</div>
);
};

View File

@@ -0,0 +1 @@
export { Badge } from "./Badge";