Rich-text editor example

A scoped Arabic editing surface.

The editor, formatting popup and mention choices inherit an explicit local language, direction and theme. Host labels and directory identities remain application-owned.

Complete React client module · MIT · Next.js and Vite

Interactive example

A scoped Arabic editing surface

The editor, formatting popup and mention choices inherit an explicit local language, direction and theme. Host labels and directory identities remain application-owned.

Keyboard

  • Tab enters the toolbar; its directional arrows follow RTL. Editor shortcuts keep their native editing semantics.
  • Type @ to search the authored Arabic directory. Escape closes suggestions and keeps the text.

States covered

  • Scoped RTL
  • Dark theme
  • Local message overrides
  • Arabic directory labels
  • Stable IDs
  • Reduced motion

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-rich-text-scoped-arabic.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {RichTextEditor,UIProvider,type RichTextMentionSource,type RichTextDocument} from '@bld8/ui';
const content:RichTextDocument={type:'doc',content:[{type:'paragraph',content:[{type:'text',text:'تفاصيل صغيرة تجعل المراجعة أوضح.'}]}]};
const source:RichTextMentionSource=async({query,signal})=>signal.aborted?[]:[{id:'reviewer-maya',label:'مايا',description:'هندسة الواجهات'},{id:'reviewer-sam',label:'سام',description:'أنظمة التصميم'}].filter(person=>person.label.includes(query));
export default function ArabicRichText(){return <UIProvider theme="dark" locale="ar" direction="rtl" motion="reduced" messages={{'rich.formatting':'تنسيق النص','rich.bold':'غامق','rich.italic':'مائل','rich.strike':'يتوسطه خط','rich.block':'نمط النص','rich.paragraph':'فقرة','rich.heading1':'عنوان ١','rich.heading2':'عنوان ٢','rich.heading3':'عنوان ٣','rich.bullets':'قائمة نقطية','rich.ordered':'قائمة مرقمة','rich.codeBlock':'كتلة برمجية','rich.editLink':'تعديل الرابط','rich.linkAddress':'عنوان الرابط','rich.undo':'تراجع','rich.redo':'إعادة','rich.mention':'إشارة إلى شخص','rich.people':'أشخاص للإشارة','rich.noPeople':'لا توجد أسماء مطابقة.'}}><div style={{padding:24,background:'var(--bui-surface)',borderRadius:12}}><RichTextEditor label="ملاحظة المراجعة" defaultValue={content} mentionSource={source} hint="الأسماء المعروضة لا تغيّر المعرّفات المخزنة."/></div></UIProvider>;}