--- name: DocumentElement ---
npm install @c4605/react-document-element---
name: DocumentElement
---
import { useState } from 'react'
import { Playground, Props } from 'docz'
import { DocumentElement, _DocumentElementInner } from './src/DocumentElement'
Provides a declarative way to specify document.documentElement attributes in a single-page app.
This component can be used on server side (but won't produce any effect).
Built with React Side Effect.
Inspired by React Document Title.
- Can be defined in many places throughout the application;
- Supports arbitrary levels of nesting, so you can set app-wide and page-specific
class name or style to document.documentElement;
- Works just as well with isomorphic apps.
{() => {
const [color, changeColor] = useState('blue')
return (
style={{ '--font-color': 'black' }}
>