Your own toolbar
The kit is optional. With @writeon/ui you keep the keyboard support and ARIA and write your own markup, for example with Tailwind:
tsx
import type { Editor } from '@writeon/core'
import { useToolbar } from '@writeon/react'
import { basicToolbarItems } from '@writeon/ui'
// All the basic buttons, without underline.
const items = basicToolbarItems({ exclude: ['underline'] })
export function MyToolbar({ editor }: { editor: Editor }) {
const toolbar = useToolbar(editor, { items })
// The prop getters bring the ARIA and keyboard support;
// the classes are yours (Tailwind here).
return (
<div {...toolbar.getRootProps()} className="flex gap-1">
{toolbar.items.map((item) => (
<button
key={item.id}
{...toolbar.getItemProps(item.id)}
className="rounded px-2 aria-pressed:bg-indigo-100"
>
{item.label}
</button>
))}
</div>
)
}What you get from getItemProps(): type="button", aria-label, aria-pressed for toggles, aria-keyshortcuts, disabled when the command cannot run here, the roving tabindex, and handlers that keep the editor's selection when a button is clicked.
To add something that is not a command button (a link button, a menu trigger) to the arrow-key navigation, use getCustomItemProps(id, props).
For plain JavaScript, see Headless UI.