Skip to content

useTextDirection

类别
导出大小
809 B
最近修改
2 days ago

元素文本的反应性dir

🌐 Reactive dir of the element's text.

示例

This paragraph is in English and correctly goes left to right.


Click to change the direction

用法

🌐 Usage

ts
import { 
useTextDirection
} from '@vueuse/core'
const
dir
=
useTextDirection
() // Ref<'ltr' | 'rtl' | 'auto'>

默认情况下,当对 html 标签应用 rtl 方向时,它会返回 rtl 方向,例如:

🌐 By default, it returns rtl direction when dir rtl is applied to the html tag, for example:

html
<!--ltr-->
<html>
  ...
</html>

<!--rtl-->
<html dir="rtl">
  ...
</html>

选项

🌐 Options

ts
import { 
useTextDirection
} from '@vueuse/core'
const
mode
=
useTextDirection
({
selector
: 'body'
}) // Ref<'ltr' | 'rtl' | 'auto'>