Files
heroui-vue/packages/styles/components/menu-item.css
T
maoyingjie 043a5418f3 fix: align Dropdown/Menu with the HeroUI baseline after fidelity audit
- menu-item.css keys disabled styling off the presence attribute Reka emits.
- Dropdown surfaces drive the ported enter/exit animations and use data-side
  for placement-specific motion.
- One role=menu per popup; items render their key as DOM id; submenu surfaces
  point aria-labelledby at the real trigger; MenuSection names its group from a
  nested Header.
- Custom (asChild) triggers stay keyboard focusable; library Button/Avatar keep
  their own layout instead of the custom-trigger rules.
- Items emit data-focused/data-hovered/data-pressed, expose the upstream render
  props to slots, and merge caller classes through tailwind-variants.
- Submenu triggers declare hasSubmenu explicitly and forward class/ARIA; the
  default submenu indicator uses the baseline chevron artwork.
- Demos restore Kbd slot="keyboard" (27x), IconSquarePlus, and remove the added
  comment, stray space and duplicated indicator SVGs.
- Document the page after the official structure and API tables, including
  renamed props, Vue extensions and remaining gaps.
2026-10-24 22:14:10 +08:00

144 lines
3.5 KiB
CSS

/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue adapters. */
/* ==========================================================================
Base menu item styles
========================================================================== */
.hv-menu-item {
@apply relative flex min-h-9 w-full items-center justify-start gap-3 rounded-2xl px-2 py-1.5 outline-none no-highlight;
/**
* Transitions
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
*/
transition:
transform 250ms var(--ease-out-quart),
box-shadow 150ms var(--ease-out);
@apply motion-reduce:transition-none;
/* Cursor */
cursor: var(--cursor-interactive);
[data-slot="label"] {
@apply pointer-events-none w-fit select-none;
}
[data-slot="description"] {
@apply pointer-events-none text-wrap select-none;
}
[data-slot="submenu-indicator"] svg {
@apply size-3.5;
}
/* Add inline-start padding when indicator is present */
&:has(.hv-menu-item__indicator) {
@apply ps-7;
}
/* Add inline-end padding when indicator is present and has submenu */
&[data-has-submenu="true"]:has(.hv-menu-item__indicator) {
@apply ps-2 pe-7;
}
/* Focus visible state (keyboard focus only). */
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply status-focused;
}
/* Pressed state */
&:active,
&[data-pressed="true"] {
@apply will-change-transform;
transform: scale(0.98);
}
/* Hover state */
@media (hover: hover) {
&:hover,
&[data-hovered="true"] {
@apply bg-default;
}
}
/* Selected state */
&[aria-checked="true"],
&[aria-selected="true"],
&[data-selected="true"] {
[data-slot="menu-item-indicator--checkmark"] {
transition: stroke-dashoffset 100ms linear;
@apply motion-reduce:transition-none;
}
[data-slot="menu-item-indicator--dot"] {
@apply scale-100 opacity-100;
}
}
/* Disabled state.
Reka writes a presence attribute (`data-disabled=""`), not `"true"`. */
&[data-disabled] {
@apply status-disabled;
}
}
/* ==========================================================================
Menu item indicator
========================================================================== */
.hv-menu-item__indicator {
@apply absolute start-2 top-1/2 flex size-4 shrink-0 -translate-y-1/2 items-center justify-center text-muted;
@apply transition duration-250 motion-reduce:transition-none;
/* Position on the inline-end when menu item has submenu */
.hv-menu-item[data-has-submenu="true"] & {
@apply start-auto end-2;
}
/* Checkmark SVG indicator */
[data-slot="menu-item-indicator--checkmark"] {
@apply size-2.5;
.hv-menu-item[data-selection-mode="multiple"] & {
@apply transition-all duration-300 motion-reduce:transition-none;
}
}
/* Dot SVG indicator */
[data-slot="menu-item-indicator--dot"] {
@apply size-2;
.hv-menu-item[data-selection-mode="multiple"] & {
@apply transition-all duration-250 motion-reduce:transition-none;
}
@apply scale-70 opacity-0;
}
}
/* Submenu indicator (chevron-right) */
.hv-menu-item__indicator--submenu {
@apply text-muted;
svg {
@apply size-3;
}
}
/* Default variant */
.hv-menu-item--default {
}
/* Danger variant */
.hv-menu-item--danger {
.hv-menu-item__indicator {
@apply text-danger;
}
[data-slot="label"] {
@apply text-danger;
}
}