How to make react-aria's Item
works with @emotion/react
?
#5605
-
Hi everyone, I have a question regarding using react-aria's type CustomItemProps = ItemProps & {
className?: string
}
export const CustomItem = Item as (props: CustomItemProps) => JSX.Element Here's how I'm using it. import { Menu } from '@my-component-library/menu';
import { css } from '@emotion/react';
<Menu>
<CustomItem css={{ color: 'red' }}>Item 1</CustomItem>
<CustomItem css={{ padding: '8px' }}>Item 2</CustomItem>
</Menu> However, the snippet above fails to run with the Does anyone happen to know a good solution to this issue? Thank you in advance for your help. 🙇 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Is this menu built with React Aria? If the latter, I'd suggest switching over to React Aria Components, classname is supported there so using frameworks like Tailwind and presumably And just to elaborate on your |
Beta Was this translation helpful? Give feedback.
Oh I see, so you aren't actually rendering anything extra in your
CustomItem
, Emotion CSS is autogenerating a wrapper element, my mistake. If that is the case, I'm not sure much can be done unfortunately, our old collection API is pretty strict about consuming elements withgetCollectionNode
only, that lack of wrapper support is actually a big reason why we've pushed for the new collections api for React Aria Components.