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

Flexbox

Also called flex, display: flex, or flexible box layout

A CSS layout mode that lines items up in a row or a column and controls how they share space, align, and wrap.

import { Menu } from '@base-ui/react/menu';

const LINKS = [
  { href: '/product', label: 'Product' },
  { href: '/pricing', label: 'Pricing' },
  { href: '/docs', label: 'Docs' }
];

export function Navbar() {
  return (
    // One row: items centered vertically, pushed to the ends and the middle.
    <header className='flex h-16 items-center justify-between gap-4 px-6'>
      <a href='/' className='font-semibold'>
        Tripmate
      </a>
      <nav className='hidden gap-8 text-sm sm:flex'>
        {LINKS.map((link) => (
          <a key={link.href} href={link.href} className='hover:underline'>
            {link.label}
          </a>
        ))}
      </nav>
      <div className='flex items-center gap-2'>
        <a
          href='/signin'
          className='rounded-full bg-primary px-4 py-2 text-sm font-medium text-primary-foreground'
        >
          Sign in
        </a>
        <Menu.Root>
          <Menu.Trigger className='rounded-full border px-4 py-2 text-sm sm:hidden'>
            Menu
          </Menu.Trigger>
          <Menu.Portal>
            <Menu.Positioner sideOffset={8} align='end'>
              <Menu.Popup className='flex min-w-40 flex-col rounded-xl border bg-background p-1 shadow-lg'>
                {LINKS.map((link) => (
                  <Menu.LinkItem
                    key={link.href}
                    href={link.href}
                    className='rounded-lg px-3 py-2 text-sm outline-none data-highlighted:bg-muted'
                  >
                    {link.label}
                  </Menu.LinkItem>
                ))}
              </Menu.Popup>
            </Menu.Positioner>
          </Menu.Portal>
        </Menu.Root>
      </div>
    </header>
  );
}
Lay out the navbar with flexbox: display: flex, align-items: center, justify-content: space-between, 64px tall with 24px horizontal padding. Put the logo on the left, the links in the middle in their own flex row with a 32px gap, and the "Sign in" button on the right. Under 640px, hide the links behind a menu button.

Paste into Layerwise or any AI coding tool.

What is Flexbox?

Turn it on with display: flex on a parent, and its children line up along a main axis: a row by default, or a column with flex-direction: column. justify-content spreads them along that axis (start, center, space-between), and align-items positions them across it (top, middle, bottom, or stretched to fill).

Flexbox is the tool for one-dimensional layouts: navigation bars, button groups, a row of avatars, an icon next to a label, or centering something in a box with justify-content: center and align-items: center. Use gap for the space between items and flex-wrap: wrap to let them flow onto new lines.

When rows and columns need to line up with each other, such as a photo gallery or a page layout, CSS Grid is usually simpler. In Tailwind these map to classes like flex, flex-col, justify-between, items-center, and gap-4, which are handy words to use in prompts.

Often confused with

CSS Grid
Flexbox arranges items along one line at a time, a row or a column. CSS Grid places items on rows and columns at once, so they line up in both directions.

Related terms

All terms

CSS Grid

A CSS layout system that places items on rows and columns at once, so content lines up in both directions.

Padding vs margin

Padding is the space inside an element’s border, around its content, while margin is the space outside the border that pushes other elements away.

Responsive design

Designing one layout that adapts to any screen width, rearranging columns, sizes, and navigation at set widths called breakpoints.

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.

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
flex-direction: row;justify-content: flex-start;align-items: flex-start;
1
2
3