
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@choiceform/colors
Advanced tools
A powerful color management and picker component library for design systems.
npm install @choiceform/colors
or
yarn add @choiceform/colors
import { useState } from "react"
import { ColorPickerPopover, ColorSolidPaint } from "@choiceform/colors"
import type { RGB } from "@choiceform/colors"
function ColorPickerExample() {
const [color, setColor] = useState<RGB>({ r: 66, g: 133, b: 244 })
const [alpha, setAlpha] = useState<number>(1)
const [open, setOpen] = useState<boolean>(false)
return (
<ColorPickerPopover
open={open}
onOpenChange={setOpen}
solidPaint={
<ColorSolidPaint
color={color}
alpha={alpha}
onColorChange={setColor}
onAlphaChange={setAlpha}
/>
}
>
<div
className="h-12 w-12 cursor-pointer rounded"
style={{
backgroundColor: `rgba(${color.r}, ${color.g}, ${color.b}, ${alpha})`,
}}
onClick={() => setOpen(true)}
/>
</ColorPickerPopover>
)
}
import { useState } from "react"
import { ColorPickerPopover, ColorSolidPaint, ColorGradientsPaint } from "@choiceform/colors"
import type { RGB, GradientPaint } from "@choiceform/colors"
function GradientPickerExample() {
const [color, setColor] = useState<RGB>({ r: 66, g: 133, b: 244 })
const [gradient, setGradient] = useState<GradientPaint>({
type: "GRADIENT_LINEAR",
gradientStops: [
{ id: "1", position: 0, color: { r: 255, g: 0, b: 0 }, alpha: 1 },
{ id: "2", position: 1, color: { r: 0, g: 0, b: 255 }, alpha: 1 },
],
gradientTransform: [
[1, 0, 0],
[0, 1, 0],
],
})
// ...
}
The Colors library provides a powerful dynamic tabs system that allows you to extend the color picker's functionality:
import { ColorPickerPopover, ColorSolidPaint } from "@choiceform/colors"
function CustomTabsExample() {
// ...
// Custom tab content
const customPaletteContent = (
<div className="p-4">
<h3>Custom Palette</h3>
{/* Custom content */}
</div>
)
// Define additional tabs
const additionalTabs = [
{
value: "CUSTOM_PALETTE",
label: "Palette",
content: customPaletteContent,
},
]
return (
<ColorPickerPopover
additionalTabs={additionalTabs}
solidPaint={<ColorSolidPaint /* ... */ />}
// ...other properties
/>
)
}
You can control the functionality of the color picker through the features
property:
<ColorPickerPopover
features={{
containerWidth: 240,
spaceDropdown: true,
alpha: true,
hex: true,
rgb: true,
hsl: true,
hsb: true,
nativePicker: true,
presets: true,
pickerType: true,
custom: true,
paintsType: true,
solid: true,
gradient: true,
pattern: true,
image: true,
checkColorContrast: true,
}}
// ...other properties
/>
Support for checking color accessibility contrast:
<ColorPickerPopover
checkColorContrast={{
backgroundColor: { r: 255, g: 255, b: 255 },
foregroundColor: color,
foregroundAlpha: alpha,
level: "AA",
category: "normal-text",
// ...other configurations
}}
// ...other properties
/>
The main color picker component.
Property | Type | Default | Description |
---|---|---|---|
open | boolean | - | Control the popup state |
onOpenChange | (open: boolean) => void | - | Popup state change callback |
pickerType | string | "CUSTOM" | Picker type |
onPickerTypeChange | (type: string) => void | - | Picker type change callback |
paintsType | Paint["type"] | "SOLID" | Paint type |
onPaintsTypeChange | (type: Paint["type"]) => void | - | Paint type change callback |
solidPaint | ReactNode | - | Solid paint component |
gradientPaint | ReactNode | - | Gradient paint component |
additionalTabs | TabItem[] | [] | Additional tabs configuration |
features | PickerFeatures | - | Feature configuration |
checkColorContrast | ColorContrast | - | Color contrast check configuration |
...others | PopoverProps | - | Properties inherited from Popover |
// Tab item
interface TabItem {
value: string
label: string
content: ReactNode
}
// Features configuration
interface PickerFeatures {
containerWidth?: number
spaceDropdown?: boolean
alpha?: boolean
hex?: boolean
rgb?: boolean
hsl?: boolean
hsb?: boolean
nativePicker?: boolean
presets?: boolean
variables?: boolean
styles?: boolean
pickerType?: boolean
custom?: boolean
paintsType?: boolean
solid?: boolean
gradient?: boolean
pattern?: boolean
image?: boolean
checkColorContrast?: boolean
}
Contributions to @choiceform/colors through PRs and Issues are welcome. Please ensure you follow the project's code style and testing standards before submitting.
MIT
FAQs
A modern React color system
The npm package @choiceform/colors receives a total of 230 weekly downloads. As such, @choiceform/colors popularity was classified as not popular.
We found that @choiceform/colors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers 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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.