Gathering detailed insights and metrics for material-color-hash
Gathering detailed insights and metrics for material-color-hash
Gathering detailed insights and metrics for material-color-hash
Gathering detailed insights and metrics for material-color-hash
hash-color-material
Hashes a string or a number to a material color hex code.
@osjwnpm/odit-ipsum-fugit
[](https://www.npmjs.com/package/material-components-web) [](https://discord.gg/material-components)
npm install material-color-hash
Typescript
Module System
Node Version
NPM Version
80.7
Supply Chain
98
Quality
77.5
Maintenance
100
Vulnerability
100
License
JavaScript (98.97%)
HTML (0.8%)
CSS (0.23%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
73 Stars
34 Commits
3 Forks
6 Watchers
2 Branches
5 Contributors
Updated on May 03, 2024
Latest Version
0.1.6
Package Id
material-color-hash@0.1.6
Unpacked Size
12.43 kB
Size
5.02 kB
File Count
9
NPM Version
5.5.1
Node Version
9.0.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Material takes cues from contemporary architecture, road signs, pavement marking tape, and athletic courts. Color should be unexpected and vibrant. (https://material.google.com/style/color.html)
Hash a string to a Material Design color
A dead-simple library to hash a string to a {backgroundColor, textColor} tuple from the official Material Design palette.
Great for dynamically coloring your UI elements (badges, list icons, ..) with good-looking, vibrant colors and ensured text legibility.
http://belkalab.github.io/material-color-hash/
1$ npm install material-color-hash
1var toMaterialStyle = require('material-color-hash'); 2// or, if you are on ES6: 3// import toMaterialStyle from 'material-color-hash' 4 5/* basic usage */ 6var fooStyle = toMaterialStyle('foo'); 7// fooStyle: { 8// backgroundColor: '#00BCD4', 9// color: 'rgba(0, 0, 0, 0.87)', 10// materialColorName: 'Cyan' 11// } 12 13/* select a different shade (default is 500) */ 14var fooStyle200 = toMaterialStyle('foo', '200'); 15// fooStyle200: { 16// backgroundColor: '#80DEEA', 17// color: 'rgba(0, 0, 0, 0.87)', 18// materialColorName: 'Cyan' 19// } 20 21var barStyle = toMaterialStyle('bar', 500); 22// barStyle: { 23// backgroundColor: '#2196F3', 24// color: 'rgba(255, 255, 255, 1)', 25// materialColorName: 'Blue' 26// } 27 28/* also works with emoji! */ 29var emojiStyle = toMaterialStyle('😎'); 30// emojiStyle: { 31// backgroundColor: '#FFEB3B', 32// color: 'rgba(0, 0, 0, 0.87)', 33// materialColorName: 'Yellow' 34// }
The returned object can be fed directly as a style prop to React components:
1import toMaterialStyle from 'material-color-hash'; 2 3const MaterialBadge = (props) => { 4 const style = toMaterialStyle(props.text); 5 6 return ( 7 <div 8 className="badge" 9 style={style} 10 > 11 {props.text} 12 </div> 13 ); 14}
For more information about Material Design colors and how to use them, check out the official Material Design docs by Google
Giovanni Frigo, Developer @Belka
material-color-hash is Copyright (c) 2016-2018 Belka, srl. It is free software, and may be redistributed under the terms specified in the LICENSE file. (TL;DR: MIT license)
Belka is a Digital Agency specialized in design, mobile applications development and custom solutions. We love open source software! You can see our projects or look at our case studies.
Interested? Hire us to help build your next amazing project.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is archived
Details
Reason
Found 2/25 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
51 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More