Open kbabbitt opened 5 months ago
Thanks for bringing this topic back again and providing a different approach to it!
Just a quick note, @rachelandrew, @tantek and I discussed a way forward for gap decorations as well in a breakout session at last year's F2F meeting in Cupertino. Unfortunately, I never actually took the time to write down our conclusions for a level 1 of this feature. So I take this opportunity to do that now and also comment on your proposal. What we concluded back then was (Rachel, Tantek, please correct me if I'm misremembering!):
column-rule
row-rule
and the related longhands as a complement to column-rule
and its longhandsRegarding your proposal, here a few quick thoughts after skimming through the explainer and the draft spec:
*-rule-*
properties are important. (Just to note, they were mentioned before.)gap-rule
shorthand (as mentioned in the explainer).Sebastian
Thank you for writing this proposal @kbabbitt and thank you for the great response @SebastianZ. I previously wrote a much more simplistic / undetailed proposal in #9482.
This is, in my opinion, one of the most glaringly missing and needed features of CSS in 2024, in the sense that there is no good workaround (even gap
was easier to "polyfill" with negative margin on the container and positive margin on children). I really hope this gets picked up and prioritized, and will gladly help in any way I can.
Thank you @SebastianZ and @benface for the comments and support!
Re: Gap decoration areas and varying decorations - I agree they add a lot of complexity, and I could see moving them out of level 1 because we can still solve a lot of use cases without them. Beyond that, it sounds like the explainer is largely in alignment with what was discussed at the Cupertino F2F.
Tagging to discuss briefly at next week's F2F - I'd love to get more thoughts on the direction and opinions on what should be in and out of scope for level 1.
Really happy to see this, and very much in favor. It does seem well aligned to what we have discussed previously. I do think reducing this to the simplest form for a L1 is a good idea, it will solve most of the use cases I see (most of the asks are pretty simple) then we can see what rises to the top in terms of developer needs.
Agreed on pursuing this, and on scoping it more narrowly for L1. Wrt alternating borders, I would much rather see the row/col pseudos move forward than bake the pattern into the syntax for these properties.
Wrt alternating borders, I would much rather see the row/col pseudos move forward than bake the pattern into the syntax for these properties.
Thanks for this suggestion, capturing links to a couple of discussions I found on this for reference, @LeaVerou please let me know if there's others I missed: #1943, #8352
I think this proposal looks really good! So the proposal, skeleton'd, is:
row-rule
to accompany column-rule
main-rule
and cross-rule
for Flexbox (personally I'd prefer to just use row-rule and column-rule)*-rule
to accept /
-separated values, which it'll cycle between as it paints the rulesgrid-row/col-rule-area
, which takes a comma-separated list of grid areas, letting you style different segments of the rule. the row/col-rule
props also accept a comma-separated list, to match up with that list. (Presumably, Flexbox/Masonry could also have their own ways to declare areas, which would match up with the *-rule
properties in the same way.)The third/fourth bullet points are required to match the usability of table borders, presumably, which makes sense to me. In many cases where you want to style something like a table you should be using a table, but that's not always appropriate; calendar, for example, probably can't use tables since there can be overlapping entries.
We will need rules for determining who "wins" for rules bordering two areas, or if you define overlapping areas. I suggest that later areas win. (We lack the hierarchy of table elements that tables have, which let us make reasonable assumptions about which element should win when there's a conflict.)
The logical equivalents to the -rule- properties are important. (Just to note, https://github.com/w3c/csswg-drafts/issues/6748#issuecomment-1036109018 before.)
They're already logical; "row" and "column" are logical terms, see Flexbox and Grid. (And, for that matter, Multicol, where column rules are always block-axis aligned.)
The mix of slashes and commas in the syntaxes needs to be discussed, especially in regard of a possible gap-rule shorthand (as mentioned in the explainer).
Yes, we need to be careful with this. In general we want to minimize the use of slashes; they tend to be confusing, especially when mixed with commas. (We're consistent with which separator wins wrt grouping, and this proposal follows that practice, but still.) Maybe we can do a cycling function or something to make it more obvious.
(personally I'd prefer to just use row-rule and column-rule)
Me too. There is no main-gap
or cross-gap
property, so I don't think we need main-rule
or cross-rule
either.
In many cases where you want to style something like a table you should be using a table, but that's not always appropriate; calendar, for example, probably can't use tables since there can be overlapping entries.
Off topic, but sounds like what we'd really need for a calendar is #4416, since rendering multiple elements in the same grid cell would currently make them overlap instead of placing them one after the other.
In many cases where you want to style something like a table you should be using a table, but that's not always appropriate; calendar, for example, probably can't use tables since there can be overlapping entries.
Off topic, but sounds like what we'd really need for a calendar is #4416, since rendering multiple elements in the same grid cell would currently make them overlap instead of placing them one after the other.
That use case is also discussed in #1183, but yeah, off-topic.
Sebastian
+1 on this for me
The CSS Working Group just discussed Proposal: CSS Gap Decorations Level 1
, and agreed to the following:
RESOLVED: import the draft with shortname css-gaps and title CSS Gap Decorations with kbabbitt as editor.
It's great to see this proposal progressing. I just wanted to share our use case for this at the BBC, in case it's helpful.
The BBC News front page in the UK has a CSS grid of cards linking to articles. (International visitors can still see a similar design on the BBC Sport front page.)
You can see how only the cards that don't include a picture have a top border. But the top border is not a desirable design because it's not in the gap between grid cells. So this proposal would allow us to achieve the originally intended design where there would be a grey divider in the centre of the above gap.
However, we wouldn't want a continuous line across the entire row gap. I've not seen anyone discuss the proposed row-rule-outset
property in the Explainer document. It would allow us to still have the desired design where the grey divider line is only above the cells and doesn't enter the column gaps.
@JoshTumath thanks for that example. One question - in a world with gap decorations, would you also want to draw lines in the gaps between cards with pictures? In other words - is the lack of lines above pictures in your example part of the intended design, or is it something that happened because you're using borders as a workaround?
The reason I ask is to inform prioritization for gap decoration areas.
@JoshTumath thanks for that example. One question - in a world with gap decorations, would you also want to draw lines in the gaps between cards with pictures? In other words - is the lack of lines above pictures in your example part of the intended design, or is it something that happened because you're using borders as a workaround?
I've just spoken to the UX Designer who originally created that layout pattern. The lack of lines in the column gap is an intentional part of the design.
It may also be desirable to have the gap decoration aligned to the edge of the gap so that it's touching the cell, rather than being centred in the gap.
Explainer
This is a fresh take on a topic that has been brought up previously in discussions such as #2748 and #6748. Authors have long been asking for ways to paint gap decorations in grids and other containers.
Why a new proposal?
The core of this proposal is similar to ones we've seen previously: We introduce
row-rule-width
,row-rule-style
, androw-rule-color
as complements tocolumn-rule-width
,column-rule-style
, andcolumn-rule-color
and apply both sets of properties to grid, flex, and masonry containers. But one reason for the fresh take is to address use cases such as this one that call for varying gap decorations over a single container, or a subregion of a container. To do that, I've drawn inspiration from grid area syntax and the parallel lists + list cycling behavior in CSS Transitions and Animations to allow things like:Applying to the specific use case I cited above:
Responsive layout
Another use case I hadn't seen addressed before is responsive flex layout. This proposal also introduces a set of logical properties to help with these cases:
main-rule-*
andcross-rule-*
which map torow-rule-*
orcolumn-rule-*
depending on flex direction.What about gap images?
Gap decoration images is definitely something I'd like to explore. However, as pointed out in this comment, gap decoration images have much more complex definition needs than border images, and there are several use cases cited in #2748 that can be addressed without the use of images. So I've left them to a future level for now.
There is also a skeleton spec as a companion to the explainer. So far it's mostly a place where I've parked notes about grammar details - there are a lot of details still to be fleshed out.
I would welcome any comments/suggestions/additional use cases, either in this thread or as issues in the MSEdgeExplainers repo: New issue
cc @alisonmaher @KurtCattiSchmidt @ethanjv @oSamDavis @bfgeek @tabatkins