Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs(i18n): update examples with explicit direction #928

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading