Skip to content

fix: keep the theme root from affecting layout - #2693

Open
SnowingFox wants to merge 1 commit into
rainbow-me:mainfrom
SnowingFox:fix/theme-root-layout
Open

fix: keep the theme root from affecting layout#2693
SnowingFox wants to merge 1 commit into
rainbow-me:mainfrom
SnowingFox:fix/theme-root-layout

Conversation

@SnowingFox

Copy link
Copy Markdown

Problem

RainbowKitProvider injects a theme-root <div data-rk> wrapper around its children so its scoped theme CSS variables can be applied. Because that injected <div> is an unstyled block element, it participates in layout: a full-height page that relies on height: 100% (or flex) stretching no longer fills the screen, since the extra wrapper breaks the height chain.

See #2164

Root cause

The theme root is rendered as a plain <div {...createThemeRootProps(id)}> with no layout behavior. It generates a normal block box, so children that depend on height: 100% stretching no longer fill their parent.

Fix

Give the theme-root wrapper style={{ display: 'contents' }}. The element no longer generates a layout box, so children render exactly as if the wrapper were not there, while the data-rk attribute is preserved. The scoped theme still works because the [data-rk] selector only sets CSS custom properties (via cssObjectFromTheme/assignInlineVars), which are inherited by children regardless of the wrapper's box.

Test

Adds a component test (RainbowKitProvider.test.tsx) that renders the provider and asserts the injected theme-root element still carries the data-rk attribute and has display: contents, so it cannot affect layout. The test fails on the previous behavior (the wrapper is a plain block <div>) and passes with the fix.

Fixes #2164

@SnowingFox
SnowingFox requested a review from a team as a code owner August 11, 2026 16:42
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@SnowingFox is attempting to deploy a commit to the rainbowdotme Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

馃 Changeset detected

Latest commit: 50dd957

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@rainbow-me/rainbowkit Patch
example Patch
@rainbow-me/rainbow-button Patch
rainbowkit-next-app Patch
site Patch
with-create-react-app Patch
with-next-app-i18n Patch
with-next-app Patch
with-next-custom-button Patch
with-next-mint-nft Patch
with-next-siwe-iron-session Patch
with-next-siwe-next-auth Patch
with-next-wallet-button Patch
with-next Patch
with-react-router Patch
with-remix Patch
with-vite Patch
with-next-rainbow-button Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

[bug] Provider affects the DOM

1 participant