useTextDirection
useTextDirection() determines the correct text direction ('ltr' or 'rtl') based on the provided language and sets it on the document. It wraps the @c15t/ui text direction utilities as a React hook.
This is used internally by IAB components but is available for custom UI that needs to handle bidirectional text.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
language | string | undefined | — | BCP 47 language tag (e.g. 'en', 'ar', 'he') |
Return Value
| Type | Description |
|---|---|
'ltr' | 'rtl' | The text direction for the given language |
RTL Languages
The hook recognizes standard RTL languages including Arabic (ar), Hebrew (he), Persian (fa), and Urdu (ur), among others.