Svelte
Optimized image component for Svelte.
Install
sh
$ npm add @urami/svelte$ npm add @urami/sveltesh
$ pnpm add @urami/svelte$ pnpm add @urami/sveltesh
$ yarn add @urami/svelte$ yarn add @urami/sveltesh
$ bun add @urami/svelte$ bun add @urami/svelteUsage
svelte
<script>
import Image from '@urami/svelte'
</script>
<Image
src="https://httpmemes.netlify.app/200.jpg"
width={801}
height={801}
alt="Tom Scott"
class="rounded-xl shadow-md"
/><script>
import Image from '@urami/svelte'
</script>
<Image
src="https://httpmemes.netlify.app/200.jpg"
width={801}
height={801}
alt="Tom Scott"
class="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 |