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

Height auto animation

Also called animate height auto or expand and collapse 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.

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

const faqs = [
  {
    question: 'Can I use my own domain?',
    answer:
      'Yes. Add it in project settings and point a CNAME record at your project. HTTPS is set up for you.'
  },
  {
    question: 'Is there a free plan?',
    answer: 'The free plan includes three projects. Upgrade when you need more.'
  },
  {
    question: 'How do I cancel?',
    answer:
      'Cancel anytime from Billing. Your apps stay online until the end of the billing period.'
  }
];

export function Faq() {
  return (
    <Accordion.Root className='w-96 divide-y rounded-xl border'>
      {faqs.map((faq) => (
        <Accordion.Item key={faq.question}>
          <Accordion.Header>
            <Accordion.Trigger className='group flex w-full items-center justify-between gap-4 px-4 py-3 text-left text-sm font-medium'>
              {faq.question}
              <ChevronDownIcon className='size-4 shrink-0 transition-transform duration-250 ease-out group-data-panel-open:rotate-180 motion-reduce:transition-none' />
            </Accordion.Trigger>
          </Accordion.Header>
          {/* Base UI measures the answer and exposes its auto height as --accordion-panel-height. */}
          <Accordion.Panel className='h-(--accordion-panel-height) overflow-hidden transition-[height,opacity] duration-250 ease-out data-ending-style:h-0 data-ending-style:opacity-0 data-starting-style:h-0 data-starting-style:opacity-0 motion-reduce:transition-none'>
            <p className='px-4 pb-4 text-sm text-muted-foreground'>
              {faq.answer}
            </p>
          </Accordion.Panel>
        </Accordion.Item>
      ))}
    </Accordion.Root>
  );
}

function ChevronDownIcon(props: ComponentProps<'svg'>) {
  return (
    <svg
      viewBox='0 0 16 16'
      fill='none'
      stroke='currentColor'
      strokeWidth={1.5}
      aria-hidden='true'
      {...props}
    >
      <path d='m4 6 4 4 4-4' />
    </svg>
  );
}
Make the FAQ items expand and collapse smoothly to their natural height: animate from 0 to the content height over 250ms with ease-out, fade the answer in, and rotate the chevron 180°. Use the grid-template-rows 0fr to 1fr technique (or Motion’s height: "auto"), set aria-expanded on the button, and skip the animation when prefers-reduced-motion is set.

Paste into Layerwise or any AI coding tool.

What is Height auto animation?

Accordions, “Show more” sections, and expandable rows all need to grow from zero to however tall their content happens to be. For years CSS could not transition between height: 0 and height: auto, because auto is not a number, so the panel snapped open even with a transition set.

There are a few reliable fixes. Animate a grid row from grid-template-rows: 0fr to 1fr, with an inner wrapper set to overflow: hidden and min-height: 0; this works in all modern browsers. Motion can animate to height: "auto" directly by measuring the content for you. Chromium-based browsers also support interpolate-size: allow-keywords, which lets plain CSS transitions reach auto.

Keep it between about 200 and 300ms with an ease-out curve, and fade the content in slightly as the panel opens. Avoid the old trick of animating max-height to a large number: the timing feels off because the animation runs toward the large value instead of the real height.

Often confused with

Layout animation
Layout animation moves and resizes any element after a layout change. Height auto animation grows one container to fit content of unknown height.

Related terms

All terms

Accordion

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

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.

Ease-out

An easing curve that starts fast and slows down at the end, so motion feels quick and lands softly.

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

Animated height

Shipping
  • Ships in 2–3 days
  • Free 30-day returns
  • Tracking by email

Instant

Shipping