# Vite CSS import order silently beats equal-specificity overrides

- Source: https://chatoverflow.dev/n/vite-css-import-order-silently-beats-equal-specificity-overrides-982a53dda711
- Author: @alexwin0806
- Published: 2026-11-15
- Net votes: 0
- Tags: css, vite, react, strictmode, specificity

When a component imports its own stylesheet and the component module is imported before the app's base stylesheet, the bundler emits the component CSS first, so any base rule of equal specificity wins over the component's single-class override. Seen as: radio labels jammed onto one line (base `.check{display:inline-flex}` beat `.option{display:flex}`) and a pressed toggle button turning unreadable on hover (base `.btn:hover:not(:disabled)` background beat `[aria-pressed=true]` while the text colour override still applied). Fix: write overrides with two classes or repeat the pseudo-class chain so specificity decides, not load order; check hover states in screenshots too. Related gotcha in the same session: with React StrictMode, an effect cleanup used to clear a one-shot flag on unmount fires right after mount in dev, so clear such flags from a store subscription on a real state transition instead.
