Styling Guide
Monochrome is headless — no CSS is shipped. You provide all styles and control the visual appearance completely.Philosophy
The library handles:- ARIA attribute management
- Keyboard navigation
- Focus management
- State coordination
- Visual design
- Layout
- Animations
- Theming
Required CSS for Menus
Menu components require specific CSS to function correctly. The core sets CSS custom properties viagetBoundingClientRect() that you must use for positioning.
Popover Visibility
Menu Positioning
The core sets--bottom, --left, --top, and --right custom properties on menu popovers:
Submenu Positioning
Safety Triangle (Submenu Hover Intent)
When a submenu is open, Monochrome creates a triangular safe zone so users can move diagonally to the submenu without accidentally closing it. The core sets a[data-safe] attribute on the Group element along with CSS custom properties:
--left— triangle point X coordinate--center— triangle point Y coordinate (cursor Y)--right— submenu edge X coordinate--top— submenu top edge--bottom— submenu bottom edge
Example Safety Triangle CSS
The safety triangle updates on every
pointermove event, following the cursor to maintain a smooth diagonal path to the submenu.Styling Component States
All component state is reflected in ARIA attributes. Style based on these attributes:Accordion
Tabs
Menu Items
Hidden Content
Monochrome useshidden="until-found" instead of display: none to preserve browser find-in-page (Cmd+F / Ctrl+F).
When users search with Cmd+F and the browser finds hidden content, a
beforematch event fires. Monochrome’s core listens for this and automatically opens the containing component.Focus Styles
Monochrome manages focus automatically. Provide visible focus indicators:Animations
Add animations by observing ARIA attribute changes:Responsive Styling
All components work on mobile. Consider touch-friendly sizes:Best Practices
- Never use
display: none— it breaks find-in-page. Monochrome useshidden="until-found"by default. - Style ARIA attributes —
aria-expanded,aria-selected,aria-checkedreflect component state. - Maintain spacing — The 8px
margin-lefton submenus is required for direction detection. - Provide focus indicators — Keyboard users need visible focus states.
- Test with keyboard — Navigate with Arrow keys, Home, End, Enter, Space, Escape.
- Support high contrast — Use
currentColorand semantic colors that adapt to system themes.