npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

css-textures

v0.2.0

Published

A zero-dependency palette of CSS textures

Readme

css-textures

Zero-dependency CSS texture overlays for backgrounds and text.

Installation

npm install css-textures

Usage

JS (auto-inject)

Importing a texture and accessing .className or calling .apply() / .applyToText() automatically injects the required CSS into the document.

import { leather } from "css-textures";

// Apply to a DOM element (injects CSS automatically)
leather.apply(document.querySelector(".card"));

// Apply to text
leather.applyToText(document.querySelector("h1"));

// Or manage the class yourself
const el = document.querySelector(".card");
el.classList.add(leather.className); // "texture-leather"

// Works in template strings too (calls toString())
el.className = `card ${leather}`;

React

import { leather } from 'css-textures';

// Background
<div
  className={leather.className}
  style={{ backgroundColor: '#1a2744', '--texture-scale': '150px', '--texture-blend-mode': 'multiply' }}
/>

// Text
<h1
  className={leather.textClassName}
  style={{ backgroundColor: '#1a2744' }}
>
  Hello
</h1>

[!NOTE] TypeScript users: import the React augmentation once (e.g. in src/env.d.ts) to use CSS custom properties in style={} without casts:

import 'css-textures/react';

Otherwise, cast the style object explicitly:

style={{ '--texture-scale': '150px' } as React.CSSProperties}

CSS-only

Import the stylesheet and apply classes directly:

@import "css-textures/css"; /* all textures */
@import "css-textures/css/leather"; /* just leather */
<div class="texture-leather" style="background-color: #1a2744"></div>
<h1 class="texture-leather-text" style="background-color: #1a2744">Hello</h1>

Or via CDN (no build step required):

<!-- All textures -->
<link
  rel="stylesheet"
  href="https://unpkg.com/css-textures/dist/textures.css"
/>

<!-- Just leather -->
<link
  rel="stylesheet"
  href="https://unpkg.com/css-textures/dist/textures/leather.css"
/>

SSR

Inject the raw CSS string server-side to avoid a flash of unstyled content:

import { leather } from "css-textures";

const { css, className } = leather;
// Inject `css` into your <head>, then use `className` on your element

Customization

Textures are customized with CSS custom properties, either inline or via a CSS rule:

.my-card {
  background-color: #1a2744;
  --texture-scale: 150px;
  --texture-intensity: 0.4;
  --texture-blend-mode: multiply;
}
<div class="my-card texture-leather">...</div>

Or inline:

<div
  class="texture-leather"
  style="background-color: #1a2744; --texture-scale: 150px; --texture-intensity: 0.4;"
></div>

| Property | Default | Description | | ---------------------- | --------- | ------------------------------------------------------------------------------------------------- | | --texture-scale | 200px | Tile/repeat size | | --texture-intensity | 0.6 | Overlay opacity (0–1). Background textures only — see text limitations below. | | --texture-blend-mode | overlay | CSS blend mode |

Texturing text

The text variant uses background-clip: text to mask the texture through the text shape. A background-color is required as the blend target — without one the text will be invisible.

<h1 className={leather.textClassName} style={{ backgroundColor: "#1a2744" }}>
  Hello
</h1>

Limitations

--texture-intensity has no effect on text variants. The text clipping technique (background-clip: text + -webkit-text-fill-color: transparent) works by masking the element's background through its text. There's no separate overlay layer to apply opacity to, so intensity cannot be controlled. To adjust the apparent strength of the texture on text, try adjusting --texture-scale or the element's text color.

--texture-blend-mode behaves differently on text. For background textures, blend mode is applied via mix-blend-mode on a ::before pseudo-element layered over the content. For text, it's applied as background-blend-mode, which blends the texture image against the element's background-color. Results will differ from the background variant and depend on what background color is set.

Avoid the background shorthand. Use background-color instead. The background shorthand resets background-image to none. The library uses !important on background-image to guard against this, but background-color (or backgroundColor in JSX/JS) is clearer and avoids surprises if you need to set other background sub-properties.

Available textures

| Export | Description | | --------- | --------------------- | | leather | Pebbled organic noise |

API reference

| Member | Type | Description | | ----------------- | -------------------------- | ------------------------------------------------------------ | | id | string | Texture identifier, e.g. "leather" | | className | string | CSS class for background texturing, e.g. "texture-leather" | | textClassName | string | CSS class for text texturing, e.g. "texture-leather-text" | | css | string | Raw CSS string (useful for SSR) | | vars | Record<string, string> | Descriptions of supported CSS custom properties | | apply(el) | (el: Element) => Element | Adds className to the element | | applyToText(el) | (el: Element) => Element | Adds textClassName to the element | | remove(el) | (el: Element) => Element | Removes both texture classes from the element | | toString() | () => string | Returns className — enables template string usage |