Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denisstasyev/svelte-image-loader
A neat preloader for images :rocket:
https://github.com/denisstasyev/svelte-image-loader
action image loading svelte svelte3
Last synced: 12 days ago
JSON representation
A neat preloader for images :rocket:
- Host: GitHub
- URL: https://github.com/denisstasyev/svelte-image-loader
- Owner: denisstasyev
- Created: 2020-08-11T20:45:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-13T21:44:24.000Z (over 4 years ago)
- Last Synced: 2025-01-31T04:31:53.263Z (21 days ago)
- Topics: action, image, loading, svelte, svelte3
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# svelte-image-loader
[](https://www.npmjs.com/package/svelte-image-loader) [](https://www.npmjs.com/package/svelte-image-loader) [](https://svelte.dev)
Svelte action to increase the level of UX by neatly preloading images (icons)

## :rocket: Features
This is Svelte's action to handle the `error` and`load` events of images correctly with filling it with color.
- Easy to use (an implementation through the Svelte action)
- Light size (zero-dependencies :fire: :boom:)
- Any custom CSS for loading/error stateP.S. It's recommended to use this package only for icons (small images). If you want to achieve the best UX for middle or large images, use [svelte-skeleton](https://github.com/denisstasyev/svelte-skeleton) ([NPM package](https://www.npmjs.com/package/svelte-skeleton)).
## Install
```bash
npm i svelte-image-loader
```## Usage
```html
import imageLoader from 'svelte-image-loader'
...
const src = `...`
const borderRadius = '50%'
$color-icon-secondary: #BFC1C7;
...
:global(.svelte-image-loader) {
background-color: $color-icon-secondary;
}...
```
Also you can initially call `initImageLoader` function to set custom class name (other than `.svelte-image-loader`).
## API
### Parameters
| Name | Type | Default | Description |
| ------------ | ------ | ------------ | ------------------------------------------ |
| borderRadius | string | empty string | CSS `border-radius` of loading/error state |## License
MIT © [Denis Stasyev](https://github.com/denisstasyev)