Forms & Inputs Pure CSS peer-placeholder-shown Zero-JS Tailwind v4

Floating Label Input

Modern animated floating label form controls utilizing HTML5 placeholder-shown pseudo-class and Tailwind peer selectors.

Interactive Preview

Live Edit & Viewport Resizer
Variants:

Installation

Add the Floating Label Input component to your project via CLI:

terminal bash
npx plain-ui add floating-label-input

Features

  • Zero JavaScript - 100% pure CSS peer animations
  • Smooth label translation, scaling, and color transitions
  • Outlined border notch and filled background styles
  • Leading and trailing icon support
  • Interactive password toggle and validation helper text

Variants & Examples

With Leading Icon

Floating label input with icon placement.

floating-label-input-with-leading-icon.html html
<div class="max-w-sm mx-auto p-4">
  <div class="relative">
    <div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none text-zinc-400">
      <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
    </div>
    <input 
      type="text" 
      id="search-input" 
      placeholder=" "
      class="peer block w-full ps-10 pe-3.5 pt-4 pb-2 text-sm text-zinc-900 dark:text-zinc-100 bg-transparent rounded-lg border border-zinc-300 dark:border-zinc-700 appearance-none focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent transition-all"
    />
    <label 
      for="search-input"
      class="absolute text-sm text-zinc-500 dark:text-zinc-400 duration-200 transform -translate-y-3.5 scale-75 top-4 z-10 origin-[0] start-10 bg-white dark:bg-zinc-950 px-1 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-placeholder-shown:bg-transparent peer-focus:scale-75 peer-focus:-translate-y-3.5 peer-focus:bg-white dark:peer-focus:bg-zinc-950 peer-focus:text-blue-600 dark:peer-focus:text-blue-400 pointer-events-none"
    >
      Search components...
    </label>
  </div>
</div>

Attributes & Classes

Attribute / Prop Type Default Description
placeholder=' ' string - Required single space placeholder to enable CSS :placeholder-shown state.
peer class - Tailwind class placed on input to enable peer sibling targeting on label.

Accessibility & Keyboard Navigation

  • Label element is properly associated with the input via matching for and id attributes.
  • Retains full keyboard focus visibility.
Components
#
Button
Interactive button primitives with rich visual variants, loading spinners, icons, and keyboard accessibility.
Core Primitives
#
Dialog
Native HTML <dialog> modal with backdrop blur, @starting-style entry animations, and accessible focus trapping.
Overlays & Modals
#
Popover
Native HTML Popover API (popover='auto') with zero JavaScript, CSS anchor positioning, and automatic light dismiss.
Overlays & Modals
#
Floating Label Input
Modern animated floating label form controls utilizing HTML5 placeholder-shown pseudo-class and Tailwind peer selectors.
Forms & Inputs
#
Border Beam
Dynamic glowing animated border beam gradient traveling continuously around cards and containers using pure CSS animations.
Motion & Effects
#
Shimmer Button
High-performance glowing shimmer button with animated radial light sweep across the surface.
Motion & Effects
#
Dock
macOS-inspired interactive dock with smooth pointer proximity magnification physics, hover tooltips, and app status dots.
Layout & Navigation
#
Bento Grid
Modern modular 12-column asymmetric bento box layout with spotlight card glow, metric widgets, and responsive auto-fitting.
Layout & Surfaces
#
Accordion
Pure HTML <details> and <summary> accordion with smooth height expansion animation and animated rotating chevrons.
Core Primitives
#
Tabs
Accessible, keyboard-navigable tab system with animated indicator slider and light-DOM panels.
Layout & Navigation
Getting Started
📖
Getting Started & Tailwind v4 Setup
Quick start guide and architecture overview
Navigate Select
Plain UI Search