CSS ACCORDION GENERATOR
Build a collapsible accordion panel, then copy the CSS and matching HTML.
In short
Design a collapsible accordion panel — header and body colors, corner radius, and transition speed — on a live preview, then copy the CSS and HTML. Runs entirely in your browser.
.accordion-item {
border: 1px solid #2a2521;
border-radius: 6px;
overflow: hidden;
}
.accordion-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 18px;
background: #2a2521;
color: #f2e9dc;
cursor: pointer;
user-select: none;
}
.accordion-header .icon {
transition: transform 0.25s ease;
}
.accordion-item.open .accordion-header .icon {
transform: rotate(180deg);
color: #ff6a35;
}
.accordion-body {
max-height: 0;
overflow: hidden;
background: #201d19;
color: #f2e9dc;
transition: max-height 0.25s ease;
}
.accordion-item.open .accordion-body {
max-height: 240px;
}
.accordion-body-inner {
padding: 16px 18px;
}How to build a CSS accordion
- 1
Click the header in the preview to expand and collapse the panel.
- 2
Pick the header background, body background, text, and open-icon accent colors.
- 3
Adjust the corner radius and transition speed.
- 4
Copy the generated CSS and the matching HTML structure.
Questions
- How does the accordion expand and collapse without JavaScript animation?
- The body's `max-height` is transitioned from 0 to a fixed value (240px here) whenever the parent has an .open class. Only a class toggle is needed in JavaScript — the smooth expand/collapse motion itself is pure CSS.
- What if my content is taller than the fixed max-height?
- Content taller than the max-height value will be clipped. Either raise the max-height in the generated CSS to a value comfortably larger than your tallest panel's content, or switch to a `grid-template-rows: 0fr` / `1fr` transition technique, which handles arbitrary content heights automatically.
- Can I have multiple accordion items where only one is open at a time?
- Yes — this CSS only styles a single .accordion-item; to make items exclusive, add a small script that removes the .open class from sibling items when one is clicked, or use radio inputs with the same name in a CSS-only implementation.
- Is this accordion accessible?
- Use a real <button> for the header (keyboard-focusable by default) and set aria-expanded on it, toggling it alongside the .open class. Give the body a matching id and reference it with aria-controls on the button.
- Does this tool send my design anywhere?
- No — everything runs locally in your browser. The CSS is generated in real time and nothing is uploaded to a server.
Related tools
- CSS Navbar GeneratorDesign a responsive navbar — alignment, height, colors, sticky positioning, and shadow — and copy the CSS and HTML.
- CSS Tooltip GeneratorDesign a hover tooltip — position, colors, font size, corner radius, arrow — and copy the CSS and HTML.
- CSS Spinner & Loader GeneratorBuild a loading spinner from 34 styles — rings, dots, bars, shapes, and skeleton/progress loaders — with size, speed, and color, and copy the CSS.
- CSS Modal GeneratorDesign a modal dialog with a fading overlay — width, radius, colors, overlay opacity, shadow — and copy the CSS and HTML.
- CSS Media Query GeneratorBuild a @media rule from common breakpoints or a custom width/orientation condition and copy the CSS.
- CSS Card GeneratorDesign a UI card — corner radius, padding, shadow intensity, colors, hover lift — and copy the CSS and HTML.
- CSS Triangle GeneratorBuild a pure-CSS triangle with the border trick — direction, size, and color — and copy the CSS.
- CSS Container GeneratorDesign a centered, max-width page container — padding, background, corner radius — and copy the CSS.
Updated