
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
hash-css-selector
Advanced tools
A function to hash CSS selectors, can be used with postcss-modules to generate short static unique class names
A function to hash CSS selectors, can be used with postcss-modules to generate short static unique class names.
hashCSSSelector
returns a 8 character long hash of the given string. The function is deterministic, so the same input will always result in the same output.
import { hashCSSSelector } from 'hash-css-selector';
hashCSSSelector('test-class'); // -> 'm-a530cc7d'
hashCSSSelector('another-test-class'); // -> 'm-c43ac187'
// Default prefix is 'm'
// Customize prefix by passing a second argument
hashCSSSelector('test-class', 'my-prefix'); // -> 'my-prefix-a530cc7d'
With default m
prefix:
import { generateScopedName } from 'hash-css-selector';
postcss([
require('postcss-modules')({
generateScopedName: generateScopedName,
}),
]);
With custom prefix:
import { createGenerateScopedName } from 'hash-css-selector';
postcss([
require('postcss-modules')({
generateScopedName: createGenerateScopedName('custom-prefix'),
}),
]);
MIT
FAQs
A function to hash CSS selectors, can be used with postcss-modules to generate short static unique class names
The npm package hash-css-selector receives a total of 1,142 weekly downloads. As such, hash-css-selector popularity was classified as popular.
We found that hash-css-selector demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.