# Outlined Floating Label

> A Material-style outlined input whose label shrinks into a notch on the top border when focused or filled.

- Category: [CSS Form Elements](https://copy-css.com/category/forms)
- Tags: floating label, outlined, material, notch, input, placeholder-shown
- Live preview: https://copy-css.com/snippets/outlined-floating-label
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<label class="outlined">
  <input type="text" name="name" autocomplete="name" placeholder=" ">
  <span>Full name</span>
</label>
```

## CSS

```css
.outlined {
  --accent: #0d9488;
  position: relative;
  display: block;
  width: 240px;
  font-family: system-ui, sans-serif;
}

.outlined input {
  box-sizing: border-box;
  width: 100%;
  padding: 14px 14px;
  border: 1.5px solid #a1a1aa;
  border-radius: 8px;
  background: #fff;
  color: #18181b;
  font: 16px system-ui, sans-serif;
  outline: none;
  transition: border-color 0.2s ease;
}

.outlined span {
  position: absolute;
  top: 50%;
  left: 10px;
  padding: 0 4px;
  background: #fff;
  color: #71717a;
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-50%);
  transition: top 0.2s ease, font-size 0.2s ease, color 0.2s ease;
}

.outlined input:hover {
  border-color: #52525b;
}

.outlined input:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.outlined input:focus + span,
.outlined input:not(:placeholder-shown) + span {
  top: 0;
  font-size: 12px;
}

.outlined input:focus + span {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .outlined span {
    transition: none;
  }
}
```

## Notes

- This CSS Outlined Floating Label is 59 lines of pure CSS (1.1 KB) with no JavaScript and no dependencies. It uses transitions, transforms, box shadows and custom properties.
- Customize with: `--accent`.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
