Skip to content

AccordionItem with hover #2434

Answered by wingkwong
hkaya15 asked this question in Help
Mar 2, 2024 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

@hkaya15 There's no onHover. Here's a workaround to use controlled with onMouseOver. However, setSelectedKeys will be called multiple times once you move over on the accordionItem.

accordionitem-onmouseover-demo.webm

Here's the code for your reference. It was modified based on controlled one in docs.

const [selectedKeys, setSelectedKeys] = React.useState<Selection>(new Set(["1"]));
  
return (
  <div className="flex flex-col gap-4">
    <Accordion {...args} selectedKeys={selectedKeys}>
      <AccordionItem
        key="1"
        aria-label="Accordion 1"
        title="Accordion 1"
        onMouseOver={() => setSelectedKeys(new Set("1"))}
      >
        {defaultContent}
      </A…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@hkaya15
Comment options

Answer selected by hkaya15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants