Reka UI logoReka
backdrop
Utilities

Config Provider

Wraps your app to provide global configurations.
  • Enables all primitives to inherit global reading direction.
  • Enables changing the behavior of scroll body when setting body lock.
  • Much more controls to prevent layout shifts.
  • Translates the labels the primitives give to assistive technology.

Anatomy

Import the component.

vue
<script setup lang="ts">
import { ConfigProvider } from 'reka-ui'
</script>

<template>
  <ConfigProvider>
    <slot />
  </ConfigProvider>
</template>

API Reference

Config Provider

When creating localized apps that require right-to-left (RTL) reading direction, you need to wrap your application with the ConfigProvider component to ensure all of the primitives adjust their behavior based on the dir prop.

You can also change the global behavior of bodylock for components such as Alert, DropdownMenu and etc to fit your layout to prevent any content shifts.

Example

Use the config provider.

Set global direction to rtl, and scroll body behavior to false (will not set any padding/margin).

By default, the scrollbar width is added to the body's own right padding while scroll is locked, and the body's margin is left alone. Both are put back as they were when the lock is released. Pass an object such as { padding: 20 } or { margin: true } to choose what is set: true adds the scrollbar width to the existing value, a number is in pixels, and a string is used as written. { margin: true } on its own moves the compensation to the margin and leaves the padding alone; set padding as well to change both.

vue
<script setup lang="ts">
import { ConfigProvider } from 'reka-ui'
</script>

<template>
  <ConfigProvider
    dir="rtl"
    :scroll-body="false"
  >
    <slot />
  </ConfigProvider>
</template>

Translations

Some primitives give assistive technology text of their own, such as the aria-label of PaginationNext. It is English by default. Pass translations to replace it, by key. Keys that are left out keep the built-in text.

vue
<script setup lang="ts">
import { ConfigProvider } from 'reka-ui'
</script>

<template>
  <ConfigProvider
    :translations="{
      paginationPrev: 'Vorherige Seite',
      paginationNext: 'Nächste Seite',
      paginationPage: 'Seite {page}',
    }"
  >
    <slot />
  </ConfigProvider>
</template>

See Translating built-in labels for every key and its default.

Hydration issue

ConfigProvider can accept a custom useId function for frameworks that need to provide their own SSR-stable ID source. Reka UI uses this function before Vue's native useId, so every primitive that generates accessibility IDs follows the same app-provided source.

This is useful in Nuxt projects where prerendered HTML and client hydration can use different Vue app ID prefixes. Pass Nuxt's useId through ConfigProvider so Reka-generated IDs stay stable across server and client rendering.

Inspired by Headless UI

vue
<!-- in Nuxt's app.vue -->
<script setup lang="ts">
import { ConfigProvider } from 'reka-ui'

const useIdFunction = () => useId()
</script>

<template>
  <ConfigProvider :use-id="useIdFunction">
    …
  </ConfigProvider>
</template>