useTextDirection

Manage RTL/LTR text direction based on the active language for consent UI.

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

ParameterTypeDefaultDescription
languagestring | undefinedBCP 47 language tag (e.g. 'en', 'ar', 'he')

Return Value

TypeDescription
'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.