Skip to content

Recessive CSS rules #6859

@janosh

Description

@janosh

Describe the problem

Every CSS rule applied internally to a component that you want to override from the outside with global CSS requires the !important keyword. See REPL.

Describe the proposed solution

Recessive CSS rules, i.e. rules with lowest possible specificity no matter with what selector they were set with inside the component.

Not sure what's the word to use here. Just using recessive in the style of genes where the dominant allele is the one expressed in the phenotype while recessive alleles are masked.

Such rules could be placed inside a special scope (similar to :root {}) or perhaps applied through a class with a special keyword so the svelte compiler knows to apply these rules with low specificity.

Alternatives considered

Creating CSS variables for every CSS rule in a component gets old fast. Plus changing these CSS props is quite verbose. E.g. to specify just four colors:

<MultiSelect
  --sms-options-bg="white"
  --sms-li-active-bg="cornflowerblue"
  --sms-li-disabled-bg="gray"
  --sms-readonly-bg="lightgray" />

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions