question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Styles root, body vs. html

See original GitHub issue

Is your feature request related to a problem? Please describe. Theme UI root element is body which, for most use cases works fine. There are although some times when you really need to apply styles to to html tag.

One of these uses cases is when dealing with rem units (which are relative the root html). So rem units currently do not work with Theme UI.

It would be nice to have a way to target the html tag somehow.

Describe the solution you’d like Creating a version of <Global /> with Theme UI capabilities could be useful.

I’ll be working on something like that on one of my projects. We could potentially package it for the library.

I was thinking of a component inside the provider with an instance of Emotion <Global /> onto which we could inject a part of the Theme Context.

Additional context I’d love to know what you guys think about something like this and if you’ve experienced similar issues.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
atanasstercommented, Jan 13, 2021

@fcisio i think you can start here https://github.com/system-ui/theme-ui/blob/90b7c10b2c2533c0126c9e12787997c67778eb39/packages/color-modes/src/custom-properties.ts#L72

You will also need to update the theme typescript types and add some tests.

i will be happy to help out on your PR, i should be back home by Monday.

not sure what @hasparus had in mind with the comments?

0reactions
hasparuscommented, Feb 15, 2021

Can we close this? @fcisio

Read more comments on GitHub >

github_iconTop Results From Across the Web

All vs root vs html vs body selectors. - Timonwa's Notes
As I said earlier it is better to give styles to the body element than the html element because the body element covers...
Read more >
What's the difference between CSS3's :root pseudo class and ...
One technical difference between them is that :root - being a pseudo class has a greater specificity than html (a type selector).
Read more >
What's the difference between :root and html in CSS?
This is because :root is a pseudo-class selector, while html is a type selector.
Read more >
HTML vs Body in CSS
The spec defines <html> as the root element of a document, and we can clearly ... So we should always put global styles...
Read more >
root - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
In HTML, :root represents the <html> element and is identical to the selector html , except that its specificity is higher.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found