feat: add ref prop to Alert

This commit is contained in:
ValdiANS
2026-02-06 09:43:27 +07:00
parent 66f017549c
commit f6cf4a29ad
+8 -3
View File
@@ -1,15 +1,16 @@
import { ReactNode } from 'react';
import { ReactNode, Ref } from 'react';
import { cn } from '@/lib/helper';
interface AlertProps {
ref?: Ref<HTMLDivElement> | undefined;
variant?: 'outline' | 'dash' | 'soft';
color?: 'info' | 'success' | 'warning' | 'error';
children?: ReactNode;
className?: string;
}
const Alert = ({ children, variant, color, className }: AlertProps) => {
const Alert = ({ children, ref, variant, color, className }: AlertProps) => {
const alertBaseClassName = cn('alert', {
'alert-soft': variant === 'soft',
'alert-outline': variant === 'outline',
@@ -21,7 +22,11 @@ const Alert = ({ children, variant, color, className }: AlertProps) => {
'alert-error': color === 'error',
});
return <div className={cn(alertBaseClassName, className)}>{children}</div>;
return (
<div ref={ref} className={cn(alertBaseClassName, className)}>
{children}
</div>
);
};
export default Alert;