Use our React Accordion
component to allow the user to show and hide sections of related content on a page. There are many ways to use this component, like displaying a list of FAQs, showing various menus and submenus, displaying the locations of a particular company, and so on.
See below our Accordion
component examples that you can use in your Tailwind CSS and React project. The examples comes in different styles and colors, so you can adapt it easily to your needs.
Here's how to implement a simple and responsive Accordion
component. It can be used for FAQs in your website.
You can set all the Accordion
items to be open by default by passing an array of values to the defaultValue
prop.
The Accordion
component could be either controlled or uncontrolled. In the controlled mode, you can manage the state of the Accordion
component by yourself. You can use the value
and onValueChange
props to control the state of the Accordion
component.
You can customize the Accordion
trigger icon by using the Accordion.Trigger
component. To make it work, you need to use group-data-[open=true]
for the icons to show/hide based on the Accordion
state.
You can customize the Accordion
component by using the className
prop. In the example below, we've showcased how to create a custom style for the Accordion
component.
You can disable the Accordion
item by adding the disabled
prop. This will prevent the user from interacting with the Accordion
item.