Collapsible
@starwind-ui starred 3 repositories
astro
tailwindcss
starwind-ui
---import { Button } from "@/components/starwind/button";import { Collapsible, CollapsibleContent, CollapsibleTrigger,} from "@/components/starwind/collapsible";import IconSelector from "@tabler/icons/outline/selector.svg";---
<Collapsible class="w-[350px] space-y-2"> <div class="flex items-center justify-between space-x-4 px-4"> <h4 class="text-sm font-semibold">@starwind-ui starred 3 repositories</h4> <CollapsibleTrigger asChild> <Button variant="ghost" size="icon-sm"> <IconSelector class="size-4" /> <span class="sr-only">Toggle</span> </Button> </CollapsibleTrigger> </div> <div class="rounded-md border px-4 py-2 font-mono text-sm">astro</div> <CollapsibleContent class="space-y-2"> <div class="rounded-md border px-4 py-2 font-mono text-sm">tailwindcss</div> <div class="rounded-md border px-4 py-2 font-mono text-sm">starwind-ui</div> </CollapsibleContent></Collapsible>import { Button } from "@/components/starwind/button";import { Collapsible, CollapsibleContent, CollapsibleTrigger,} from "@/components/starwind/collapsible";import { IconSelector } from "@tabler/icons-react";
export function Example() { return ( <Collapsible className="w-[350px] space-y-2"> <div className="flex items-center justify-between space-x-4 px-4"> <h4 className="text-sm font-semibold">@starwind-ui starred 3 repositories</h4> <CollapsibleTrigger asChild> <Button variant="ghost" size="icon-sm"> <IconSelector className="size-4" /> <span className="sr-only">Toggle</span> </Button> </CollapsibleTrigger> </div> <div className="rounded-md border px-4 py-2 font-mono text-sm">astro</div> <CollapsibleContent className="space-y-2"> <div className="rounded-md border px-4 py-2 font-mono text-sm">tailwindcss</div> <div className="rounded-md border px-4 py-2 font-mono text-sm">starwind-ui</div> </CollapsibleContent> </Collapsible> );}Installation
pnpx starwind@latest add collapsiblenpx starwind@latest add collapsibleyarn dlx starwind@latest add collapsibleFramework Availability
Astro Available React AvailableCollapsible is available for Astro and React.
Usage
General Notes
The Collapsible component provides a way to show and hide content with a trigger button. It’s useful for FAQs, expandable sections, and progressive disclosure patterns.
The essential components are Collapsible, CollapsibleTrigger, and CollapsibleContent.
API Reference
Primitive And Runtime API
Use these references when you need the lower-level behavior APIs behind Collapsible.
Primitive API
Runtime API
- Collapsible primitive
createCollapsiblefrom@starwind-ui/runtime/collapsible
Changelog
v2.0.0
- Rebuilt Collapsible on Starwind Runtime for open state and panel lifecycle.
- See the Collapsible Primitive for the underlying unstyled anatomy and behavior API.