Skip to content

Separate explicitly ordered stylesheets for reliable override behavior #26

@lewisl9029

Description

@lewisl9029

At the very least we'll need separate stylesheets for media queries to override other styles, as they have 0 extra specificity. May also want a separate stylesheet for shorthands so that we can place non-shorthands after and have them always override.

As a last resort we can ask users to apply !important which isn't the end of the world as it's easy enough to reason about because we'd still only have 2 levels of specificity.

Can also add some api to apply some vanity class to raise specificity of certain selectors for overriding:

className={useStyles({ padding: '8px' }) + useStyles({ 'padding-top': '16px' }, { increaseSpecificityBy: 1 })}

Can translate to:

className={"r_somehash r_s r_someotherhash"}

With the following css injected:

.r_somehash {
  padding: 8px;
}

.r_s.r_someotherhash {
  padding: 16px;
}

(With specificity of 2+, we can chain more .r_s classes like .r_s.r_s.r_s.r_someotherhash)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions