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

Alert banner

Also called alert, notification banner, or callout

A colored strip in the page that delivers an important message, such as info, success, warning, or error, and stays until it is resolved or dismissed.

import { useState, type ReactNode } from 'react';
import { AnimatePresence, motion } from 'motion/react';

const TONES = {
  info: 'border-blue-500/40 bg-blue-500/10 text-blue-600',
  success: 'border-green-500/40 bg-green-500/10 text-green-600',
  warning: 'border-amber-500/40 bg-amber-500/10 text-amber-600',
  error: 'border-red-500/40 bg-red-500/10 text-red-600'
};

type Props = { tone: keyof typeof TONES; children: ReactNode };

// <AlertBanner tone='warning'>Your trial ends in 3 days. <a href='/billing'>Add a card</a></AlertBanner>
export function AlertBanner({ tone, children }: Props) {
  const [open, setOpen] = useState(true);

  return (
    <AnimatePresence>
      {open && (
        // Animating height pushes the page down (and back up) instead of jumping.
        <motion.div
          initial={{ height: 0, opacity: 0 }}
          animate={{ height: 'auto', opacity: 1 }}
          exit={{ height: 0, opacity: 0 }}
          transition={{ duration: 0.2, ease: [0.23, 1, 0.32, 1] }}
          className='overflow-hidden'
        >
          {/* Errors interrupt screen readers right away; the rest wait their turn. */}
          <div
            role={tone === 'error' ? 'alert' : 'status'}
            className={`mb-4 flex items-center gap-3 rounded-lg border px-4 py-3 text-sm ${TONES[tone]}`}
          >
            <svg
              viewBox='0 0 16 16'
              aria-hidden='true'
              className='size-4 shrink-0 fill-none stroke-current stroke-[1.5]'
            >
              <circle cx='8' cy='8' r='6.5' />
              <path d='M8 5v3.5M8 11h.01' />
            </svg>
            <p className='flex-1 text-foreground'>{children}</p>
            <button
              aria-label='Dismiss'
              onClick={() => setOpen(false)}
              className='opacity-60 hover:opacity-100'
            >
              ✕
            </button>
          </div>
        </motion.div>
      )}
    </AnimatePresence>
  );
}
Add an alert banner component with four variants (info in blue, success in green, warning in amber, error in red), each with an icon, a one-line message, an optional action link, and a close button. It appears at the top of the page by expanding its height and fading in over 200ms, and collapses the same way when dismissed so the content below moves smoothly. Use role="alert" for errors and role="status" for the rest.

Paste into Layerwise or any AI coding tool.

What is Alert banner?

An alert banner is a full-width box with an icon, a short message, and often an action or a close button. Its color matches the tone: blue for info, green for success, amber for warnings, and red for errors. It sits in the page layout, usually at the top of the page or a section, and pushes the content below it down.

Use it for messages that apply to the whole page and should stay visible until handled: a failed payment, scheduled maintenance, a trial that ends in three days, an error that blocks saving. For a quick confirmation such as “Saved”, use a toast, which disappears on its own.

Keep it to one sentence plus an action, and show one banner at a time where you can, since a stack of them reads as noise. Use role="alert" for urgent errors so screen readers announce them right away, and role="status" for calmer updates.

Often confused with

Toast notification
A toast floats over the page for a few seconds and disappears on its own. An alert banner sits in the layout and stays until the issue is fixed or someone dismisses it.
Modal
A modal blocks the page until you respond. An alert banner informs you while you keep working.

Related terms

All terms

Toast notification

A brief message that slides into a corner of the screen to confirm an action, then disappears on its own after a few seconds.

Modal

A window that opens over the page, dims everything behind it, and blocks the rest of the interface until you finish or dismiss it.

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.

Inline validation

Form checking that happens right next to each field as you fill it in, showing an error or a checkmark before you press Submit.

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
Billing

Maintenance on Sunday at 2 AM UTC.

Plan
Pro · $20/month
Next invoice
Nov 30
Payment method
Visa ending 4242