#2794·vitepress

Disable automatically set direction in `<html>`

Author: qmhcCreated Aug 16, 2023Updated Sep 15, 2026
Labelsthemecontribution welcomestale

Is your feature request related to a problem? Please describe.

If the direction of <html> is set dynamically via some js scripts in runtime, since the route path changed, this attribute (dir) will be override to 'ltr'.

Describe the solution you'd like

User can disable this behavior.

For example, user can specify dir: false to effect above.

Describe alternatives you've considered

Now I'm using below workaround:

typescript
watch(() => router.route.path, syncVitepressDir)

function syncVitepressDir() {
  site.value.dir = isRtl.value ? 'rtl' : 'ltr'

  if (isClient) {
    document.documentElement.dir = site.value.dir
  }
}

But the dir attribute of <html> will be set to 'ltr' then set to 'rtl' in every time the route path changed.

Additional context

No response

Validations