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

Theme reset is not applied to <body> tag #661

Open
ijxy opened this issue Dec 30, 2024 · 1 comment
Open

Theme reset is not applied to <body> tag #661

ijxy opened this issue Dec 30, 2024 · 1 comment

Comments

@ijxy
Copy link

ijxy commented Dec 30, 2024

The styles.css file includes the below snippet, which should reset the margin on <body>:

.rt-reset:where(body, blockquote, dl, dd, figure, p) {
  margin: 0;
}

Expectation

The above snippet would apply to the <body> and set margin to 0, when the app is set up in the suggested manner:

import "@radix-ui/themes/styles.css"

import { Theme } from "@radix-ui/themes";

export default function () {
  return (
    <html>
      <body>
        <Theme>
          <MyApp />
        </Theme>
      </body>
    </html>
  );
}

Actual outcome

The <body> has default browser margins, ie the reset is not applied.

image

Workaround

It seems to behave as I expect if I wrap the body with <Reset>, but this feels like a hack.

import "@radix-ui/themes/styles.css"

import { Reset, Theme } from "@radix-ui/themes";

export default function () {
  return (
    <html>
      <Reset>
        <body>
          <Theme>
            <MyApp />
          </Theme>
        </body>
      </Reset>
    </html>
  );
}

Is this the intended way to apply the CSS reset to <body>?

@mwskwong
Copy link

mwskwong commented Jan 2, 2025

Currently, <Reset> basically adds a CSS class .rt-rest to the wrapped component. The CSS reset ONLY applies if the corresponding component has this class. Therefore, technically speaking, the behavior mentioned here is by design.

However, I would much prefer the reset be done globally, e.g. instead of

.rt-reset:where(body, blockquote, dl, dd, figure, p) {
  margin: 0;
}

it would be just

body,
blockquote,
dl,
dd,
figure,
p {
  margin: 0;
}

@ijxy ijxy changed the title Theme reset is not applied to <body> tag using the Theme reset is not applied to <body> tag Jan 3, 2025
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

No branches or pull requests

2 participants