vike-react icon indicating copy to clipboard operation
vike-react copied to clipboard

Need a way to add html attributes to the root `<html>` element

Open loteoo opened this issue 1 year ago • 4 comments

First of all, thank you for this great library!

I'm creating this issue to share a hiccup I ran into. I'm using the Mantine-UI library and for the dark mode / light mode to work properly, you need a way to add a data-mantine-color-scheme html attribute to the root HTML element.

Currently, there is no way to manage this with the Head component to modify the html element.

Maybe a solution could look like this:

const Head: React.FC = () => {
  return (
    <>
      <html my-custom-attribute="foo" />
    </>
  )
}

Thank you!

loteoo avatar Apr 10 '24 20:04 loteoo

Yes, that's very much on the radar. It's actually something I plan to start implementing today. Depending on how things go, the ETA could be as early as this week — let's see.

In the meantime, you can eject or patch vike-react (it's quite small like 500 LoC).

brillout avatar Apr 11 '24 06:04 brillout

I'll probably be able to make a pre-release today.

brillout avatar Apr 11 '24 08:04 brillout

Woah! Amazing, let me know if I can help! And no rush! :) ❤️

loteoo avatar Apr 11 '24 22:04 loteoo

Turns out there is a blocker in Vike core for this, so it's going to take a little longer. (Thanks for sponsoring!)

brillout avatar Apr 12 '24 13:04 brillout

https://vike.dev/htmlAttributes

brillout avatar Aug 12 '24 15:08 brillout

Let us know if anything doesn't work for your use case. We look forward to gathering feedback on the new improvements to head tag management.

brillout avatar Aug 12 '24 17:08 brillout

Amazing, thank you!

loteoo avatar Aug 13 '24 20:08 loteoo