# useBodyClass Adds one or more CSS classes to `document.body` while the component is mounted, and removes them on unmount. ## Signature ```ts function useBodyClass(className: string): void; ``` | Parameter | Type | Description | | ----------- | -------- | ------------------------------------------------------- | | `className` | `string` | Space-separated class name(s) to add to `document.body` | ## Usage ```tsx export function ModalLayout({ children }: { children: React.ReactNode }) { useBodyClass('overflow-hidden bg-overlay'); return
{children}
; } ``` While `ModalLayout` is mounted, `document.body` will have the classes `overflow-hidden` and `bg-overlay`. Both are removed automatically when the component unmounts. ## Notes - Accepts a space-separated string — multiple classes are handled individually so partial removal is safe. - Re-applies classes if the `className` prop changes. - Client-only (`'use client'`). Does not run during SSR.