# Numbered list {#ordered-list}

Source: [Add numbered lists to a React editor · Yurich](https://leeyujoo.com/yurich/features/ordered-list/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

Number steps and other items in sequence.

## Try it {#try-it}

Select both paragraphs and click **Numbered list**. The result is an `<ol>` with two `<li>` items. Select the list and toggle it again to turn its items into paragraphs.

## Add it to your editor {#setup}

Enable `OrderedList` and connect a button to `toggleOrderedList`. Choose this for steps where order carries meaning.

```tsx
import { EditorContent, EditorProvider, OrderedList, useEditor, useIsActive } from 'yurich';

export function OrderedListEditor() {
  const editor = useEditor({
    extensions: [OrderedList],
    initialValue: "<p>Install Yurich</p><p>Give the Bold button a home</p>",
  });
  const active = useIsActive(editor, 'toggleOrderedList');

  return (
    <EditorProvider editor={editor}>
      <button
        type="button"
        aria-pressed={active}
        onMouseDown={event => event.preventDefault()}
        onClick={() => editor.execute('toggleOrderedList')}
      >
        Numbered list
      </button>
      <EditorContent ariaLabel="Editor" />
    </EditorProvider>
  );
}
```

## Behavior to account for {#behavior}

With the caret in one item, the command operates on that item. Removing or changing a middle item can split the surrounding list.

[Features](https://leeyujoo.com/yurich/features/)
