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

Dark mode

Also called dark theme or night mode

An alternate color theme with light text on dark backgrounds, chosen in settings or matched to the device’s system setting.

import { useEffect, useState } from 'react';
import { Toggle } from '@base-ui/react/toggle';
import { ToggleGroup } from '@base-ui/react/toggle-group';

const THEMES = ['light', 'dark', 'system'] as const;
type Theme = (typeof THEMES)[number];
const DARK_QUERY = '(prefers-color-scheme: dark)';

// Theme tokens such as bg-background switch under .dark on <html>. Run the
// same code in an inline <head> script too, so the first paint is right.
function applyTheme(theme: Theme) {
  const dark =
    theme === 'dark' || (theme === 'system' && matchMedia(DARK_QUERY).matches);
  document.documentElement.classList.toggle('dark', dark);
  document.documentElement.style.colorScheme = dark ? 'dark' : 'light';
}

export function ThemePicker() {
  const [theme, setTheme] = useState<Theme>(
    () => THEMES.find((t) => t === localStorage.getItem('theme')) ?? 'system'
  );

  useEffect(() => {
    applyTheme(theme);
    localStorage.setItem('theme', theme);
    if (theme !== 'system') return;
    // Follow the device setting while System is selected.
    const media = matchMedia(DARK_QUERY);
    const onChange = () => applyTheme('system');
    media.addEventListener('change', onChange);
    return () => media.removeEventListener('change', onChange);
  }, [theme]);

  return (
    <ToggleGroup
      aria-label='Theme'
      value={[theme]}
      onValueChange={(value) => {
        const next = THEMES.find((t) => t === value[0]);
        if (next) setTheme(next); // ignore clicks on the selected option
      }}
      className='inline-flex gap-1 rounded-full border bg-muted p-1'
    >
      {THEMES.map((option) => (
        <Toggle
          key={option}
          value={option}
          className='rounded-full px-3 py-1.5 text-sm text-muted-foreground capitalize data-pressed:bg-background data-pressed:text-foreground data-pressed:shadow-sm focus-visible:outline-2 focus-visible:outline-blue-500'
        >
          {option}
        </Toggle>
      ))}
    </ToggleGroup>
  );
}
Add dark mode with Light, Dark, and System options in settings. Define every color as a CSS variable, override them under a .dark class on <html>, default to System with prefers-color-scheme, and save the choice in localStorage. Apply the saved theme with an inline script in <head> so there is no white flash, set color-scheme to match, and use #0a0a0a instead of pure black for the page background.

Paste into Layerwise or any AI coding tool.

What is Dark mode?

Dark mode swaps an interface’s light backgrounds for dark ones and flips text to light colors, while the layout stays the same. Most apps offer three choices: Light, Dark, and System, which follows the device setting through the prefers-color-scheme media query.

Build it with color variables instead of fixed colors: define tokens such as --background and --text, then give them new values under a .dark class or a data-theme="dark" attribute on the root element. Every component that uses the tokens switches at once. Set color-scheme too, so scrollbars and form controls match.

Good dark mode takes more than inverted colors. Use dark gray rather than pure black, tone down bright accent colors, show depth with lighter surfaces instead of shadows, and check text contrast again in both themes. Apply the saved theme before the page paints, or visitors see a white flash on load. For a circular reveal like the demo’s, the View Transitions API with an animated clip-path does the job.

Related terms

All terms

Color contrast

How much text stands out from its background, measured as a ratio from 1:1 to 21:1 and checked against the WCAG levels AA and AAA.

Accent color

The one highlight color an interface uses for actions and selected states, and the CSS property that tints native form controls.

View Transitions API

A browser feature that animates between two states of a page by snapshotting the old view, applying your update, and animating to the new one.

Clip-path

A CSS property that cuts an element to a shape, such as a circle, an inset rectangle, or a polygon, and hides everything outside it.

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
ASAna SilvaPro plan
Email alerts
Weekly report
Storage6.4 of 10 GB
ASAna SilvaPro plan
Email alerts
Weekly report
Storage6.4 of 10 GB