Dev HelpersOpen library
← Back

Variable weight preview

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

Open this example in the interactive library

Live preview

Source code

// components/VariableWeightPreview.tsx

import { useState } from "react";

export default function VariableWeightPreview({
  text = "Copper studio",
}: { text?: string } = {}) {
  const [w, set] = useState(400);
  return (
    <label>
      Weight {w}
      <input
        type="range"
        min={100}
        max={900}
        step={100}
        value={w}
        onChange={(e) => set(+e.target.value)}
      />
      <b style={{ fontWeight: w }}>{text}</b>
    </label>
  );
}