Context
Entity reference field items are hard to tell apart.
Same problem, different markup: Increase space between book navigation links (theme site). In both cases the space between two items is about the same as the space between the wrapped lines of one item, so you can't tell where one item ends.
Current list variations
Computed styles in mantra_starter, measured at a 16px font size:
| Source | Markup | Line height | Gap between items | Indent | List margin |
|---|---|---|---|---|---|
Prose: lists in .text-formatted |
ul/ol |
1.75 | 8px | 26px + 6px | 20px |
Item list (core item_list, Views lists) |
div.item-list > ul.item-list__list |
1 | 8px | 16 / 20px | 0 (wrapper has my-4) |
| Item list inside prose | same | 1.75 (picks up prose values) | 8px | 26 + 6px | 0 |
list_items SDC |
ul.list_items |
1 / 1.25 / 1.5, set by a prop | 0 | 16 / 20px | 16px (browser default) |
Plain list: book nav ul.menu-tree, any list with no class |
ul |
1 | 0 | 16px | 16px |
| Multi-value fields, including reference fields | div.field__items > div.field__item |
1.5 | 4px | none, no markers | 0 |
Inline: ul.links.inline, comma lists |
ul |
1.25 | separators | — | — |
- Book navigation:
libraries/global/base/elements.csssets the "compact" list values (line height 1) on:root.variables.cssloads first (weight -1), so compact quietly became the site default. With line height 1 and no gap, a wrapped title is as close to its own second line as to the next item. - Reference fields: line height 1.5 leaves about 8px between the lines of a wrapped title, and items are only 4px further apart than that (
component/field.css,.25rem). No markers either. - Variables are tangled:
--list-line-heightis set to 1.5 invariables.css, then overridden to 1.--list-default-*exists only so.text-formattedcan undo that override.--list-ol-style: discis never used, and would be wrong for anol.list_itemsdefines its own--item-list-line-height.field.cssandviews.cssuse hard-coded rem values.
Ideas
Rule for every variant: the gap between items must clearly exceed the spacing between the wrapped lines of one item.
-
Five variants:
- prose: unchanged; the UnoCSS typography preset already reads
--list-*. - default: markers, line height about 1.3, gap of at least 0.5em.
- compact: denser, for sidebars and tables.
- plain: same spacing as default, no markers or indent (reference fields).
- inline: comma lists and inline links.
Columns and nested markers (circle, square / lower-alpha, lower-roman) are separate options that apply to any variant.
- prose: unchanged; the UnoCSS typography preset already reads
- One set of variables per variant:
--list-line-height,--list-item-gap,--list-indent,--list-margin-block,--list-marker. One shared stylesheet reads them; a variant class only sets them. Delete the:rootoverride inelements.cssand the--list-default-*/--list-compact-*layers. - Unclassed lists get the default variant. This fixes the book navigation with no template change, along with every other stray list.
-
Render all lists through
list_items. Replace itsline_height: 1|2|3prop with avariantprop. Route the other sources through it:item-list.html.twig(commalist_style→ inline);views-view-list.html.twig;- a
book-tree.html.twigoverride (list_itemsalready supports nestedbelowitems); - multi-value reference fields, through a field template suggestion (variant plain) rather than per-display Fences settings.
Nested markers move from
list_items.cssinto the shared stylesheet so every list gets them.
TODO
- [ ] Steps 2–3: variables and the default variant for unclassed lists. Resolves the book navigation issue.
- [ ] Field template suggestion for multi-value reference fields. Resolves this task.
- [ ] Add the
variantprop tolist_items; move item lists, Views lists and the book tree onto it. - [ ] Update
/ui-examples/item_lists(mantra_examples/src/ItemListExamples.php): it describes--item-list-line-heightand an adjacent-sibling margin rule as part ofitem-list.css, and that file no longer contains either. - [ ]
ddev theme build, commitdist/, checkcontrib(task pages) andtheme(/ui-examples/item_lists,list_itemsstories).