useTextDirection

Tags:

A React Hook that helps to get/set the text direction of an element.

Demo

Source
Anim aliqua ad quis aute veniam cillum duis excepteur.
Text direction:
auto

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const [dir, setDir] = useTextDirection(options)

Options

export interface UseTextDirectionOptions { /** * The target element to set the text direction attribute. * * @defaultValue 'html' */ target?: ElementTarget /** * The initial text direction value. * * @defaultValue 'ltr' */ initialValue?: UseTextDirectionValue }

Returns

export type UseTextDirectionReturns = [ /** * The current text direction value. */ dir: UseTextDirectionValue, /** * Sets the text direction value. */ setDir: ReactSetState<UseTextDirectionValue>, ]