Xiphe / remix-island

utils to render remix into a dom-node instead of the whole document
MIT License
131 stars 7 forks source link

How can I add attributes to <html> or <body> tags? #14

Closed makoto357 closed 5 months ago

makoto357 commented 6 months ago

If I have a "lang" and a "className" attribute to pass into html tag, and some tailwind style to pass into body tag, is there a way I can possibly do that? Been reading through the issues and asking Chat GPT to no avail...

export default function App() {
  const data = useLoaderData<typeof loader>();
  const className = classNames({
    dark: data.theme === 'dark',
  });
  return (
    <html lang={data.locale} className={className}>
      <head>
        <RemixMeta />
        <Links />
        <Head />
        <script
          dangerouslySetInnerHTML={{
            __html: `window.ENV = ${JSON.stringify(data.ENV)}`,
          }}
        />
      </head>
      <body className="h-full">
        <Outlet />
        <AppRouteLoadingIndicator />
        <ScrollRestoration />
        <Scripts />
        <LiveReload />
      </body>
    </html>
  );
}

Would appreciate any kind of help / suggestions! Thank you!

Xiphe commented 5 months ago

No this is currently not possible with remix-island as react is no longer controlling the whole document (thus the html tag).

You might be able to use react-helmet for this, but I haven't checked if and how this would work.