Skip to content

Commit

Permalink
docs(i18n): update examples with explicit direction (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightjack authored May 17, 2024
1 parent a344018 commit ce1e992
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/content/guides/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ Then in your root Vue file:

```vue
<script setup lang="ts">
import { computed } from 'vue'
import { ConfigProvider } from 'radix-vue'
import { useTextDirection } from '@vueuse/core'
const dir = useTextDirection()
const textDirection = useTextDirection()
const dir = computed(() => textDirection.value === 'rtl' ? 'rtl' : 'ltr')
</script>
<template>
Expand All @@ -73,17 +75,22 @@ To support SSR - when the server has no access to the `html` and its direction,
import { ConfigProvider } from 'radix-vue'
import { useTextDirection } from '@vueuse/core'
const dir = useTextDirection({ initialValue: 'rtl' })
const textDirection = useTextDirection({ initialValue: 'rtl' })
const dir = computed(() => textDirection.value === 'rtl' ? 'rtl' : 'ltr')
</script>
<template>
<template>
<ConfigProvider :dir="dir">
<slot />
</ConfigProvider>
</template>
```

`dir` is a [`Ref`](https://vuejs.org/api/reactivity-core.html#ref), and by changing the value of it to either "ltr" or "rtl", the `dir` attribute on the `html` tag changes as well.
::: info
The `dir` prop doesn't support `auto` as a value, so we need an intermediate Ref to explicitly define the direction.
:::

`textDirection` is a [`Ref`](https://vuejs.org/api/reactivity-core.html#ref), and by changing the value of it to either "ltr" or "rtl", the `dir` attribute on the `html` tag changes as well.

## Internationalization

Expand Down

0 comments on commit ce1e992

Please sign in to comment.