Dev Helpers
← Back

UTF-8 byte budget

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

Open this example in the interactive library

Live preview

Source code

// components/UTF8ByteBudget.tsx

export default function UTF8ByteBudget({
  source = "Copper Studio North",
}: { source?: string } = {}) {
  const bytes = new TextEncoder().encode(source).length;
  return (
    <label>
      Encoded size <meter min={0} max={Math.max(bytes, 64)} value={bytes} />
      {bytes} bytes
    </label>
  );
}