Files
vf_react/src/components/Image/index.tsx
2025-11-26 10:11:02 +08:00

22 lines
501 B
TypeScript

import React, { useState } from 'react';
interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
className?: string;
}
const Image: React.FC<ImageProps> = ({ className, ...props }) => {
const [loaded, setLoaded] = useState(false);
return (
<img
className={`inline-block align-top opacity-0 transition-opacity ${
loaded && 'opacity-100'
} ${className || ''}`}
onLoad={() => setLoaded(true)}
{...props}
/>
);
};
export default Image;