Collapsible
Region that the user can show or hide.
- Browsers
- Chrome 123+, Firefox 121+, Safari 17.5+
- Tier
- 0
- Bundle compressed
- 429 B
- Forced layout budget
- 0 ms
- Axe budget
- 0
- SSR compatible
- Yes
- Built on
- elements/details
- Published contract
- Test harness
Playground
Collapsible
Closed
Toggle section
Hidden panel content
Open
Toggle section
Visible panel content
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
import { Collapsible } from "@gunkin/uiify";
export default function Example() {
return (
<Collapsible
className=""
id="release-notes"
label="Release notes"
content={<>New keyboard navigation and accessibility improvements.</>}
/>
);
}- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
/* Collapsible — a single native <details>/<summary> disclosure. Same shape
as accordion.css: [data-part] selectors let styles apply without opting
into the BEM classes, both rules kept together so they can't drift apart. */
@layer components {
:where([data-uiify-collapsible], [data-uiify-collapsible]) {
inline-size: 100%;
border: var(--border-width) solid var(--border);
border-radius: var(--radius-xl);
corner-shape: squircle;
overflow: hidden;
}
[data-uiify-collapsible] [data-part="trigger"] {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-md);
padding: var(--space-lg);
font-size: var(--text-sm);
font-weight: var(--weight-medium);
cursor: pointer;
list-style: none;
}
[data-uiify-collapsible] [data-part="trigger"]::-webkit-details-marker {
display: none;
}
[data-uiify-collapsible] [data-part="trigger"]:hover {
background-color: var(--secondary);
}
[data-uiify-collapsible] [data-part="trigger"]:focus-visible {
outline: none;
box-shadow: inset 0 0 0 var(--ring-width) color-mix(in oklch, var(--ring) 16%, transparent);
}
[data-uiify-collapsible] [data-part="trigger"]::after {
content: "+";
display: grid;
place-items: center;
inline-size: 1.5rem;
block-size: 1.5rem;
flex: 0 0 1.5rem;
color: var(--muted-foreground);
font:
1.25rem/1 ui-monospace,
monospace;
transition: rotate var(--duration-fast) var(--ease-out);
}
[data-uiify-collapsible][open] [data-part="trigger"]::after {
content: "−";
}
[data-uiify-collapsible][open] [data-part="trigger"] {
color: var(--primary);
}
[data-uiify-collapsible] [data-part="panel"] {
padding-block: 0 var(--space-lg);
padding-inline: var(--space-lg);
color: var(--muted-foreground);
font-size: var(--text-sm);
}
[data-uiify-collapsible] {
interpolate-size: allow-keywords;
}
:where([data-uiify-collapsible], [data-uiify-collapsible])::details-content {
block-size: 0;
overflow: clip;
}
:where([data-uiify-collapsible], [data-uiify-collapsible])[open]::details-content {
block-size: auto;
}
/* Shared presence timing; block-size only interpolates where the block above applies. */
@media (prefers-reduced-motion: no-preference) {
:where([data-uiify-collapsible], [data-uiify-collapsible])::details-content {
opacity: 0;
transition:
opacity var(--duration-fast) var(--ease-out),
block-size var(--duration-fast) var(--ease-out),
content-visibility var(--duration-fast) allow-discrete;
}
:where([data-uiify-collapsible], [data-uiify-collapsible])[open]::details-content {
opacity: 1;
}
}
}- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
import { Collapsible } from "@gunkin/uiify";
export default function Example() {
return (
<Collapsible
className={
"[inline-size:100%] border-[length:var(--border-width)] border-solid border-border rounded-xl [corner-shape:" +
"squircle] overflow-hidden [&_[data-part=trigger]]:flex [&_[data-part=trigger]]:items-center [&_[data-part=t" +
"rigger]]:justify-between [&_[data-part=trigger]]:gap-md [&_[data-part=trigger]]:p-lg [&_[data-part=trigger]" +
"]:text-sm [&_[data-part=trigger]]:font-[number:var(--weight-medium)] [&_[data-part=trigger]]:cursor-pointer" +
" [&_[data-part=trigger]]:list-none [&_[data-part=trigger]::-webkit-details-marker]:hidden [&_[data-part=tri" +
"gger]:hover]:bg-secondary [&_[data-part=trigger]:focus-visible]:[outline:none] [&_[data-part=trigger]:focus" +
"-visible]:[box-shadow:inset_0_0_0_var(--ring-width)_color-mix(in_oklch,_var(--ring)_16%,_transparent)] [&_[" +
"data-part=trigger]::after]:content-[\"+\"] [&_[data-part=trigger]::after]:grid [&_[data-part=trigger]::after]" +
":place-items-center [&_[data-part=trigger]::after]:[inline-size:1.5rem] [&_[data-part=trigger]::after]:[blo" +
"ck-size:1.5rem] [&_[data-part=trigger]::after]:[flex:0_0_1.5rem] [&_[data-part=trigger]::after]:text-muted-" +
"foreground [&_[data-part=trigger]::after]:not-italic [&_[data-part=trigger]::after]:[font-variant:normal] [" +
"&_[data-part=trigger]::after]:font-normal [&_[data-part=trigger]::after]:[font-stretch:normal] [&_[data-par" +
"t=trigger]::after]:[font-size:1.25rem] [&_[data-part=trigger]::after]:leading-none [&_[data-part=trigger]::" +
"after]:[font-family:ui-monospace,_monospace] [&_[data-part=trigger]::after]:[transition:rotate_var(--durati" +
"on-fast)_var(--ease-out)] [&[open]_[data-part=trigger]::after]:content-[\"−\"] [&[open]_[data-part=trigger]]:" +
"text-primary [&_[data-part=panel]]:[padding-block:0_var(--space-lg)] [&_[data-part=panel]]:px-lg [&_[data-p" +
"art=panel]]:text-muted-foreground [&_[data-part=panel]]:text-sm [interpolate-size:allow-keywords] [&::detai" +
"ls-content]:[block-size:0] [&::details-content]:overflow-clip [&[open]::details-content]:[block-size:auto] " +
"motion-safe:[&::details-content]:opacity-0 motion-safe:[&::details-content]:[transition:opacity_var(--durat" +
"ion-fast)_var(--ease-out),_block-size_var(--duration-fast)_var(--ease-out),_content-visibility_var(--durati" +
"on-fast)_allow-discrete] motion-safe:[&[open]::details-content]:opacity-100"
}
id="release-notes"
label="Release notes"
content={<>New keyboard navigation and accessibility improvements.</>}
/>
);
}- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
/* app.css */
@layer reset, ui, app, tokens, base, demo, components, utilities, theme;
@import "@gunkin/uiify/styles/reset";
@import "@gunkin/uiify/components/behavior.css";
@import "@gunkin/uiify/styles/tokens";
@import "@gunkin/uiify/styles/tailwind";
@import "tailwindcss/utilities.css";
@theme { --spacing: 0.25rem; --font-weight-normal: 400; --font-weight-medium: 500; --font-weight-semibold: 600; --font-weight-bold: 700; }
@source inline('[inline-size:100%] border-[length:var(--border-width)] border-solid border-border rounded-xl [corner-shape:squircle] overflow-hidden [&_[data-part=trigger]]:flex [&_[data-part=trigger]]:items-center [&_[data-part=trigger]]:justify-between [&_[data-part=trigger]]:gap-md [&_[data-part=trigger]]:p-lg [&_[data-part=trigger]]:text-sm [&_[data-part=trigger]]:font-[number:var(--weight-medium)] [&_[data-part=trigger]]:cursor-pointer [&_[data-part=trigger]]:list-none [&_[data-part=trigger]::-webkit-details-marker]:hidden [&_[data-part=trigger]:hover]:bg-secondary [&_[data-part=trigger]:focus-visible]:[outline:none] [&_[data-part=trigger]:focus-visible]:[box-shadow:inset_0_0_0_var(--ring-width)_color-mix(in_oklch,_var(--ring)_16%,_transparent)] [&_[data-part=trigger]::after]:content-["+"] [&_[data-part=trigger]::after]:grid [&_[data-part=trigger]::after]:place-items-center [&_[data-part=trigger]::after]:[inline-size:1.5rem] [&_[data-part=trigger]::after]:[block-size:1.5rem] [&_[data-part=trigger]::after]:[flex:0_0_1.5rem] [&_[data-part=trigger]::after]:text-muted-foreground [&_[data-part=trigger]::after]:not-italic [&_[data-part=trigger]::after]:[font-variant:normal] [&_[data-part=trigger]::after]:font-normal [&_[data-part=trigger]::after]:[font-stretch:normal] [&_[data-part=trigger]::after]:[font-size:1.25rem] [&_[data-part=trigger]::after]:leading-none [&_[data-part=trigger]::after]:[font-family:ui-monospace,_monospace] [&_[data-part=trigger]::after]:[transition:rotate_var(--duration-fast)_var(--ease-out)] [&[open]_[data-part=trigger]::after]:content-["−"] [&[open]_[data-part=trigger]]:text-primary [&_[data-part=panel]]:[padding-block:0_var(--space-lg)] [&_[data-part=panel]]:px-lg [&_[data-part=panel]]:text-muted-foreground [&_[data-part=panel]]:text-sm [interpolate-size:allow-keywords] [&::details-content]:[block-size:0] [&::details-content]:overflow-clip [&[open]::details-content]:[block-size:auto] motion-safe:[&::details-content]:opacity-0 motion-safe:[&::details-content]:[transition:opacity_var(--duration-fast)_var(--ease-out),_block-size_var(--duration-fast)_var(--ease-out),_content-visibility_var(--duration-fast)_allow-discrete] motion-safe:[&[open]::details-content]:opacity-100');
@layer base { :root { --uiify-control-text: var(--text-sm); } @media (pointer: coarse) { :root { --uiify-control-text: var(--text-base); } } }
/* Authored animation and registered properties used by the Tailwind skin.
* Visual rules belong in utility recipes; only at-rule definitions live here. */
@layer components {
@keyframes uiify-presence-in {
from {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@layer components {
@keyframes uiify-presence-out {
to {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@property --uiify-spinner-tail {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
@property --uiify-spinner-length {
syntax: "<angle>";
inherits: false;
initial-value: 36deg;
}
@layer components {
@keyframes uiify-spinner-rotate {
to {
transform: rotate(360deg);
}
}
}
@layer components {
@keyframes uiify-spinner-orbit {
0% {
--uiify-spinner-tail: 0deg;
--uiify-spinner-length: 36deg;
}
50% {
--uiify-spinner-tail: 90deg;
--uiify-spinner-length: 324deg;
}
100% {
--uiify-spinner-tail: 360deg;
--uiify-spinner-length: 36deg;
}
}
}
@layer components {
@keyframes uiify-skeleton-pulse {
50% {
opacity: 0.45;
}
}
}
@layer components {
@keyframes uiify-skeleton-shimmer {
to {
background-position: -200% 0;
}
}
}
@layer components {
@keyframes uiify-skeleton-reveal {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
}
@property --candle-body-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-body-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-slot {
syntax: "<percentage>";
inherits: true;
initial-value: 100%;
}
@property --candle-wick-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-wick-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-x {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@property --line-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-prev-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-count {
syntax: "<integer>";
inherits: false;
initial-value: 1;
}
@property --line-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@layer components {
@keyframes uiify-otp-input-caret-blink {
50% {
opacity: 0;
}
}
}API
Collapsible
| Prop | Type | Default | Description |
|---|---|---|---|
id* | string | — | Id of the underlying <details> element. |
label* | ReactNode | — | Content of the summary that opens and closes the region. |
content* | ReactNode | — | Content of the panel revealed when the region is open. |
defaultOpen | boolean | false | Open on first render. Uncontrolled, so it survives with no JavaScript. |
disabled | boolean | false | Blocks toggling and marks the summary with aria-disabled and data-disabled. |
className | string | — | Class applied to the <details> root. |
Keyboard
| Key | Action |
|---|---|
| Tab | Move focus to/from the control |
| Enter / Space | Activate when focused (button-like controls) |
Accessibility
Uses semantic HTML where possible. Inspect rendered markup in the playground — ARIA is added only when native elements are insufficient.
Styling hooks
data-disabled