LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Components

Accordion

Also called collapsible sections or expandable FAQ

A vertical stack of headings that each expand to reveal their content when clicked, so long pages stay short and easy to scan.

import { Accordion } from '@base-ui/react/accordion';

const FAQ = [
  {
    id: 'cancel',
    question: 'Can I cancel anytime?',
    answer: 'Yes. Your plan stays active until the end of the billing period.'
  },
  {
    id: 'refunds',
    question: 'Do you offer refunds?',
    answer: 'We refund unused months on yearly plans within 30 days.'
  },
  {
    id: 'switch',
    question: 'Can I switch plans later?',
    answer: 'Upgrade or downgrade from Billing; we prorate the difference.'
  }
];

// Without `multiple`, opening one answer closes the one that was open.
export function PricingFaq() {
  return (
    <Accordion.Root
      defaultValue={['cancel']}
      className='w-96 divide-y border-y'
    >
      {FAQ.map(({ id, question, answer }) => (
        <Accordion.Item key={id} value={id}>
          <Accordion.Header>
            <Accordion.Trigger className='group flex w-full items-center justify-between gap-4 py-4 text-left text-sm font-medium outline-none focus-visible:underline'>
              {question}
              <svg
                viewBox='0 0 16 16'
                fill='none'
                stroke='currentColor'
                strokeWidth={1.5}
                aria-hidden='true'
                className='size-4 shrink-0 transition-transform duration-250 group-data-panel-open:rotate-180'
              >
                <path d='m4 6 4 4 4-4' />
              </svg>
            </Accordion.Trigger>
          </Accordion.Header>
          {/* Base UI measures the answer and exposes it as --accordion-panel-height. */}
          <Accordion.Panel className='h-(--accordion-panel-height) overflow-hidden text-sm text-muted-foreground transition-[height] duration-250 ease-[cubic-bezier(0.23,1,0.32,1)] data-ending-style:h-0 data-starting-style:h-0 motion-reduce:transition-none'>
            <p className='pb-4'>{answer}</p>
          </Accordion.Panel>
        </Accordion.Item>
      ))}
    </Accordion.Root>
  );
}
Turn the pricing FAQ into an accordion: each question is a button with aria-expanded, clicking it expands the answer by animating its height over 250ms with cubic-bezier(0.23, 1, 0.32, 1), and the chevron rotates 180°. Allow only one answer open at a time, start with the first one open, and skip the height animation when prefers-reduced-motion is set.

Paste into Layerwise or any AI coding tool.

What is Accordion?

An accordion shows a list of headings, such as FAQ questions, with the details hidden. Clicking a heading slides its section open, and a chevron rotates to show the state. Some accordions close the open section when you open another; others let several stay open.

Use accordions for FAQs, groups of settings, and long reference content where people need only one or two sections. Content that most people need to read should stay visible, since hiding it costs a click. Make each heading a real button with aria-expanded.

Animate the height so content does not jump, over about 200 to 300ms with an ease-out curve. The native <details> element opens and closes with no script, giving several of them the same name lets only one stay open, and interpolate-size: allow-keywords lets CSS animate to height: auto in Chromium browsers.

Often confused with

Tabs
Tabs show one panel at a time in the same spot. An accordion stacks sections vertically and can open more than one.

Related terms

All terms

Height auto animation

An animation that opens or closes a panel to the exact height of its content, even though that height is unknown ahead of time.

Tabs

A row of labels that switches between panels of related content in the same spot, showing one panel at a time.

Layout animation

An animation that smoothly moves and resizes elements when the layout changes, such as list items gliding to new spots after a sort or filter.

Reduced motion

An operating system setting that asks apps to minimize movement, which websites detect with the prefers-reduced-motion media query.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit