Fulldev UI

A color or pattern beside an option or filter value.

Installation

npx shadcn@latest add @fulldev/swatch

Usage

import { Swatch } from "@/components/ui/swatch"
<Swatch color="#1e3a5f" />
<Swatch image="/swatches/denim.webp" />

color sets the background color and image the URL of a pattern or photo, such as a Shopify swatch. A swatch is decorative, so it renders with aria-hidden="true": keep the value’s name in text, or give the control around it an aria-label. Set its size with a size-* class.

API Reference

Source: react/src/components/ui/swatch.tsx