Component

Floating Label Input

Material-inspired floating label inputs with smooth animations

  • Component
  • Tailwind
  • MIT

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.dev/library/tailwind/components/input/floating-label/
fluid · no fixed width 100%
No dependencies Production-ready

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Input/floating-label
registry path: Tailwind/Components/Input/floating-label

Source

Implementation

code.html
<!-- Floating Label - Standard -->
<div class="relative">
  <input type="email" id="email-float" placeholder=" " class="peer w-full px-4 py-4 pt-6 pb-2 bg-white border border-gray-200 rounded-xl focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-all" />
  <label for="email-float" class="absolute left-4 top-4 text-gray-400 transition-all duration-200 pointer-events-none peer-placeholder-shown:top-4 peer-placeholder-shown:text-base peer-focus:top-2 peer-focus:text-xs peer-focus:text-blue-500 peer-focus:font-medium">Email Address</label>
</div>

<!-- Floating Label - With Value -->
<div class="relative mt-4">
  <input type="email" id="email-filled" placeholder=" " value="user@company.com" class="peer w-full px-4 py-4 pt-6 pb-2 bg-white border border-gray-200 rounded-xl focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-all" />
  <label for="email-filled" class="absolute left-4 top-2 text-xs text-blue-500 font-medium transition-all duration-200 pointer-events-none peer-placeholder-shown:top-4 peer-placeholder-shown:text-base">Email Address</label>
</div>

<!-- Floating Label - Password -->
<div class="relative mt-4">
  <input type="password" id="password-float" placeholder=" " class="peer w-full px-4 py-4 pt-6 pb-2 bg-white border border-gray-200 rounded-xl focus:outline-none focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20 transition-all" />
  <label for="password-float" class="absolute left-4 top-4 text-gray-400 transition-all duration-200 pointer-events-none peer-placeholder-shown:top-4 peer-placeholder-shown:text-base peer-focus:top-2 peer-focus:text-xs peer-focus:text-purple-500 peer-focus:font-medium">Password</label>
</div>
17 lines UTF-8 · LF · Spaces: 2

AI-ready

Available to your agent.

This component is reachable through the DevSnips CLI, MCP server and Skills integrations — one registry, one resource path.

Resource path

devsnips://components/input/floating-label

Continue browsing

View all