Filters

Svelte Action

Apply Instagram-like filter affects to images.

Examples

example Original
example Emerald
example BlueNight
example XPro
example Summer84
example Rustic
example Apollo
example GreenFall
example Noir
example NoirLight

Getting Started

Add within scope of your filtered element. To use globally throughout your application, add this to your application's root layout. Only import the filters you plan to use.

javascript
import { Emerald, BlueNight, /* ... */  } from '@skeletonlabs/skeleton';
html
<Emerald />
<BlueNight />

Applying a Filter

Use of of the two menthods below to apply your desired filter. Be sure to include the required hash mark as shown.

Via the Svelte Action

Use the following Svelte action to to filter any element. Pass the filter name as the only parameter.

javascript
import { filter  } from '@skeletonlabs/skeleton';
html
<img src={myImageSrc} use:filter={'#BlueNight'}>

Via Style Attribute

Alternatively you may apply filters using inline CSS. This is what the action is doing under the hood.

html
<img src={myImageSrc} style="filter: url({'#Emerald'})">

How It Works

This feature is enabled by the use of native browser SVG filters via feColorMatrix transformations.

Create a Custom Filter

Use this tool by by Rik Schennink to easily generate your own custom filters.

Create a Filter

Browser Support

Please be aware that browser support varies for this feature. Some filters are not functional in Safari, while Firefox is not supported at all. For non-supported browsers the filter will not be present but the image will still display, which allows for progressive enhancement.

Chrome: Full

Edge: Full

Safari: Partial

Firefox: None