Skip to content

Add a snapping threshold to CSS grid alignment and justification #14186

Description

@scottkellum

Problem

There are times when items within a grid are sized similarly, leaving small gaps, and other times when the gaps are much larger. In instances where there are small gaps it would look better to fill them using the stretch keyword, but where the gaps are wide, it would look better to use an alignment keyword like start or center.

Image

Proposal

One possible solution would be to add a snap function that holds an alignment keyword and a threshold. When the whitespace around the grid items is less than or equal to the threshold, then it renders as stretch instead of the keyword value.

.grid {
  align-items: snap(start, 4rem);
}

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