# Accordion URL: /react/components/accordion Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/accordion.mdx A component that lists multiple related content sections vertically, allowing users to explore information by expanding or collapsing each section. 사용 가능 버전: @seed-design/react@2.0.0, @seed-design/css@2.0.0 ## Preview ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionPreview() { return (

Content of the first item.

Content of the second item.

Content of the third item.

); } ``` ## Installation - npm: npx @seed-design/cli@latest add ui:accordion - pnpm: pnpm dlx @seed-design/cli@latest add ui:accordion - yarn: yarn dlx @seed-design/cli@latest add ui:accordion - bun: bun x @seed-design/cli@latest add ui:accordion ## Props ### `Accordion` ### `AccordionItem` ### `AccordionTrigger` ### `AccordionContent` ## Examples ### Inline Variant This is the default variant. Items are provided in a continuous flow, with dividers displayed between items. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionInline() { return (

첫 번째 항목의 내용입니다.

두 번째 항목의 내용입니다.

세 번째 항목의 내용입니다.

); } ``` ### Separated When using `variant="separated"`, each item is displayed as a separate card. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionSeparated() { return (

첫 번째 항목의 내용입니다.

두 번째 항목의 내용입니다.

세 번째 항목의 내용입니다.

); } ``` ### Multiple By default, only one item can be expanded at a time. With the `multiple` prop, multiple items can be expanded simultaneously. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionMultiple() { return (

여러 항목을 동시에 펼칠 수 있습니다.

각 항목은 다른 항목과 독립적으로 열고 닫힙니다.

세 번째 항목의 내용입니다.

); } ``` ### Always one open By using the controlled pattern with `values` and `onValuesChange`, you can force always having one item open by adding a guard that prevents calling the setter when an empty array is provided. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; import { useState } from "react"; export default function AccordionControlledRequiredOpen() { const [values, setValues] = useState(["item-1"]); return ( { if (next.length === 0) return; setValues(next); }} >

현재 항목은 다시 눌러도 닫히지 않고, 다른 항목을 선택할 때만 전환됩니다.

평일 오후 2시 이전 주문은 당일 출고되며, 주말 주문은 다음 영업일에 출고됩니다.

수령 후 7일 이내에 교환 또는 반품을 요청할 수 있습니다.

); } ``` ### Size Set the size of the Accordion with `size`. (default: `medium`) `responsive` is a value where the size is automatically switched according to screen width. Use `size=responsive` to support multiple screen widths together in products. ```tsx import { Box, VStack } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionSize() { return ( 항목의 내용입니다. 항목의 내용입니다. 항목의 내용입니다. ); } ``` ### Prefix You can pass prefix elements like icons to the `prefix` prop. ```tsx import { Box, Icon } from "@seed-design/react"; import { IconCardLine, IconQuestionmarkCircleLine, IconTruckLine, } from "@karrotmarket/react-monochrome-icon"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionWithPrefixIcon() { return ( } />} title="배송 방법" />

일반 배송, 빠른 배송, 방문 수령 중 주문 상황에 맞는 방법을 선택할 수 있습니다.

} />} title="결제 및 쿠폰" />

카드, 간편결제, 보유 쿠폰을 한 번에 확인하고 결제에 적용할 수 있습니다.

} />} title="문의와 환불" />

주문 취소 가능 시간, 환불 소요 기간, 고객센터 문의 방법을 확인할 수 있습니다.

); } ``` ### Description You can add additional descriptions to the trigger using the `description` prop. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionWithDescription() { return (

첫 번째 항목의 내용입니다.

두 번째 항목의 내용입니다.

세 번째 항목의 내용입니다.

); } ``` ### Disabled You can disable all or individual items using the `disabled` prop. - Setting `disabled` on `Accordion` disables all items. - Setting `disabled` on `AccordionItem` disables only that item. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionDisabled() { return (

이 항목은 활성화 상태입니다.

이 항목은 비활성화 상태입니다.

이 항목은 활성화 상태입니다.

); } ``` ### Controlled You can directly control the open state using `values` and `onValuesChange`. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; import { useState } from "react"; export default function AccordionControlled() { const [values, setValues] = useState(["item-1"]); return (

첫 번째 항목의 내용입니다.

두 번째 항목의 내용입니다.

세 번째 항목의 내용입니다.

); } ``` ### Value Array Changes In controlled mode, the currently open items are passed as a `values` array. The example below shows the latest `values` and recent `onValuesChange` results each time a trigger is clicked. ```tsx import { Box, Text, VStack } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; import { useState } from "react"; const DEFAULT_VALUES = ["shipping"]; export default function AccordionValueChanges() { const [values, setValues] = useState(DEFAULT_VALUES); const [history, setHistory] = useState([DEFAULT_VALUES]); return ( { setValues(nextValues); setHistory((prev) => [nextValues, ...prev].slice(0, 5)); }} >

빠른 배송, 새벽 배송, 방문 수령 옵션을 비교할 수 있습니다.

카드, 계좌이체, 간편결제 중에서 원하는 결제 수단을 선택할 수 있습니다.

주문 취소 가능 시간과 환불 소요 기간을 확인할 수 있습니다.

values: {JSON.stringify(values)} onValuesChange history: {history.map((snapshot, index) => ( {index + 1}. {JSON.stringify(snapshot)} ))}
); } ``` ### Default Expanded You can specify the initial open state using `defaultValues`. ```tsx import { Box } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionDefaultExpanded() { return (

첫 번째 항목은 기본으로 펼쳐진 상태입니다.

두 번째 항목의 내용입니다.

세 번째 항목의 내용입니다.

); } ``` ### Custom Content `AccordionContent` acts only as an open/close animation container. It does not provide default padding, background color, border, or typography styles, so you must configure them directly in the inner content. The pattern of explicitly providing padding and background with `Box`, as shown in the example below, is recommended. ```tsx import { Box, Text, VStack } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionCustomContent() { return ( 일반 배송 주문 후 영업일 기준 2-3일 내에 배송됩니다. 제주 및 도서산간 지역은 1-2일이 추가 소요될 수 있습니다. 1. 고객센터로 반품/교환 요청 2. 상품 수거 (택배 방문 수거) 3. 검수 후 환불 또는 교환 처리 ); } ``` ## Accessibility Follows the [WAI-ARIA Accordion Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/). `AccordionTrigger` internally creates a `heading > button` structure. The default heading level is `h3`, and if a different level is needed to match the document structure, it can be adjusted using the `headingLevel` prop. The WAI-ARIA APG example also uses `h3` to match the upper section structure. - Pattern: [WAI-ARIA APG Accordion Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) - Example: [WAI-ARIA APG Accordion Example](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/examples/accordion/) ### Heading Level Escape Hatch If a parent section heading already exists, please align the accordion header level using `headingLevel`. For example, if an accordion is placed inside an `h3` section, you can maintain the document outline by lowering each item header to `h4`. ```tsx import { Box, Text, VStack } from "@seed-design/react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "seed-design/ui/accordion"; export default function AccordionHeadingLevel() { return ( 주문 도움말

배송 관련 세부 내용은 h4 heading 아래의 accordion section으로 제공할 수 있습니다.

); } ``` ### Keyboard Interactions | Key | Action | | ----------------- | ---------------------------------------------------------------------------- | | `Enter` / `Space` | Expands or collapses the panel of the focused trigger. | | `Tab` | Moves to the next focusable element. | | `Shift + Tab` | Moves to the previous focusable element. | | `ArrowDown` | Moves focus to the next trigger. Cycles to the first if at the end. | | `ArrowUp` | Moves focus to the previous trigger. Cycles to the last if at the beginning. | | `Home` | Moves focus to the first trigger. | | `End` | Moves focus to the last trigger. |