When using values and onValuesChange with a controlled pattern, you can ensure that one item is always open by adding a guard that prevents the setter from being called when an empty array is received.
Loading Lynx example…
Preparing URL…
import "./styles";import { useState } from "@lynx-js/react";import { Box, Text, useSeedClassName } from "@seed-design/lynx-react";import { Accordion, AccordionContent, AccordionItem, AccordionTrigger,} from "@/components/ui/accordion";export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [values, setValues] = useState<string[]>(["item-1"]); function handleValuesChange(nextValues: string[]) { "background only"; if (nextValues.length === 0) return; setValues(nextValues); } return ( <view className={`${seedClassName} docs-lynx-accordion-root`}> <Accordion values={values} onValuesChange={handleValuesChange}> <AccordionItem value="item-1"> <AccordionTrigger title="주문 전 확인 사항" /> <AccordionContent> <Box p="x4"> <Text textStyle="t4Regular"> 현재 항목은 다시 눌러도 닫히지 않고, 다른 항목을 선택할 때만 전환됩니다. </Text> </Box> </AccordionContent> </AccordionItem> <AccordionItem value="item-2"> <AccordionTrigger title="배송 일정" /> <AccordionContent> <Box p="x4"> <Text textStyle="t4Regular"> 평일 오후 2시 이전 주문은 당일 출고되며, 주말 주문은 다음 영업일에 출고됩니다. </Text> </Box> </AccordionContent> </AccordionItem> <AccordionItem value="item-3"> <AccordionTrigger title="교환 및 반품" /> <AccordionContent> <Box p="x4"> <Text textStyle="t4Regular"> 수령 후 7일 이내에 교환 또는 반품을 요청할 수 있습니다. </Text> </Box> </AccordionContent> </AccordionItem> </Accordion> </view> );}
Set the size of the Accordion using size. (default: medium)
Lynx supports medium and large. The responsive option that automatically changes based on screen width is not supported, so you should select one of the two values based on screen width in your app if needed.
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 the trigger is clicked.
Loading Lynx example…
Preparing URL…
import "./styles";import { useState } from "@lynx-js/react";import { Box, HStack, Text, VStack, useSeedClassName } from "@seed-design/lynx-react";import { Accordion, AccordionContent, AccordionItem, AccordionTrigger,} from "@/components/ui/accordion";const DEFAULT_VALUES = ["shipping"];export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [values, setValues] = useState<string[]>(DEFAULT_VALUES); const [history, setHistory] = useState<string[][]>([DEFAULT_VALUES]); function handleValuesChange(nextValues: string[]) { "background only"; setValues(nextValues); setHistory((previous) => [nextValues, ...previous].slice(0, 5)); } return ( <view className={`${seedClassName} docs-lynx-accordion-root`}> <HStack className="accordion-preview__value-changes" gap="x6" align="flexStart"> <Box flexGrow width="full" minWidth="0"> <Accordion multiple values={values} onValuesChange={handleValuesChange}> <AccordionItem value="shipping"> <AccordionTrigger title="배송 옵션" /> <AccordionContent> <Box p="x4"> <Text textStyle="t4Regular"> 빠른 배송, 새벽 배송, 방문 수령 옵션을 비교할 수 있습니다. </Text> </Box> </AccordionContent> </AccordionItem> <AccordionItem value="payment"> <AccordionTrigger title="결제 수단" /> <AccordionContent> <Box p="x4"> <Text textStyle="t4Regular"> 카드, 계좌이체, 간편결제 중에서 원하는 결제 수단을 선택할 수 있습니다. </Text> </Box> </AccordionContent> </AccordionItem> <AccordionItem value="refund"> <AccordionTrigger title="환불 정책" /> <AccordionContent> <Box p="x4"> <Text textStyle="t4Regular"> 주문 취소 가능 시간과 환불 소요 기간을 확인할 수 있습니다. </Text> </Box> </AccordionContent> </AccordionItem> </Accordion> </Box> <Box className="accordion-preview__history" p="x4" bg="bg.layerBasement" borderRadius="r2" borderWidth={1} borderColor="stroke.neutralWeak" > <VStack gap="x2" align="stretch"> <Text textStyle="t3Medium">values: {JSON.stringify(values)}</Text> <Text textStyle="t3Medium">onValuesChange history:</Text> {history.map((snapshot, index) => ( <Text key={`${snapshot.join(",") || "empty"}-${index}`} textStyle="t4Regular"> {index + 1}. {JSON.stringify(snapshot)} </Text> ))} </VStack> </Box> </HStack> </view> );}
AccordionContent serves only as an open/close animation container. It does not provide default padding, background color, borders, or typography styles, so you must configure these directly in the internal content. We recommend the pattern of explicitly providing padding and background using Box as shown in the example below.
Loading Lynx example…
Preparing URL…
import "./styles";import { Box, Text, VStack, useSeedClassName } from "@seed-design/lynx-react";import { Accordion, AccordionContent, AccordionItem, AccordionTrigger,} from "@/components/ui/accordion";export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( <view className={`${seedClassName} docs-lynx-accordion-root`}> <Accordion> <AccordionItem value="item-1"> <AccordionTrigger title="배송 안내" description="배송 정책 및 예상 소요 시간" /> <AccordionContent> <Box p="x4"> <Box p="x4" borderRadius="r3" bg="bg.layerBasement"> <VStack gap="x3" align="stretch"> <VStack gap="x1" align="stretch"> <Text textStyle="t5Bold">일반 배송</Text> <Text textStyle="t5Regular">주문 후 영업일 기준 2-3일 내에 배송됩니다.</Text> </VStack> <Box p="x3" borderRadius="r2" bg="bg.layerDefault"> <Text textStyle="t4Regular" color="fg.neutralSubtle"> 제주 및 도서산간 지역은 1-2일이 추가 소요될 수 있습니다. </Text> </Box> </VStack> </Box> </Box> </AccordionContent> </AccordionItem> <AccordionItem value="item-2"> <AccordionTrigger title="반품 및 교환" description="반품/교환 절차 안내" /> <AccordionContent> <Box p="x4"> <Box p="x4" borderRadius="r3" bg="bg.layerBasement"> <VStack gap="x2" align="stretch"> <Text textStyle="t5Regular">1. 고객센터로 반품/교환 요청</Text> <Text textStyle="t5Regular">2. 상품 수거 (택배 방문 수거)</Text> <Text textStyle="t5Regular">3. 검수 후 환불 또는 교환 처리</Text> </VStack> </Box> </Box> </AccordionContent> </AccordionItem> </Accordion> </view> );}
The Lynx Accordion has the following differences from the React version.
Native elements: Renders Lynx <view> and <text> instead of HTML heading, button, and region.
Interaction: Opens and closes items via the Trigger's native tap event instead of keyboard navigation.
Accessibility: Uses accessibility-heading, accessibility-role-description, and accessibility-value instead of DOM ARIA.
Responsive size: Lynx preset does not support viewport media queries, so size="responsive" is not provided.
Content transition: The React version passes height via CSS custom property, while the Lynx version measures content height with layoutchange and applies transitions with the same duration and easing.