Template Direction

The Crema template is fully RTL-supported. On one toggle button, the user can switch between "Right to Left" direction and the "Left to Right" direction.

Changing Template Direction in run time:-

Click on the Settings button on the right corner of the screen just below the notification icon, a drawer will open in which you will find the RTL support toggle button. By using that button, you can enable or disable RTL support.

Changing RTL support in development mode (setting default RTL type):-

To set the default RTL type, go to the defaultConfig.js file, which can be found at the path:-

In this file, you will find a property named 'direction'. You need to set the value of 'direction' according to your choice from the accepted values like below in libs/constants/src/defaultConfig.js.

export const defaultTheme = {
  theme: {
    ...,
    direction: LayoutDirection.RTL, // You can switch theme direction here
    palette: {...}
  }
}

####### Layout Direction #########(libs/constants/src/AppEnums.js)

export const LayoutDirection = {
  RTL: 'rtl',
  LTR: 'ltr',
};j

Since some languages are read from 'Right to Left', so whenever that language is chosen, the template direction changes to 'Right to Left'. This is managed by the property name "rtlLocale". This property can be found in the libs/constants/src/defaultConfig.js file. It takes an array as the value and language codes for which RTL is to be enabled can be passed in it.

const defaultConfig = {
  ...,
  locale: {
    languageId: 'english',
    locale: 'en',
    name: 'English',
    icon: 'us',
  },
  rtlLocale: ['ar'],
};

Currently, 'ar' which has been used for the Arabic language in the Crema has been passed in the array which means whenever the Arabic language is chosen, RTL will be enabled. Similarly, you can pass any other language locale code in the array to enable RTL on the selection of that language.

Last updated