mui / mui/base-ui

[menu] Add `data-label` attribute to menu items

Open
#1,816 0 comments 0 reactions 0 assignees View on GitHub
component: menu type: enhancement
Dominant language
TypeScript
Stars
10.9k
Forks
543
Avg merge
1d 20h
Merged PRs (30d)
101

Description

# Feature request

## Summary

It could be useful for different reasons to add a `data-label` attribute to the element that `Menu.Item` (or `Menu.CheckboxItem` or `Menu.RadioItem`) renders:

- Easily inspect how Base UI converts `children` into a string label (when `label` is not set), e.g. for debugging purposes.
- Write custom search/filtering functionality in the menu (this is what I'm trying to do).
- Maybe even style a specific menu item from an ancestor that doesn't control the rendering of individual items (though it would be a fragile selector).

## Examples in other libraries

N/A

## Motivation

See above. Thank you!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.