StealThis .dev

GSAP Accordion

Three accordion variants (exclusive, multi-open, minimal) using GSAP height:'auto' animation. Demonstrates smooth open/close without CSS max-height artifacts, arrow rotation spring ease, and aria attributes.

Open in Lab
gsapaccordionheight-autoa11y
Targets: JS HTML

Code

/* ── Demo 50: GSAP Accordion ── */
/* Clean light-ish neutral palette — distinct from all existing dark demos */

:root {
  --bg: #f8f7f4;
  --white: #ffffff;
  --panel: #f0ede8;
  --border: #d8d4cc;
  --text: #1a1814;
  --muted: #7a756c;
  --accent: #2d5be3;    /* electric blue */
  --accent-warm: #e05a20;
  --green: #1a7a40;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(45, 91, 227, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* ── Page layout ── */
.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 5rem 2rem 8rem;
}

.page-header {
  margin-bottom: 5rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.page-header h1 em {
  font-style: normal;
  color: var(--accent);
}

.page-header p {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.8;
  max-width: 540px;
}

/* ── Demo sections ── */
.demo-section {
  margin-bottom: 4.5rem;
}

.demo-label {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.variant-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  background: var(--accent);
  color: white;
  border-radius: 2px;
}

.demo-label h2 {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--muted);
}

/* ── Accordion base ── */
.accordion {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--white);
}

.acc-item {
  border-bottom: 1px solid var(--border);
}

.acc-item:last-child {
  border-bottom: none;
}

/* ── Trigger ── */
.acc-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.2s;
}

.acc-trigger:hover {
  background: var(--panel);
}

.at-icon {
  color: var(--accent);
  font-size: 0.5rem;
  flex-shrink: 0;
  transition: color 0.3s;
}

.at-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  flex-shrink: 0;
  width: 24px;
}

.at-title {
  flex: 1;
}

.at-arrow {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Active state */
.acc-item[data-open="true"] .acc-trigger,
.acc-item.acc-item--open .acc-trigger {
  background: var(--panel);
}

.acc-item[data-open="true"] .at-icon,
.acc-item.acc-item--open .at-icon {
  color: var(--accent-warm);
}

.acc-item[data-open="true"] .at-arrow,
.acc-item.is-open .at-arrow {
  transform: rotate(180deg);
}

/* ── Body ── */
.acc-body {
  overflow: hidden;
  height: 0;
}

.acc-item[data-open="true"] .acc-body,
.acc-item.acc-item--open .acc-body {
  height: auto;
}

.acc-inner {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.acc-inner p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.8;
}

/* Timeline variant */
.acc-inner--timeline {
  padding-top: 0.5rem;
}

.tl-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--panel);
}

.tl-item:last-child {
  border-bottom: none;
}

.tl-week {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.tl-task {
  font-size: 0.88rem;
  color: var(--text);
}

/* ── Minimal variant ── */
.accordion--minimal {
  border: none;
  border-radius: 0;
  border-top: 2px solid var(--text);
}

.accordion--minimal .acc-item {
  border-bottom: 1px solid var(--border);
}

.accordion--minimal .acc-trigger {
  padding: 1.25rem 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.accordion--minimal .acc-trigger:hover {
  background: transparent;
  color: var(--accent);
}

.accordion--minimal .acc-trigger:hover .at-arrow {
  color: var(--accent);
}

.accordion--minimal .at-arrow {
  font-size: 1.2rem;
  font-weight: 300;
  color: var(--text);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s;
}

.accordion--minimal .is-open .at-arrow {
  transform: rotate(45deg);
}

.accordion--minimal .acc-inner {
  padding-left: 0;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .page { padding: 3rem 1.25rem 5rem; }
  .demo-label { flex-direction: column; gap: 0.5rem; }
}

/* ── Reduced motion ── */
html.reduced-motion .acc-trigger,
html.reduced-motion .at-arrow {
  transition: none !important;
}

GSAP Accordion

Three accordion variants (exclusive, multi-open, minimal) using GSAP height:‘auto’ animation. Demonstrates smooth open/close without CSS max-height artifacts, arrow rotation spring ease, and aria attributes.

Source

  • Repository: libs-genclaude
  • Original demo id: 50-gsap-accordion

Notes

Three accordion variants (exclusive, multi-open, minimal) using GSAP height:‘auto’ animation. Demonstrates smooth open/close without CSS max-height artifacts, arrow rotation spring ease, and aria attributes.