Dev Helpers
← Back

Split palette comparison

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

Open this example in the interactive library

Live preview

Source code

// components/SplitPaletteComparison.tsx

import { useState } from "react";

export default function SplitPaletteComparison({
  hex = "#bc805a",
}: { hex?: string } = {}) {
  const [other, set] = useState("#19423a");
  return (
    <label>
      Compare colour
      <input type="color" value={other} onChange={(e) => set(e.target.value)} />
      <span
        style={{
          display: "block",
          height: 64,
          background: "linear-gradient(90deg," + hex + " 50%," + other + " 50%)",
        }}
      />
    </label>
  );
}