Dev Helpers
← Back

Sentence boundary list

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

Open this example in the interactive library

Live preview

Source code

// components/SentenceBoundaryList.tsx

export default function SentenceBoundaryList({
  source = "Copper Studio North",
}: { source?: string } = {}) {
  const phrases = [
    ...new Intl.Segmenter("en", { granularity: "sentence" }).segment(source),
  ];
  return (
    <ol>
      {phrases.map((s) => (
        <li key={s.index}>{s.segment}</li>
      ))}
    </ol>
  );
}