Installations
npm install @uiw/react-color-swatch
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Node Version
20.18.1
NPM Version
10.8.2
Score
93.2
Supply Chain
94.3
Quality
86.4
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (98.29%)
HTML (1.02%)
CSS (0.65%)
Less (0.04%)
Developer
Download Statistics
Total Downloads
1,905,170
Last Day
9,238
Last Week
38,728
Last Month
160,601
Last Year
1,472,339
GitHub Statistics
343 Stars
460 Commits
109 Forks
4 Watching
9 Branches
15 Contributors
Bundle Size
3.61 kB
Minified
1.77 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
2.3.4
Package Id
@uiw/react-color-swatch@2.3.4
Unpacked Size
17.41 kB
Size
3.96 kB
File Count
7
NPM Version
10.8.2
Node Version
20.18.1
Publised On
11 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
1,905,170
Last day
1.6%
9,238
Compared to previous day
Last week
-14.3%
38,728
Compared to previous week
Last month
17.5%
160,601
Compared to previous month
Last year
317.4%
1,472,339
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
3
Dev Dependencies
1
React Color Swatch
Swatch Component is a subcomponent of @react-color
.
Install
1npm i @uiw/react-color-swatch
Usage
1import React, { useState } from 'react'; 2import { hsvaToHex, getContrastingColor, } from '@uiw/color-convert'; 3import Swatch from '@uiw/react-color-swatch'; 4 5function Point(props: { color?: string; checked?: boolean }) { 6 if (!props.checked) return null; 7 return ( 8 <div 9 style={{ 10 height: 5, 11 width: 5, 12 borderRadius: '50%', 13 backgroundColor: getContrastingColor(props.color!), 14 }} 15 /> 16 ); 17} 18 19function Demo() { 20 const [hex, setHex] = useState("#fff"); 21 return ( 22 <Swatch 23 colors={[ '#F44E3B', '#FE9200', '#FCDC00', '#DBDF00' ]} 24 color={hex} 25 rectProps={{ 26 children: <Point />, 27 style: { 28 display: 'flex', 29 alignItems: 'center', 30 justifyContent: 'center', 31 }, 32 }} 33 onChange={(hsvColor) => { 34 setHex(hsvaToHex(hsvColor)) 35 }} 36 /> 37 ); 38} 39 40export default Demo;
Props
1import React from 'react'; 2import { HsvaColor, ColorResult } from '@uiw/color-convert'; 3export type SwatchPresetColor = { 4 color: string; 5 title?: string; 6} | string; 7export interface SwatchRectRenderProps extends React.HTMLAttributes<HTMLDivElement> { 8 title: string; 9 color: string; 10 checked: boolean; 11 style: React.CSSProperties; 12 onClick: (evn: React.MouseEvent<HTMLDivElement, MouseEvent>) => void; 13}; 14export interface SwatchProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'color'> { 15 prefixCls?: string; 16 color?: string; 17 colors?: SwatchPresetColor[]; 18 rectProps?: React.HTMLAttributes<HTMLDivElement>; 19 rectRender?: (props: SwatchRectRenderProps) => JSX.Element; 20 onChange?: (hsva: HsvaColor, color: ColorResult, evn: React.MouseEvent<HTMLDivElement, MouseEvent>) => void; 21 addonAfter?: React.ReactNode; 22 addonBefore?: React.ReactNode; 23} 24declare const Swatch: React.ForwardRefExoticComponent<SwatchProps & React.RefAttributes<HTMLDivElement>>; 25export default Swatch;
Contributors
As always, thanks to our amazing contributors!
Made with contributors.
License
Licensed under the MIT License.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/ci.yml:8
Reason
8 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 7
Reason
Found 6/28 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:63: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:80: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:88: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/pr.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/uiwjs/react-color/pr.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:21
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:23
- Warn: npmCommand not pinned by hash: .github/workflows/pr.yml:16
- Warn: npmCommand not pinned by hash: .github/workflows/pr.yml:18
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 7 third-party GitHubAction dependencies pinned
- Info: 0 out of 4 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/pr.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 8 are checked with a SAST tool
Score
5.1
/10
Last Scanned on 2025-01-27
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