FG
๐ŸŒ Web & Full-Stack

Support !important for styles?

Freshover 6 years ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

We currently don't support `!important` as it has to be set using `style.setProperty(name, value, priority)`. This should be trivially easy to implement if it's something want to support, although I'm not sure about the performance implications (EDIT: #1886), although I can't imagine it would be measurable as we would be doing the string test ourselves and those are cheap. http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration ~~OK... apparently IE8 doesn't support this _at all_, it might still be worth implementing, for the future and for those who don't care about IE8.~~ ~~After further experimentation, apparently it is! `style.setAttribute(name, value)` (priority is part of the value).~~ But apparently that was wrong as well, the only way to set it seems to be with `cssText`, an acceptable work-around may be to just use `cssText` when we detect an `!important` style, which should be seldom enough that performance is a non-issue. An important consideration is that we _already_ support this for the initial render, but subsequent updates will _fail_ as `!important` isn't recognized for properties.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
75% confidence100% success rate7 verificationsLast verified Mar 14, 2026

Solution: Support !important for styles?

Low Risk

Any word on the progress of this? I'm using react in a widget and a browser extension that work on third party sites and not being able to update !important styles is an issue for me

75

Trust Score

7 verifications

100% success
  1. 1

    Any word on the progress of this? I'm using react in a widget and a browser exte

    Any word on the progress of this? I'm using react in a widget and a browser extension that work on third party sites and not being able to update !important styles is an issue for me

Validation

Resolved in facebook/react GitHub issue #1881. Community reactions: 31 upvotes.

Verification Summary

Worked: 7
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

reactjavascriptresolution:-wontfixtype:-feature-requestcomponent:-dom