diff --git a/src/components/MdxComponents.tsx b/src/components/MdxComponents.tsx index 3c1c7d88e..4deee6482 100644 --- a/src/components/MdxComponents.tsx +++ b/src/components/MdxComponents.tsx @@ -11,6 +11,7 @@ import { QuickLink, QuickLinks } from './mdx/QuickLinks'; import { Tab, Tabs } from './mdx/Tabs'; import { PreCodeBlock } from './PreCodeBlock'; import ResourceEstimator from './resource-estimator/ResourceEstimator'; +import { Badge } from './ui/badge'; const MdxComponents = (version?: string) => { return { @@ -62,7 +63,8 @@ const MdxComponents = (version?: string) => {
{props.children}
- ) + ), + Badge }; }; diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx new file mode 100644 index 000000000..f2e98550e --- /dev/null +++ b/src/components/ui/badge.tsx @@ -0,0 +1,60 @@ +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; + +import { cn } from "@/lib/utils"; + +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 hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +); + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps { + backgroundColor?: string; + textColor?: string; + textSize?: "text-xs" | "text-sm" | "text-base" | "text-lg" | "text-xl" | "text-2xl"; +} + +function Badge({ + className, + variant, + backgroundColor, + textColor, + textSize = "text-xs", + ...props +}: BadgeProps) { + return ( +
+ ); +} + +export { Badge, badgeVariants };