Skip to content
Discussion options

You must be logged in to vote

All of our components can be "controlled" if you would like to open/close them programmatically.

const [value, setValue] = React.useState('one');

return () => (
  <div>
	{/* Something outside of Accordion that controls the open content */}
    <button onClick={() => setValue('two')}>Open two</button>

    <Accordion.Root type="single" value={value} onValueChange={setValue}>
      <Accordion.Item value="one">
        <Accordion.Header>
          <Accordion.Trigger>One</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>
          Content for one
        <Accordion.Content>
      </Accordion.Item>
      <Accordion.Item value="two">
        <Accordion.Header>
          <

Replies: 5 comments 20 replies

Comment options

You must be logged in to vote
14 replies
@eliuAtFanatics
Comment options

@thanksphil
Comment options

@charpeni
Comment options

@poulch
Comment options

@benjick
Comment options

Answer selected by jjenzz
Comment options

You must be logged in to vote
4 replies
@joaom00
Comment options

@emilioaray-dev
Comment options

@jjenzz
Comment options

@jewel109
Comment options

Comment options

You must be logged in to vote
2 replies
@jjenzz
Comment options

@sigmarsson
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet