Skip to content

feat: new setting +rootAttributes - #229

Open
nitedani wants to merge 3 commits into
mainfrom
claude/html-tags-attributes-setting-ljv9nc
Open

nitedani wants to merge 3 commits into
mainfrom
claude/html-tags-attributes-setting-ljv9nc

Conversation

@nitedani

@nitedani nitedani commented Sep 18, 2026

Copy link
Copy Markdown
Member

Implements the +rootAttributes setting requested in vikejs/vike#3513: it adds attributes to the root element <div id="root">.

// pages/+config.ts
export default {
  // <div id="root" role="none">
  rootAttributes: { role: 'none' },
}

Semantics

Same as +htmlAttributes and +bodyAttributes:

No default value: the root element stays <div id="root"> unless the app sets something. The id attribute isn't validated: overriding it is the user's responsibility (hydration then fails).

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01MdJwhUKSfXPVuSvXyxBpr7

…over the ones set by Vike extensions

For cumulative settings, `getHeadSetting()` returned the values in the order Vike provides them (most specific value first, values set by Vike extensions last) followed by the values set by `useConfig()`, and the tag attributes were merged in that order with the last value winning upon conflict. Consequently, upon conflict, a value set by a Vike extension would override the app's value, and a value set by `+config.js` would override the value set by `+htmlAttributes.js`.

`getHeadSetting()` now returns the values of cumulative settings sorted by increasing precedence (values set by Vike extensions first, the app's most specific value last, then the values set by `useConfig()`), so that merging them in order yields the value with the highest precedence. Values set by `useConfig()` keep the highest precedence.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MdJwhUKSfXPVuSvXyxBpr7
Adds attributes to the root element `<div id="root">`, e.g. `rootAttributes: { role: 'none' }`.

Same semantics as `+htmlAttributes` and `+bodyAttributes`: server-only (not re-applied upon client-side navigation), global, cumulative (for Vike extensions, the app's values taking precedence), value or `(pageContext) => value`, and settable via `useConfig()`.

The `id` attribute isn't validated: overriding it is the user's responsibility.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MdJwhUKSfXPVuSvXyxBpr7
@nitedani
nitedani force-pushed the claude/tag-attributes-precedence-ljv9nc branch from 42eac6c to 5efce2f Compare September 19, 2026 07:10
@nitedani
nitedani force-pushed the claude/html-tags-attributes-setting-ljv9nc branch from 4ba27ac to c8e5d10 Compare September 19, 2026 07:10
Base automatically changed from claude/tag-attributes-precedence-ljv9nc to main September 19, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants