Skip to content

Handle css rules specificity #223

Open
@ingro

Description

@ingro

Hello, I have a problem using nano-css in combination with global pre-existing styles.

For example:

/* style.css */
.myapp button {
  font-size: inherit;
}

Then I create a button with jsx:

const Button = jsx('button', {
  fontSize: '24px'
});

Which generates a random class name for my button component. Problem is, due to css rules specificity the global rule is more specific than the one generated for the component and so the custom font-size is ignored.

Other css-in-js handled that problem with a custom namespace that could be added to every class, like this one for stylis.

It could be possible to implement something like that for nano-css? Maybe it could be enough to just allow to pass a custom stylis instance to the stylis addon, which could also be useful for other reasons.

Thank you.

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