Accordion

Description

The Accordion component is a UI component that allows users to dynamically show and hide content by clicking a trigger element. This component uses React context to manage the state of the currently open item.

Usage

Here is some content for Section 1.

Here is some content for Section 1.

Here is some content for Section 1.

Explore more details in Section 2.

Explore more details in Section 2.

Find useful insights in Section 3.


import { Accordion } from "mogora-ui";

export default function AccordionDemo() {
  return (
    <Accordion className="max-w-sm">
      <Accordion.Item value="item-1">
        <Accordion.Trigger>Section 1</Accordion.Trigger>
        <Accordion.Content>
          <p>Here is some content for Section 1.</p>
        </Accordion.Content>
        <Accordion.Content>
          <p>Here is some content for Section 1.</p>
        </Accordion.Content>
        <Accordion.Content>
          <p>Here is some content for Section 1.</p>
        </Accordion.Content>
      </Accordion.Item>
      <Accordion.Item value="item-2">
        <Accordion.Trigger>Section 2</Accordion.Trigger>
        <Accordion.Content>
          <p>Explore more details in Section 2.</p>
        </Accordion.Content>
      </Accordion.Item>
    </Accordion>
  )
}

API Reference

Accordion

The main component that wraps all items in a single accordion group.

PropTypeDescription
classNamestring(Optional) Adds a custom class for styling

Accordion.Item

A component for each item in the accordion.

PropTypeDescription
classNamestring(Optional) Adds a custom class for styling
valuestring | numberA unique value that identifies this item.

Accordion.Trigger

A button component used to open or close the content.

PropTypeDescription
classNamestring(Optional) Adds a custom class for styling

Accordion.Content

A component that contains content that can be expanded or hidden.

PropTypeDescription
classNamestring(Optional) Adds a custom class for styling

Customization

This component uses Tailwind CSS for styling. You can add additional CSS classes through the className prop to customize the appearance as needed.