React
Optimized image component for React.
Install
sh
$ npm add @urami/react$ npm add @urami/reactsh
$ pnpm add @urami/react$ pnpm add @urami/reactsh
$ yarn add @urami/react$ yarn add @urami/reactsh
$ bun add @urami/react$ bun add @urami/reactUsage
tsx
import Image from "@urami/react";
const Component = () => {
return (
<Image
src="https://httpmemes.netlify.app/200.jpg"
width={801}
height={801}
alt="Tom Scott"
className="rounded-xl shadow-md"
/>
);
};import Image from "@urami/react";
const Component = () => {
return (
<Image
src="https://httpmemes.netlify.app/200.jpg"
width={801}
height={801}
alt="Tom Scott"
className="rounded-xl shadow-md"
/>
);
};Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
src | string | - | ✅ | Source of the image |
width | number | - | ✅ | Width of the image |
height | number | - | ❌ | Height of the image (Specify this will results in less layout shift) |
quality | number | 75 | ❌ | Quality of the image |
loader | fn | defaultLoader | ❌ | Loader function, please refer to Loader |
formats | string[] | ['webp', 'jpg'] | ❌ | Formats to generate for the <picture> element |