Skip to content

fix(menu): align slotted icon sizing and layout with Material 3 specs - #151

Merged
treeder merged 3 commits into
mainfrom
fix_slotted_menu_icons
Oct 14, 2026
Merged

treeder merged 3 commits into
mainfrom
fix_slotted_menu_icons

Conversation

@treeder

@treeder treeder commented Oct 14, 2026

Copy link
Copy Markdown
Member

Summary

Aligns menu item icon sizing, slot constraints, item gap, and container height with the official Material 3 Menus Specification. Previously, icons defaulted to 24px instead of 20px, and arbitrary slotted content (such as avatars, images, or SVGs) could expand unconstrained beyond the standard bounding box.

Key Changes

  • Icon Sizing & Slot Bounding:
    • Changed --md-menu-item-icon-size fallback and token values to 20px across both baseline and expressive vertical variants.
    • Enforced a strict 20px x 20px bounding box (width, height, min/max-width, min/max-height, flex-shrink: 0) on [slot='start'] and [slot='end'].
    • Added box-sizing: border-box, object-fit: contain, max-width, and max-height to ::slotted(*).
    • Added object-fit: cover and border-radius: inherit for ::slotted(img) so custom avatars and profile images maintain their aspect ratio and circular clipping.
    • Added optical sizing font-variation-settings: 'opsz' 20 to ::slotted(md-icon).
  • Layout Spacing & Height:
    • Updated --md-menu-item-between-space from 12px to 8px per the spec diagram.
    • Updated single-line item container height to 48px.
  • Demos & Documentation:
    • Updated token reference tables in menu/README.md.
    • Added a demo card to demo/menu-demo.html showcasing slotted standard icons, avatars (<img>), and SVG graphics strictly constrained to 20px.

Verification

  • Formatted files with Prettier.
  • Verified layout rules in demo/menu-demo.html.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-slotted-menu-icons-material.treeder.workers.dev (commit 357275a)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://401d6014-material.treeder.workers.dev 357275a 2026-10-14T05:49:32.628Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ad2f6d92-material.treeder.workers.dev cb32de3 2026-10-14T05:40:09.384Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f2889f98-material.treeder.workers.dev 1c66ec2 2026-10-14T05:36:39.168Z Visit the dashboard ↗

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This pull request refines Material Design 3 menu item metrics and icon handling across md-menu and md-menu-item, adjusting container height to 48px, horizontal padding to 12px, item gap to 8px, and enforcing 20px icon sizing across slotted icons, images, and SVGs. In addition, it updates the documentation and menu demo page to demonstrate slotted avatars, icons, and SVGs.

🔍 General Feedback

  • Standardising the menu item dimensions (48px height, 12px horizontal padding, 8px gap) and capping slotted icons/images to 20px aligns nicely with the Material Design 3 menu specifications.
  • The new slotted icons and avatars section in demo/menu-demo.html is a great showcase of the containment behavior.
📊 Token Usage & Cost Efficiency
Metric Value
Input Tokens (uncached) 43,114
Input Tokens (cached) 418,560 (⚡ 90.7% cached)
Thinking / Reasoning Tokens 87
Output Tokens 459
Total Session Tokens 462,220
Cost (uncached input) $0.0323
Cost (cached input) $0.0314
Cost (thinking / reasoning) $0.0003
Cost (response output) $0.0017
Estimated Total Cost $0.0658

Gemini 3.8 Flash: introductory rate $0.75/$3.75 per 1M applied; reverts to $1.5/$7.5 after 2026-12-31.
Gemini 3.8 Flash: standard tier; batch and flex are half again, priority is higher.
Cache reads are priced here, but context-cache STORAGE, where the model charges for it separately per token-hour, is not included, so the figure can run slightly low.

Comment thread menu/menu-item.js Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This pull request refines Material 3 menu styling and specifications across the codebase, updating the standard item height to 48px, horizontal padding to 12px, element gap to 8px, and icon sizing to 20px in both vertical and baseline modes. Documentation and demos have been updated accordingly, including a new showcase for slotted icons, avatars, and SVGs. While the containment rules on slotted elements work well, applying fixed dimensions directly to the slot elements causes unpopulated leading and trailing slots to reserve empty 20px boxes, which introduces layout regressions for text-only items and select options.

✅ Resolved Items from Prior Reviews

  • Removed hard-coded font-variation-settings: 'opsz' 20 on slotted md-icon elements so that other standard Material Symbols font variation axes (such as FILL, wght, and GRAD) remain intact. (menu/menu-item.js:156)

🔍 General Feedback

  • Updating the M3 menu specs to 48px item height, 12px padding, and 8px gap aligns the implementation cleanly with the latest Material 3 Expressive guidelines.
  • The new slotted icons and avatars demo section in demo/menu-demo.html is a great addition for validating SVG graphics, standard icons, and circular avatar images.
  • Ensure all components reusing menuItemStyles (such as <md-select-option>) are regression-tested when altering default menu item dimensions.
📊 Token Usage & Cost Efficiency
Metric Value
Input Tokens (uncached) 43,070
Input Tokens (cached) 418,560 (⚡ 90.5% cached)
PR Comments History Tokens 799
Thinking / Reasoning Tokens 46,251
Output Tokens 826
Total Session Tokens 509,506
Cost (uncached input) $0.0329
Cost (cached input) $0.0314
Cost (thinking / reasoning) $0.1734
Cost (response output) $0.0031
Estimated Total Cost $0.2408

Gemini 3.8 Flash: introductory rate $0.75/$3.75 per 1M applied; reverts to $1.5/$7.5 after 2026-12-31.
Gemini 3.8 Flash: standard tier; batch and flex are half again, priority is higher.
Cache reads are priced here, but context-cache STORAGE, where the model charges for it separately per token-hour, is not included, so the figure can run slightly low.

Comment thread menu/menu-item.js Outdated
Comment thread menu/menu-item.js Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This pull request refines Material 3 menu item specifications and slotted icon styling to align with the updated design tokens. It standardises menu item heights to 48px, adjusts element spacing to 8px, and ensures 20px icon containment for slotted icons, SVGs, and avatars across both vertical and baseline variants. In addition, the documentation and interactive demo have been updated to demonstrate slotted media containment.

✅ Resolved Items from Prior Reviews

  • Removed hard-coded font-variation-settings on slotted md-icon elements to preserve custom font variation axes such as FILL and wght. (menu/menu-item.js:156)
  • Removed fixed dimensions from [slot='start'] so that items without leading icons do not display an empty 20px indent. (menu/menu-item.js:168)
  • Removed fixed dimensions from [slot='end'] so that items without trailing icons or indicators render flush without reserved blank space. (menu/menu-item.js:181)

🔍 General Feedback

  • Applying width, height, max-width, and max-height constraints to :is([slot='start'], [slot='end'])::slotted(*) ensures that custom slotted images, avatars, and SVGs are consistently contained within the 20px spec bounding box without breaking layout alignment.
  • The synchronised updates across tokens in menu.js, styling in menu-item.js, documentation in menu/README.md, and demo examples in demo/menu-demo.html maintain excellent project consistency.
📊 Token Usage & Cost Efficiency
Metric Value
Input Tokens (uncached) 42,123
Input Tokens (cached) 418,560 (⚡ 90.5% cached)
PR Comments History Tokens 1,814
Thinking / Reasoning Tokens 3,752
Output Tokens 412
Total Session Tokens 466,661
Cost (uncached input) $0.0330
Cost (cached input) $0.0314
Cost (thinking / reasoning) $0.0141
Cost (response output) $0.0015
Estimated Total Cost $0.0800

Gemini 3.8 Flash: introductory rate $0.75/$3.75 per 1M applied; reverts to $1.5/$7.5 after 2026-12-31.
Gemini 3.8 Flash: standard tier; batch and flex are half again, priority is higher.
Cache reads are priced here, but context-cache STORAGE, where the model charges for it separately per token-hour, is not included, so the figure can run slightly low.

@treeder
treeder merged commit 67f40b9 into main Oct 14, 2026
2 checks passed
@treeder
treeder deleted the fix_slotted_menu_icons branch October 14, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant