Vibary.ai
← Vibe Coding

Conditional Section Reveal

Picking an option unfolds the extra fields it requires, the section easing its height open.

formscalmminimalinteraction · finite · starter · ~0.3s
Interactive · click to play
Variant

The animated component in this preview is rendered from the canonical file shown here. The surrounding demo shell only provides context and is not part of the copied code.

310 lines · react + motion only
import { useId, useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

/**
 * Vibary · Conditional Section Reveal
 *
 * Choosing an option unfolds the fields that option requires. The section
 * eases its height open and the fields inside arrive just behind the

About this pattern

Forms that ask everything up front feel twice as long as they are, so the fields only one kind of customer needs stay out of sight until that customer is identified. The section eases its height open on a short curve — never a spring, because a panel that overshoots its own height flashes clipped text on the way back — and the fields inside rise into place just behind the growing edge, staggered barely enough to read as one movement. Choosing the other option folds the section away and the form closes the gap rather than leaving a hole where it was.

Checkout billing detailsConditional questionnaireSettings that depend on a choiceAccount setup questions

Where it shows up

Screens we drew to show where this motion usually sits. Illustrations, not captures of any product.

  • Payment
    Card number4242 4242 4242 4242Name on cardN. Bergström
    Expiry04 / 28CVC•••
    Subtotal$156.00Shipping$0.00Tax$13.65Total$169.65
    Pay $169.65
    Checkout

    Business billing adds company and tax fields without a page change.

Related patterns