State Variables
Change CSS variables to reflect UI state — open/closed sidebars, active nav items — instead of toggling many classes.
Change CSS variables to reflect UI state — open/closed sidebars, active nav items — instead of toggling many classes.
.sidebar { --w: 240px; width: var(--w); transition: width 0.3s; }
.sidebar.collapsed { --w: 60px; }
.nav-item[aria-current="page"] { --bg: var(--primary-light); background: var(--bg); }
One variable change can update multiple properties at once across the component.