Skip to content

Commit a97b874

Browse files
authored
fix MenuSection in RAC Tailwind starter (#7508)
1 parent a71fbed commit a97b874

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

starters/tailwind/src/Menu.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import {
55
MenuItem as AriaMenuItem,
66
MenuProps as AriaMenuProps,
77
MenuItemProps,
8+
MenuSection as AriaMenuSection,
9+
MenuSectionProps as AriaMenuSectionProps,
810
Separator,
911
SeparatorProps,
10-
composeRenderProps
12+
composeRenderProps,
13+
Header,
14+
Collection
1115
} from 'react-aria-components';
12-
import { DropdownSection, DropdownSectionProps, dropdownItemStyles } from './ListBox';
16+
import { dropdownItemStyles } from './ListBox';
1317
import { Popover, PopoverProps } from './Popover';
1418

1519
interface MenuProps<T> extends AriaMenuProps<T> {
@@ -48,6 +52,18 @@ export function MenuSeparator(props: SeparatorProps) {
4852
return <Separator {...props} className="mx-3 my-1 border-b border-gray-300 dark:border-zinc-700" />
4953
}
5054

51-
export function MenuSection<T extends object>(props: DropdownSectionProps<T>) {
52-
return <DropdownSection {...props} />;
55+
export interface MenuSectionProps<T> extends AriaMenuSectionProps<T> {
56+
title?: string
57+
items?: any
58+
}
59+
60+
export function MenuSection<T extends object>(props: MenuSectionProps<T>) {
61+
return (
62+
<AriaMenuSection className="first:-mt-[5px] after:content-[''] after:block after:h-[5px]">
63+
<Header className="text-sm font-semibold text-gray-500 dark:text-zinc-300 px-4 py-1 truncate sticky -top-[5px] -mt-px -mx-1 z-10 bg-gray-100/60 dark:bg-zinc-700/60 backdrop-blur-md supports-[-moz-appearance:none]:bg-gray-100 border-y dark:border-y-zinc-700 [&+*]:mt-1">{props.title}</Header>
64+
<Collection items={props.items}>
65+
{props.children}
66+
</Collection>
67+
</AriaMenuSection>
68+
)
5369
}

0 commit comments

Comments
 (0)