Dev Helpers
← Back

Complementary paint swatch

Import and render <ComplementaryPaintSwatch /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/ComplementaryPaintSwatch.tsx

export default function ComplementaryPaintSwatch({
  hex = "#bc805a",
}: { hex?: string } = {}) {
  const complement =
    "#" + (0xffffff ^ parseInt(hex.slice(1), 16)).toString(16).padStart(6, "0");
  return (
    <figure style={{ border: "2rem solid " + complement }}>
      <figcaption>Complement {complement}</figcaption>
    </figure>
  );
}