Skip to main content

Overview

Languages such as Arabic are read right to left. In an RTL layout, the UI Kit mirrors its components: avatars, names, buttons, message bubbles, menus and sheets 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 numbers keep their order inside the text around them.
  • Audio players and code blocks stay left to right, as they do in every RTL app.

Layout Direction and Language

Layout direction and language are two separate settings: By default the UI Kit follows the app’s direction. 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 app’s direction (default)

With the default value, "auto", the UI Kit uses the direction the app is already in (I18nManager.isRTL). If your app switches to RTL for an RTL language with React Native’s I18nManager, the UI Kit follows with no extra code:
Set the UI Kit’s language to Arabic with CometChatI18nProvider. See Localize.

Set it for the whole UI Kit

Pass layoutDirection in UIKitSettings to give every UI Kit component a fixed direction, whatever the app’s direction. It needs no I18nManager.forceRTL and no restart, and your own screens are not affected:

Change it at runtime

Use CometChatUIKit.setLayoutDirection to change the direction while the app is running, for example from a settings screen:
The new direction applies to UI Kit components created after the change. Components that stay mounted (open screens, tab screens, screens on the back stack) can show a mix of the old and new direction, so remount the UI Kit screens after changing it, for example by changing a key on your navigator. init() applies layoutDirection only when you pass it, so a direction you set with setLayoutDirection before init() is kept.

Set It Per Component

The screen components take a layoutDirection prop. It overrides the global setting for that component and everything inside it, including the sheets, menus and dialogs it opens:
Leave it unset to inherit the direction from the UI Kit component around it, or from the global setting. These components take layoutDirection:
The ongoing-call screen (Ongoing Call) is drawn by the Calls SDK and doesn’t follow layoutDirection.

Which Setting Wins

When settings disagree, the first rule that gives a direction wins:
  1. Audio players 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 app’s own direction (I18nManager.isRTL).
Don’t wrap a UI Kit component in a view with a direction style to change its direction: that mirrors the layout but not the icons or text inputs, and a global "ltr" or "rtl" ignores it. To force one component’s direction, use its layoutDirection prop.

App Screens Outside the UI Kit

The UI Kit never changes your app’s direction. With a global "ltr" or "rtl", the UI Kit’s components follow it but your own screens stay as they are. To give one of your screens the same direction, set direction on its root view:
To mirror the whole app, use I18nManager.forceRTL(true) and restart, and leave the UI Kit on "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, sheets, swipe actions, tooltips and loading skeletons. Sent messages sit on the left and received messages on the right. Swipe to reply goes the other way. Horizontal lists, such as emoji and sticker tabs and the attachment tray, start from the right.

Icons

Icons you pass into the UI Kit are drawn as you give them.

What doesn’t mirror

  • Audio players, including voice notes, the audio recorder and the attachment tray’s audio tile: playback controls, waveforms and progress bars stay left to right in every language. The times use the language’s digits.
  • Video plays in the system player, whose controls follow the phone’s own direction rules.
  • Code: inline code and code blocks, in chat messages and in AI assistant replies, always read 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. A message with digits but no letters (123 + 456 = 579) reads left to right, unless it contains a mention. A message of only emoji follows the bubble.
  • Names and mentions keep their place. A user’s name can’t scramble the sentence around it, and a mention always reads @name. Invisible direction-control characters are removed from names, so a name can’t reverse the text after it.
  • Links, email addresses and phone numbers read left to right.
  • Numbers and dates. When the UI Kit’s language is Arabic, the dates, times and counts it formats use Arabic digits (٠١٢٣٤٥٦٧٨٩) and Arabic plural forms. Text you supply yourself, for example from a datePattern callback, is shown as given.

Message composer

  • The text follows the language you type: English starts at the left, Arabic at the right.
  • In an empty composer, the cursor sits on the side of the keyboard’s language: English keyboard on the left, Arabic keyboard on the right. This uses a native module added in UI Kit 5.7.0, so rebuild the app after upgrading (pod install and an Xcode build on iOS, a Gradle build on Android). On Expo, use a development build; Expo Go doesn’t include the module. Without it, the cursor sits at the start edge.

Custom Views in RTL

Views you pass into the UI Kit (view slots, custom message templates, custom bubbles) are placed inside the component’s direction. Use start/end styles so they mirror with the rest of the UI Kit: When a view needs to know the direction itself, for example to choose an icon, read it with useCometChatLayoutDirection() instead of I18nManager.isRTL. It returns the direction of the UI Kit content around your view, so it is right even when you set the UI Kit’s direction with layoutDirection and it differs from the app’s:

Languages

The UI Kit ships Arabic translations. For another RTL language, such as Hebrew, Persian or Urdu, add it with CometChatI18nProvider as described in Localize, then make the app RTL with I18nManager or set layoutDirection: "rtl".

Next Steps

Localize

Set the UI Kit’s language and translations

Methods

UIKitSettings and CometChatUIKit reference

Theme

Colors, typography and styles

Troubleshooting

Common RTL questions