Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
blurhash-gradients
Advanced tools
Readme
Draw blurhashes using CSS gradients.
Blurhash's main drawback is that it absolutely requires some client side JS. It cannot be server rendered.
Install the package using npm or yarn.
npm install blurhash-gradients
Then simply call the blurhashAsGradients
function with the blurhash and use the resulting CSS object on a placeholder element behind your image.
import { blurhashAsGradients } from 'blurhash-gradients';
const css = blurhashAsGradients('LEHV6nWB2yk8pyo0adR*.7kCMdnj');
/*
{
backgroundImage: string;
backgroundSize: string;
backgroundPosition: string;
backgroundRepeat: string;
boxShadow: string;
filter: string;
clipPath: string;
}
*/
<div style="position: relative">
<div style="position: absolute; inset: 0px; z-index: -1; [THE CSS GRADIENT OUTPUT HERE]">
<img src="./big_image.png" width="1920" height="1080"/> <!-- Make sure to include size -->
</div>
You can also optionally pass in an options object as the second argument. Here are the defaults:
import { blurhashAsGradients } from 'blurhash-gradients';
const css = blurhashAsGradients('LEHV6nWB2yk8pyo0adR*.7kCMdnj', {
width: 8, //The horizontal resolution of the gradients
height: 8, //The vertical resolution of the gradients
blur: 20, //The amount of blur to apply to the gradients (in pixels). Increase this on large display sizes.
});
FAQs
Draw blurhashes using CSS gradients.
The npm package blurhash-gradients receives a total of 39 weekly downloads. As such, blurhash-gradients popularity was classified as not popular.
We found that blurhash-gradients demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.