Dev Helpers
← Back

Greyscale proof switch

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

Open this example in the interactive library

Live preview

Source code

// components/GreyscaleProofSwitch.tsx

import { useState } from "react";

export default function GreyscaleProofSwitch({
  hex = "#bc805a",
}: { hex?: string } = {}) {
  const [proof, set] = useState(false);
  return (
    <button
      aria-pressed={proof}
      style={{ border: "1rem solid " + hex, filter: proof ? "grayscale(1)" : "none" }}
      onClick={() => set(!proof)}
    >
      Monochrome proof
    </button>
  );
}