Dev Helpers
← Back

Glyph distribution strip

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

Open this example in the interactive library

Live preview

Source code

// components/GlyphDistributionStrip.tsx

export default function GlyphDistributionStrip({
  text = "Copper studio",
}: { text?: string } = {}) {
  const unique = [...new Set(text.toLowerCase().replace(/\s/g, ""))];
  return (
    <ul>
      {unique.map((c) => (
        <li key={c}>
          {c}: {[...text.toLowerCase()].filter((v) => v === c).length}
        </li>
      ))}
    </ul>
  );
}