@lattice-ui/accordion Part of the stable direction toward v1.0.
What It Is For
Use Accordion when the screen needs progressive disclosure without leaving the current layout.
It is a headless compound component, so you own the trigger visuals, spacing, and motion while the package owns open-state coordination.
import { Accordion } from "@lattice-ui/accordion";
import React from "@rbxts/react";
export function AccordionExample() {
const [value, setValue] = React.useState<string | string[]>("general");
return (
<frame BackgroundTransparency={1} Size={UDim2.fromOffset(720, 260)}>
<Accordion.Root
collapsible
onValueChange={setValue}
type="single"
value={value}
>
<frame BackgroundTransparency={1} Size={UDim2.fromOffset(720, 220)}>
<uilistlayout
FillDirection={Enum.FillDirection.Vertical}
Padding={new UDim(0, 10)}
/>
{[
[
"general",
"General settings stay visible inside the current layout.",
],
[
"privacy",
"Privacy controls can expand without opening a separate screen.",
],
].map(([itemValue, description]) => (
<Accordion.Item asChild key={itemValue} value={itemValue}>
<frame
BackgroundTransparency={1}
Size={UDim2.fromOffset(720, 92)}
>
<Accordion.Header asChild>
<frame
BackgroundTransparency={1}
Size={UDim2.fromOffset(720, 36)}
>
<Accordion.Trigger asChild>
<textbutton
AutoButtonColor={false}
BackgroundColor3={Color3.fromRGB(34, 41, 54)}
BorderSizePixel={0}
Size={UDim2.fromOffset(720, 36)}
Text={itemValue}
TextColor3={Color3.fromRGB(236, 240, 248)}
TextSize={16}
TextXAlignment={Enum.TextXAlignment.Left}
>
<uicorner CornerRadius={new UDim(0, 8)} />
<uipadding PaddingLeft={new UDim(0, 12)} />
</textbutton>
</Accordion.Trigger>
</frame>
</Accordion.Header>
<Accordion.Content asChild>
<textlabel
BackgroundTransparency={1}
Position={UDim2.fromOffset(12, 48)}
Size={UDim2.fromOffset(690, 32)}
Text={description}
TextColor3={Color3.fromRGB(172, 181, 196)}
TextSize={14}
TextWrapped={true}
TextXAlignment={Enum.TextXAlignment.Left}
TextYAlignment={Enum.TextYAlignment.Top}
/>
</Accordion.Content>
</frame>
</Accordion.Item>
))}
</frame>
</Accordion.Root>
</frame>
);
} Live demo is experimental and may contain bugs.
Install
Global CLI command: lattice add accordion
Monorepo local script
Use your package manager wrapper when running the local lattice command.
pnpm lattice add accordionPublic Exports
-
Accordion -
Accordion.Root -
Accordion.Item -
Accordion.Header -
Accordion.Trigger -
Accordion.Content -
nextAccordionValues -
normalizeAccordionValue
State Model
Accordion.Rootcan be controlled withvalueor uncontrolled withdefaultValue.typeswitches the value shape between a single string and an array of strings.- Each item tracks
openanddisabledstate through context, andAccordion.Contentcan stay mounted withforceMount.
Key API
Accordion.Root
Use type, value, defaultValue, onValueChange, and collapsible to define the disclosure model for the entire group.
Accordion.Item
Each item needs a stable value; disabled removes that item from interaction without changing the rest of the group.
Accordion.Content
Use forceMount when you need persistent layout measurement or your own enter/exit animation handling.
Composition Patterns
FAQ or help content
Model each answer as an Accordion.Item so the surrounding layout stays simple and only the disclosure behavior is shared.
Settings sections
Use type="single" when the UI should encourage one open section at a time, and type="multiple" for checklist-style review flows.
Cautions / Limits
- Match the controlled
valueshape totype: a single string forsingle, an array formultiple. - The package does not style or animate panels for you; provide your own trigger affordance and content transition treatment.