Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useTextDirection.md
1---2category: Browser3---45# useTextDirection67Reactive [dir](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) of the element's text.89## Usage1011```ts12import { useTextDirection } from '@vueuse/core'1314const dir = useTextDirection() // Ref<'ltr' | 'rtl' | 'auto'>15```1617By default, it returns `rtl` direction when dir `rtl` is applied to the `html` tag, for example:1819```html20<!--ltr-->21<html>22...23</html>2425<!--rtl-->26<html dir="rtl">27...28</html>29```3031## Options3233```ts34import { useTextDirection } from '@vueuse/core'3536const mode = useTextDirection({37selector: 'body'38}) // Ref<'ltr' | 'rtl' | 'auto'>39```4041## Type Declarations4243```ts44export type UseTextDirectionValue = "ltr" | "rtl" | "auto"45export interface UseTextDirectionOptions extends ConfigurableDocument {46/**47* CSS Selector for the target element applying to48*49* @default 'html'50*/51selector?: string52/**53* Observe `document.querySelector(selector)` changes using MutationObserve54*55* @default false56*/57observe?: boolean58/**59* Initial value60*61* @default 'ltr'62*/63initialValue?: UseTextDirectionValue64}65/**66* Reactive dir of the element's text.67*68* @see https://vueuse.org/useTextDirection69*70* @__NO_SIDE_EFFECTS__71*/72export declare function useTextDirection(73options?: UseTextDirectionOptions,74): WritableComputedRef<UseTextDirectionValue, UseTextDirectionValue>75```76