Skip to main content

Accordion

An accordion is a collapsible content component that allows users to expand and collapse sections of content. It's commonly used to organize information into manageable sections, improving the user experience by reducing visual clutter.

The accordion is a compound component composed of Root, Item, Header, and Content subcomponents.

Accordion Collapsed

Accordion Expanded

Usage

Example
import type { NubeSDK } from "@tiendanube/nube-sdk-types";
import { Accordion, Text } from "@tiendanube/nube-sdk-jsx";

function MyComponent() {
return (
<Accordion.Root defaultValue="shipping-info">
<Accordion.Item value="shipping-info">
<Accordion.Header showIcon>Shipping Information</Accordion.Header>
<Accordion.Content>
<Text>Free shipping on orders over $50</Text>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="return-policy">
<Accordion.Header showIcon>Return Policy</Accordion.Header>
<Accordion.Content>
<Text>30-day return policy for all items</Text>
</Accordion.Content>
</Accordion.Item>
</Accordion.Root>
);
}

export function App(nube: NubeSDK) {
nube.send("ui:slot:set", () => ({
ui: {
slots: {
after_line_items: <MyComponent />,
},
},
}));
}

Subcomponents

Accordion.Root

The root container that manages the accordion state.

PropertyTypeRequiredDescription
childrenNubeChildrenComponentNoAccordion items to be rendered.
defaultValuestringNoDefault expanded item value.
styleStyleSheetNoCustom styles for the accordion root.
idstringNoOptional unique identifier for the component.

Accordion.Item

Individual accordion item container.

PropertyTypeRequiredDescription
childrenNubeChildrenComponentNoHeader and content components.
valuestringYesUnique value to identify the accordion item.
idstringNoOptional unique identifier for the component.
styleStyleSheetNoCustom styles for the accordion item.

Accordion.Header

The clickable header that toggles the accordion item.

PropertyTypeRequiredDescription
childrenstringNoText content of the header.
showIconbooleanNoWhether to show expand/collapse icon.
styleStyleSheetNoCustom styles for the header.

Accordion.Content

The collapsible content area of the accordion item.

PropertyTypeRequiredDescription
childrenNubeChildrenComponentNoContent to be displayed when item is expanded.
styleStyleSheetNoCustom styles for the content area.