Skip to content

Feature proposal: children variant #277

@benface

Description

@benface

The idea would be to be able to do things like this:

Input CSS

@variants children {
    .block { ... }
}

Output CSS

.children:block > * { display: block; }
.block { display: block; }

Note: All children: variants would need to be output before the normal rule-sets so children can override rules defined by their parent (.class and .class > * have the same specificity).

HTML

<div class="children:block children:my-1">
    <a>
        I am a block with some vertical margin
    </a>
    <a>
        Me too
    </a>
    <a class="mb-0">
        I don't have bottom margin
    </a>
</div>

Advantages

  • Less repetition in the HTML (easier to change things that should be changed together)
  • Easier to read
  • Smaller HTML file size

I think this would be particularly useful for grids and lists. What do you think?

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