Alert

import { cn } from '@utilities/cn'
import { cva, type VariantProps } from 'class-variance-authority'
import * as React from 'react'
const alertVariants = cva(
'relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7',
{
defaultVariants: {
variant: 'default',
},
variants: {
variant: {
default: 'bg-background text-foreground',
destructive:
'border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive',
},
},
},
)
const Alert = ({
className,
ref,
variant,
...props
}: { ref?: React.RefObject<HTMLDivElement | null> } & React.HTMLAttributes<HTMLDivElement> &
VariantProps<typeof alertVariants>) => (
<div className={cn(alertVariants({ variant }), className)} ref={ref} role="alert" {...props} />
)
Alert.displayName = 'Alert'
const AlertTitle = ({
className,
ref,
...props
}: {
ref?: React.RefObject<HTMLParagraphElement | null>
} & React.HTMLAttributes<HTMLHeadingElement>) => (
<h5
className={cn('mb-1 font-medium leading-none tracking-tight', className)}
ref={ref}
{...props}
/>
)
AlertTitle.displayName = 'AlertTitle'
const AlertDescription = ({
className,
ref,
...props
}: {
ref?: React.RefObject<HTMLParagraphElement | null>
} & React.HTMLAttributes<HTMLParagraphElement>) => (
<div className={cn('text-sm [&_p]:leading-relaxed', className)} ref={ref} {...props} />
)
AlertDescription.displayName = 'AlertDescription'
export { Alert, AlertDescription, AlertTitle }
Next

Test