BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn-htmx/collapsible

Collapsible

shadcn-htmx/collapsible
FreeComponent

A single show/hide disclosure built on native <details>/<summary> — click, Space, or Enter toggle and the browser mirrors aria-expanded, all with zero JavaScript. A standalone disclosure, distinct from the grouped Accordion.

Live preview

live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/collapsible.json

Source

registry/ui/collapsible.tsxshadcn-htmx.productdevbook.com/r/collapsible.json
1/** @jsxImportSource hono/jsx */
2import type { PropsWithChildren } from "hono/jsx"
3import { cn, type ClassValue } from "@/registry/lib/cn"
4
5// Collapsible — shadcn-htmx, htmx v4 + Tailwind v4.
6//
7// shadcn upstream uses Radix Collapsible (a CollapsibleTrigger button + a
8// CollapsibleContent region wired together with aria-expanded / aria-controls
9// and JS state). We use the native HTML disclosure widget instead:
10// <details><summary>Trigger</summary>...content...</details>
11// so the platform gives us, with zero JS:
12// - Click / Space / Enter toggles open (browser default on <summary>).
13// - <summary> is implicitly role="button", focusable, with its text as the
14// accessible name; the browser sets aria-expanded to mirror `open`.
15// - The content is the accessible description of the summary.
16//
17// This is the WAI-ARIA Disclosure (Show/Hide) pattern: a single button that
18// shows/hides one section of content. Distinct from Accordion — Collapsible
19// is a standalone, single show/hide, NOT a group, so there is no `name`
20// attribute and no exclusive grouping. No public/site.js hook is required:
21// the entire keyboard contract (Enter / Space) is native to <summary>.
22//
23// Refs:
24// repos/aria-practices/content/patterns/disclosure/disclosure-pattern.html
25// (Keyboard: Enter / Space toggle; role=button; aria-expanded true/false)
26// repos/mdn/files/en-us/web/html/reference/elements/details/index.md
27// (`open` boolean; implicit ARIA role=group; toggle event)
28// repos/mdn/files/en-us/web/html/reference/elements/summary/index.md
29// (click/Space toggles parent <details>; display:list-item marker)
30
31type CollapsibleProps = PropsWithChildren<{
32 // Pre-open the disclosure on initial render.
33 open?: boolean
34 disabled?: boolean
35 class?: ClassValue
36}>
37
38export function Collapsible(props: CollapsibleProps) {
39 const { open, disabled, class: className, children, ...rest } = props
40 return (
41 <details
42 data-slot="collapsible"
43 data-disabled={disabled ? "true" : undefined}
44 open={open}
45 class={cn(
46 "w-full",
47 disabled && "pointer-events-none opacity-50",
48 className,
49 )}
50 {...rest}
51 >
52 {children}
53 </details>
54 )
55}
56
57type CollapsibleTriggerProps = PropsWithChildren<{ class?: ClassValue }>
58
59export function CollapsibleTrigger(props: CollapsibleTriggerProps) {
60 const { class: className, children, ...rest } = props
61 return (
62 <summary
63 data-slot="collapsible-trigger"
64// … truncated

Facts

Registry
shadcn-htmx
Type
registry:ui
Access
Free
Files written
0
Licence
MIT
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on shadcn-htmx shadcn-htmx.productdevbook.com productdevbook/shadcn-htmx on GitHub Raw registry item This item as JSON

More from shadcn-htmx

All 83 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionshadcn-htmxComponentsFreeno deps
Active Searchactive-searchshadcn-htmxComponentsFreeno deps
Alertalertshadcn-htmxComponentsFreeno deps
Alert Dialogalert-dialogshadcn-htmxComponentsFreeno deps
Aspect Ratioaspect-ratioshadcn-htmxComponentsFreeno deps
Auto Gridauto-gridshadcn-htmxComponentsFreeno deps
Autocompleteautocompleteshadcn-htmxComponentsFreeno deps
Autosize Textareaautosize-textareashadcn-htmxComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex