Files
Andreas Reinhold / reiniandClaude Opus 5 2f8fb2183f Draw the menu group without Tailwind
<x-menu-group> renders data-md-menu-group with data-md-gap and no
class list; menu-group.css draws the plain cluster's 4px padding and
the gapped Expressive layout's 2px item gap and 8px cluster margin
from SegmentedMenuTokens (plan step 36, actions).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
2026-09-14 16:08:25 +02:00

48 lines
2.0 KiB
PHP

{{-- A group of items in an `<x-menu>`, labelled ("Sort by", "Share with"), set apart by a gap, or
both.
M3 Expressive gives a menu two ways to break its items into clusters, and they are not
interchangeable:
- `<x-menu-separator />`, a line. M3: "dividers are more subtle and are the right choice for
scrollable menus or text-field dropdowns", and "on web, use dividers to separate items".
The default answer, and the only one for a menu long enough to scroll.
- `<x-menu-group gap>`, the Expressive "Grouped" layout: no line, a gap. M3: "gaps are the
more expressive way to separate item clusters" but "limit to one or two gaps per menu",
"don't vary gap size", and "never use gaps in a scrollable menu" (unsupported).
A gapped cluster sets its items 2px apart (SegmentedMenuTokens.SegmentedGap = 2dp) and holds
them in a box of their own, so the two ends of the cluster round the way the ends of a whole
list round and each cluster reads as one block. Clusters stand 8px apart, the same 8px a
separator keeps above and below its line, so a menu is the same height whichever it uses.
SegmentedMenuTokens' own GroupShape is 8dp where the library's list ends are 12dp; the
library's shape wins, so a cluster's ends and a list's ends match.
Drawn by resources/css/components/menu-group.css from `data-md-gap`. --}}
@props([
'label' => null,
'gap' => false,
])
@php
$attributes = $attributes->merge(array_filter([
'data-md-menu-group' => true,
'data-md-gap' => $gap ? true : null,
'role' => 'group',
'aria-label' => filled($label) ? $label : null,
], fn ($value): bool => $value !== null));
@endphp
<div {{ $attributes }}>
@if (filled($label))
<div data-md-menu-group-label aria-hidden="true">{{ $label }}</div>
@endif
@if ($gap)
<div data-md-menu-group-items>{{ $slot }}</div>
@else
{{ $slot }}
@endif
</div>