> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# RTL Support

> Show CometChat Angular UI Kit components right to left for Arabic and other RTL languages: from your page's direction, for the whole kit, or per component with layoutDirection.

> [accordion] AI Integration Quick Reference
>
> | Field | Value |
> | - | - |
> | Package | `@cometchat/chat-uikit-angular` 5.4.0 or later |
> | Import | `import { CometChatUIKit, UIKitSettingsBuilder, CometChatLocalize } from '@cometchat/chat-uikit-angular';` |
> | Purpose | Show UI Kit components right to left (RTL) or left to right (LTR), for the whole kit or for one component. |
> | Global setting | `new UIKitSettingsBuilder().setLayoutDirection(...)` at init, `CometChatUIKit.setLayoutDirection(...)` after init |
> | Per component | `layoutDirection` input on the feature components (lists, message components, call screens, AI Assistant Chat, every message bubble): `<cometchat-conversations layoutDirection="rtl">`. Base components have none and follow the component they sit in |
> | Values | Global: `'auto'` (default) · `'ltr'` · `'rtl'`. Component input: `'ltr'` · `'rtl'` (leave it unset to inherit) |
> | Default behavior | `'auto'` follows your page's direction (`<html dir>`), so an app that is already RTL needs no extra code |
> | Language → direction | `CometChatLocalize.getDirection(language)` returns `'rtl'` for every language written in a right-to-left script (`ar`, `he`, `fa`, `ur` and others, any region), `'ltr'` for everything else |
> | Who sets `<html dir>` | Your app. The UI Kit never changes the page's direction. |
> | Types | `CometChatLayoutDirection` (`'auto' \| 'ltr' \| 'rtl'`) and `CometChatTextDirection` (`'ltr' \| 'rtl'`), exported for typing your own settings state |
> | Related | [Localization](https://www.cometchat.com/docs/ui-kit/angular/customization/localization.md) · [Methods](https://www.cometchat.com/docs/ui-kit/angular/methods.md) · [Theming](https://www.cometchat.com/docs/ui-kit/angular/customization/theming.md) |

## Overview

Languages such as Arabic are read right to left. In an RTL layout, the UI Kit mirrors every component: avatars, names, buttons, message bubbles, menus, popovers and dialogs swap sides, and arrows point the other way.

Mirroring the layout doesn't mean flipping the content. The UI Kit keeps every piece of content readable:

* Each message reads in its own direction, so an English message in an Arabic chat still reads left to right.
* Names, mentions and email addresses keep their order inside the text around them.
* Audio and video players and code blocks stay left to right, as they do in every RTL app.

An app that sets no direction and has no `dir="rtl"` on its page lays out left to right, exactly as before.

## Layout Direction and Language

Layout direction and language are two separate settings:

| Setting | Decides | Set with |
| - | - | - |
| Layout direction | Which side things sit on | `<html dir>` (default), or `layoutDirection` |
| Language | Which strings are shown | `CometChatLocalize.setCurrentLanguage()` (see [Localization](https://www.cometchat.com/docs/ui-kit/angular/customization/localization.md)) |

Choosing Arabic translates the UI Kit but doesn't change its layout. By default the UI Kit follows your page's direction, which your app sets from the language. You can also set them apart, for example an English app laid out RTL, or an Arabic app kept LTR.

## Turn On RTL

### Follow the page's direction (default)

With the default value, `'auto'`, the UI Kit follows your app: set `dir` on `<html>` and every component lays out to match. This is the recommended setup for an app that is itself right to left.

```html theme={null}
<html lang="ar" dir="rtl">
```

The UI Kit never writes `<html dir>`. If your app switches language at runtime, set the page's direction from the language yourself:

> [tab] TypeScript
>
> ```typescript theme={null}
> import { CometChatLocalize } from '@cometchat/chat-uikit-angular';
>
> export function applyLanguage(language: string): void {
>   CometChatLocalize.setCurrentLanguage(language);
>   // Your app sets the page's language and direction, not the UI Kit.
>   document.documentElement.lang = language;
>   document.documentElement.dir = CometChatLocalize.getDirection(language); // 'rtl' for 'ar'
> }
> ```

`CometChatLocalize.getDirection()` returns `'rtl'` for every language written in a right-to-left script, in any region: Arabic (`ar`, `ar-SA`), Hebrew, Persian, Urdu, Pashto, Sindhi, Sorani Kurdish, Uyghur, Yiddish and Dhivehi, and tags that name such a script (`pa-Arab`). It returns `'ltr'` for everything else. With no argument, it uses the language the UI Kit is actually showing: a language with no strings of its own, such as `he` before you add Hebrew, shows English and returns `'ltr'`. It only reports the direction; it changes nothing.

> [!NOTE]
>
> `CometChatUIKit.init()` selects the browser's language. To use a language your user picked, call `CometChatLocalize.setCurrentLanguage()` after `init()`, then set `<html dir>` before your app renders, so the first frame already has the right direction. Components work out some text (dates, previews, labels) when they are created, so after a language change, recreate the screen or reload the page.

### Set it for the whole UI Kit

Call `setLayoutDirection()` on the `UIKitSettingsBuilder` to give every UI Kit component a fixed direction, whatever the page's direction. Your own components and the rest of the page are not affected:

> [tab] TypeScript
>
> ```typescript theme={null}
> import { CometChatUIKit, UIKitSettingsBuilder } from '@cometchat/chat-uikit-angular';
>
> const uiKitSettings = new UIKitSettingsBuilder()
>   .setAppId('APP_ID')
>   .setRegion('REGION')
>   .setAuthKey('AUTH_KEY')
>   .subscribePresenceForAllUsers()
>   .setLayoutDirection('rtl') // 'auto' (default) | 'ltr' | 'rtl'
>   .build();
>
> CometChatUIKit.init(uiKitSettings)?.then(() => {
>   // Log in and render your app
> });
> ```

| Value | Result |
| - | - |
| `'auto'` | Follows the page's direction. This is the default, so apps that don't set it see no change. |
| `'ltr'` | Every UI Kit component is left to right. |
| `'rtl'` | Every UI Kit component is right to left. |

### Change it at runtime

Use `CometChatUIKit.setLayoutDirection()` to change the direction while the app is running, for example from a settings screen:

> [tab] TypeScript
>
> ```typescript theme={null}
> import { CometChatUIKit } from '@cometchat/chat-uikit-angular';
>
> CometChatUIKit.setLayoutDirection('rtl');
>
> // Recreate the UI Kit screens so they pick up the new direction,
> // for example by toggling an @if around them or navigating away and back.
> ```

> [!NOTE]
>
> The new direction applies to UI Kit components created after the change. Components already on screen keep their direction until they are created again, for example when the user reopens the screen. Call it after `init()`: `init()` applies the builder's setting (`'auto'` if you didn't set one), so a direction set before `init()` is replaced.

## Set It Per Component

The feature components listed below take a `layoutDirection` input, `'ltr'` or `'rtl'`. It overrides the global setting for that component and the UI Kit components inside it, including the menus, popovers and dialogs it opens:

> [tab] HTML
>
> ```html theme={null}
> <!-- The whole UI Kit is RTL, but this list stays LTR. -->
> <cometchat-conversations layoutDirection="ltr"></cometchat-conversations>
>
> <!-- Bound to a property of your component -->
> <cometchat-message-list [user]="user" [layoutDirection]="chatDirection"></cometchat-message-list>
> ```

Leave it unset to inherit the direction from the UI Kit component around it, or from the global setting. Unlike the global setting, changing the input updates the component at once.

The input is on:

| Chat | Messages | Calls and AI |
| - | - | - |
| [Conversations](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-conversations.md) | [Message Header](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-message-header.md) | [Call Buttons](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-call-buttons.md) |
| [Conversation Item](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-conversation-item.md) | [Message List](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-message-list.md) | [Call Logs](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-call-logs.md) |
| [Users](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-users.md) | [Message Composer](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-message-composer.md) | [Incoming Call](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-incoming-call.md) |
| [User Item](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-user-item.md) | [Message Bubble](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-message-bubble.md) | [Outgoing Call](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-outgoing-call.md) |
| [Groups](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-groups.md) | [Message Information](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-message-information.md) | [AI Assistant Chat](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-ai-assistant-chat.md) |
| [Group Item](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-group-item.md) | [Thread Header](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-thread-header.md) | [Markdown Renderer](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-markdown-renderer.md) |
| [Group Members](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-group-members.md) | [Pinned Messages](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-pinned-messages.md) | |
| [Group Member Item](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-group-member-item.md) | [Saved Messages](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-saved-messages.md) | |
| [Search](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-search.md) | [Reactions](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-reactions.md), [Reaction List](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-reaction-list.md), [Reaction Info](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-reaction-info.md) | |
| [Notification Feed](https://www.cometchat.com/docs/ui-kit/angular/components/notification-feed.md) | [Stickers Keyboard](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-stickers-keyboard.md) | |

Every message bubble takes it too: [Text](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-text-bubble.md), [Card](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-card-bubble.md), [Image](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-image-bubble.md), [Video](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-video-bubble.md), [Audio](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-audio-bubble.md), [File](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-file-bubble.md), [Action](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-action-bubble.md), [Delete](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-delete-bubble.md), [Call](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-call-bubble.md), [Poll](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-poll-bubble.md), [Collaborative Document](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-collaborative-document-bubble.md), [Collaborative Whiteboard](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-collaborative-whiteboard-bubble.md) and [Sticker](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-sticker-bubble.md).

Every other component has no input of its own: it follows the component it sits in, and used on its own it follows the global setting. A `[layoutDirection]` binding on one of these fails to compile. They are:

* Base elements: avatar, button, checkbox, radio button, dropdown, list item, date, popover, context menu, toast, action sheet, search bar, typing indicator, error boundary and fullscreen viewer.
* Dialogs and pickers: confirm dialog, pin and save confirm dialog, flag message dialog, change scope, link dialog and link popover, emoji keyboard and media recorder.
* Message parts: message preview and thread view.
* AI: [Smart Replies](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-smart-replies.md), [Conversation Starter](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-conversation-starter.md) and [Conversation Summary](https://www.cometchat.com/docs/ui-kit/angular/components/cometchat-conversation-summary.md).
* The search result lists (`cometchat-search-messages-list` and `cometchat-search-conversations-list`), which follow the Search component they sit in.

## Which Setting Wins

When settings disagree, the first rule that gives a direction wins:

1. Audio and video players and the voice recorder are always left to right.
2. The component's own `layoutDirection`.
3. The nearest UI Kit component around it: its own `layoutDirection`, or the global setting as it was when that component was created.
4. The global setting, when it is `'ltr'` or `'rtl'`.
5. The page's direction: the `dir` of `<html>`, or of an element the component sits inside.

The UI Kit writes the result as `dir` on the component's host element. With nothing set and the global setting `'auto'`, it writes no `dir` at all.

> [!WARNING]
>
> When the global setting is `'ltr'` or `'rtl'`, wrapping a component in an element with its own `dir` does **not** change the component's direction:
>
> ```html theme={null}
> <!-- With setLayoutDirection('rtl'), this list still lays out right to left -->
> <div dir="ltr">
>   <cometchat-conversations></cometchat-conversations>
> </div>
> ```
>
> The global setting is written on each component's host element, so it wins over the wrapper. Use the component's input instead: `<cometchat-conversations layoutDirection="ltr">`. A `dir` wrapper works only while the global setting is `'auto'`.

## Pages Outside the UI Kit

The UI Kit never changes your page's direction. With a global `'ltr'` or `'rtl'`, the UI Kit's components follow it but your own components, headers and navigation stay as they are. To give one of your own sections the same direction, set `dir` on it:

> [tab] HTML
>
> ```html theme={null}
> <section dir="rtl" class="settings-panel">
>   <!-- your own content -->
> </section>
> ```

To mirror the whole app, set `<html dir="rtl">` and leave the UI Kit on `'auto'`.

## Common Scenarios

| You want | Global setting | Component setting |
| - | - | - |
| Your app is already in Arabic and right to left | `'auto'` (the default) and `<html dir="rtl">` | None |
| An English app, with the chat in Arabic and right to left | `'rtl'`, plus `CometChatLocalize.setCurrentLanguage('ar')` | None |
| Everything right to left except one component | `'rtl'` | `'ltr'` on that component |
| A right-to-left app with one component left to right | `'auto'` | `'ltr'` on that component |
| Only the chat screen right to left, in a left-to-right app | `'auto'` | `'rtl'` on each of the screen's components |

In the last case, components side by side, such as a header, message list and composer, each need the input, or wrap them in `<div dir="rtl">`: a wrapper works because the global setting is `'auto'`.

## What Changes in RTL

### Layout

Everything that has a side moves to the other one: avatars, titles, subtitles, timestamps, unread badges, receipts, buttons, the composer's actions, message bubbles, menus, popovers, dialogs, toasts, tooltips and loading skeletons. Sent messages sit on the left and received messages on the right.

Menus, popovers and tooltips are placed by the direction and stay on screen near both edges. A `placement` of `left` or `right` on a popover or context menu is mirrored in RTL, so a menu set to open at the end side still does. The left and right arrow keys follow the layout: in a right-to-left list, the left arrow moves to the next item.

### Icons

| Icon | In RTL |
| - | - |
| Arrows that point along the reading direction: back, forward, sideways chevrons, send, reply, reply all, reply in thread, and the call-direction arrows (incoming, outgoing and missed, voice and video, alone or with a handset) | Flip |
| Video camera, copy, chat (message privately) and sticker | Flip |
| Bulleted list and quote, in the composer's formatting toolbar | Flip |
| Numbered list, in the composer's formatting toolbar | Swaps to a drawing with the numbers on the right, so they still read 1, 2, 3 |
| Everything else: phone handset, hang-up, microphone, attach, emoji, close, search, receipt ticks, pin, media controls, file types, logos, flags and vertical arrows | Stay as drawn |

Icons you pass into the UI Kit, such as your own `iconURL` on a menu option, are drawn as you give them.

### What doesn't mirror

* **Audio and video players**, including voice notes, the voice recorder and the fullscreen viewer: playback controls, waveforms and progress bars stay left to right in every language. The bubble around the player still follows the layout.
* **Code blocks**, in chat messages and in AI assistant replies, always read left to right.
* **The link dialog's URL field** in the composer reads left to right.
* **Counters such as `+3`** on an image grid or a reactions row keep their sign in front.
* **The call screen** during a call (`cometchat-ongoing-call`) is the Calls SDK's own UI: its participants panel, layout and settings menus and toasts always stay left to right.

### Message text

* **Each message reads in its own direction.** The first letter decides it: a message that starts with an English letter reads left to right, one that starts with an Arabic letter reads right to left. Conversation subtitles, search results, saved messages and the composer's reply and edit previews do the same.
* **Names and mentions keep their place.** A sender's name is isolated, so it can't reorder the text around it (the `:` after a name stays after it), and a mention always reads `@name`.
* **Links, inline code and email addresses** take their own direction: a URL or an email address reads left to right inside Arabic text.
* **The UI Kit's own labels** (empty and error states, dialog text, toasts) read in the UI language's direction, so an English label in an RTL layout keeps its punctuation at the end. Their position still follows the layout.
* **Numbers and dates.** When the UI Kit's language is Arabic (`ar`), the dates, times and counts it formats use Arabic-Indic digits (٠١٢٣٤٥٦٧٨٩). A regional tag, such as `ar-MA`, uses that region's own digits. Member counts, reply counts and "last seen" use Arabic's plural forms ("عضوان", "١١ عضوًا"). See [Count Texts](https://www.cometchat.com/docs/ui-kit/angular/customization/localization.md#count-texts). Text you supply yourself is shown as given.

### Message composer

* The text follows the language you type: an English line starts at the left, an Arabic line at the right, in either layout direction.
* The placeholder stays on the layout's start side.

## Custom Views in RTL

Templates you pass into the UI Kit (item, leading, title, subtitle, trailing and header views, custom bubbles) render inside the component's host element and inherit its direction. A UI Kit component you place inside one of these templates inherits from the UI Kit component around it. Write your templates and CSS so they mirror with the rest of the UI Kit.

**Use CSS logical properties.** The UI Kit's own stylesheets use them, so they mirror on their own. Physical properties still work in a left-to-right layout exactly as before, but don't mirror:

| Instead of | Use |
| - | - |
| `margin-left`, `margin-right` | `margin-inline-start`, `margin-inline-end` |
| `padding-left`, `padding-right` | `padding-inline-start`, `padding-inline-end` |
| `left`, `right` (absolute position) | `inset-inline-start`, `inset-inline-end` |
| `border-left`, `border-right` | `border-inline-start`, `border-inline-end` |
| `border-top-left-radius` | `border-start-start-radius` |
| `text-align: left`, `right` | `text-align: start`, `end` |

**Style by direction with `:dir(rtl)`**, not `[dir="rtl"] .x` or `:host-context([dir="rtl"])`. A component set to `'ltr'` on an RTL page is still inside `<html dir="rtl">`, so an attribute selector matches it wrongly. `:dir()` matches the direction the element actually lays out in (Chrome 120, Safari 16.4 and Firefox 49 or later):

> [tab] CSS
>
> ```css theme={null}
> /* Matches the direction the icon actually lays out in */
> .my-forward-icon:dir(rtl) {
>   scale: -1 1;
> }
>
> /* Avoid: also matches inside a component set to 'ltr' on an RTL page */
> [dir="rtl"] .my-forward-icon {
>   scale: -1 1;
> }
> ```

**Read the direction from the element** in code, not from `<html>` or the global setting. It is right even when you set the UI Kit's direction with `layoutDirection` and it differs from the page's:

> [tab] TypeScript
>
> ```typescript theme={null}
> const isRtl = getComputedStyle(element).direction === 'rtl';
> ```

**Pass the direction to overlays you open yourself.** The UI Kit's own menus and dialogs carry the direction of the component that opens them. An overlay you attach to `document.body`, such as an Angular CDK overlay, leaves that component's DOM, so copy the direction from the element it opens from. With the CDK, pass it as the overlay's `direction`:

> [tab] TypeScript
>
> ```typescript theme={null}
> import { Component, inject } from '@angular/core';
> import { Overlay } from '@angular/cdk/overlay';
> import type { Direction } from '@angular/cdk/bidi';
>
> @Component({
>   selector: 'app-more-button',
>   standalone: true,
>   template: `<button #anchor (click)="openMenu(anchor)">More</button>`,
> })
> export class MoreButtonComponent {
>   private readonly overlay = inject(Overlay);
>
>   openMenu(anchor: HTMLElement): void {
>     // The direction the button lays out in: from the UI Kit setting, a wrapper or <html dir>.
>     const direction = getComputedStyle(anchor).direction as Direction;
>
>     const overlayRef = this.overlay.create({
>       direction,
>       positionStrategy: this.overlay
>         .position()
>         .flexibleConnectedTo(anchor)
>         .withPositions([{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' }]),
>     });
>     // Attach your menu to overlayRef
>   }
> }
> ```

Or set `dir` on the overlay's pane yourself: `overlayRef.overlayElement.setAttribute('dir', direction)`.

## Languages

The UI Kit ships Arabic (`ar`) translations; regional tags such as `ar-SA` and `ar-EG` use them too. Select it after `init()`:

> [tab] TypeScript
>
> ```typescript theme={null}
> import { CometChatLocalize } from '@cometchat/chat-uikit-angular';
>
> CometChatLocalize.setCurrentLanguage('ar');
> document.documentElement.lang = 'ar';
> document.documentElement.dir = CometChatLocalize.getDirection('ar'); // 'rtl'
> ```

To lay out only the UI Kit right to left without changing your page, leave out the `dir` line and use `setLayoutDirection('rtl')` instead. To change any Arabic string, override it as you would for any other language: see [Global Translation Overrides](https://www.cometchat.com/docs/ui-kit/angular/customization/localization.md#global-translation-overrides).

For another RTL language, such as Hebrew, Persian or Urdu, add it as described in [Adding a New Language](https://www.cometchat.com/docs/ui-kit/angular/customization/localization.md#adding-a-new-language), then set `<html dir="rtl">` or `setLayoutDirection('rtl')`. `CometChatLocalize.getDirection()` already reports `'rtl'` for `he`, `fa` and `ur`.

## Next Steps

> [card] [Localization](https://www.cometchat.com/docs/ui-kit/angular/customization/localization.md)
>
> Set the UI Kit's language and translations

> [card] [Methods](https://www.cometchat.com/docs/ui-kit/angular/methods.md)
>
> UIKitSettingsBuilder and CometChatUIKit reference

> [card] [Theming](https://www.cometchat.com/docs/ui-kit/angular/customization/theming.md)
>
> Colors, fonts and dark mode

> [card] [Troubleshooting](https://www.cometchat.com/docs/ui-kit/angular/troubleshooting.md)
>
> Common RTL questions


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.