Dev Helpers
← Back

Accent colour preview

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

Open this example in the interactive library

Live preview

Source code

// components/AccentColourPreview.tsx

import { useState } from "react";

import type { ReactNode } from "react";

export default function AccentColourPreview({
  children = "Preview text",
}: { children?: ReactNode } = {}) {
  const [color, set] = useState("#ad7651");
  return (
    <section>
      <label>
        Accent{" "}
        <input type="color" value={color} onChange={(e) => set(e.target.value)} />
      </label>
      <div style={{ borderInlineStart: "6px solid " + color, paddingInlineStart: 12 }}>
        {children}
      </div>
    </section>
  );
}