Spelte

Open Github

Color Selector

Interactive color picker component.

Installation

pnpm dlx shadcn-svelte@latest add https://spelte.dev/r/color-selector.json

Examples

Size

Callback

Selected: purple

Usage

<script>
	import ColorSelector from '$registry/spelte/color-selector.svelte';
 
	const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
</script>
 
<ColorSelector {colors} defaultValue="blue" />

Props

PropTypeDefaultDescription
colorsstring[]Array of color names or hex values
defaultValuestringInitially selected color
size"sm" | "default" | "lg""default"Size of color circles
namestringName for hidden form input
onColorSelect(color: string) => voidCallback when color is selected
classstringAdditional CSS classes