Swatch palette

Grid of colour swatches for quick selection. Pairs with ColourPicker.

Install

npx shadcn@latest add https://substrate.georgedrury.co.uk/r/swatch-palette

Examples

Default

#3b82f6
"use client"

import { useState } from "react"

Props

PropTypeDefaultDescription
coloursstring[]—Array of hex colour strings
valuestring—Currently selected colour
onSelect(colour: string) => void—Called when a swatch is clicked
columnsnumber8Grid column count

Presets

Two built-in palettes are exported for convenience:

import {
	MATERIAL_COLOURS,
	TAILWIND_COLOURS,
} from "@/components/substrate/swatch-palette"