About this snippet

Upgrade your search with an AI prompt input field. It features an auto-expanding text area and a subtle gradient glow, which just looks incredible on dark themes.

Size
3.1 KB
Uses
HTML, CSS, JavaScript
Loads
Nothing external
Views
425
<div class="prompt-container">
  <div class="glow-wrapper">
    <div class="input-box">
      <textarea id="prompt-area" placeholder="Describe what you want to generate..." rows="1"></textarea>
      
      <div class="actions">
        <button class="attach-btn" aria-label="Attach file">
          <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2">
            <path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path>
          </svg>
        </button>
        <button class="submit-btn" aria-label="Submit prompt">
          <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2">
            <line x1="12" y1="19" x2="12" y2="5"></line>
            <polyline points="5 12 12 5 19 12"></polyline>
          </svg>
        </button>
      </div>
    </div>
  </div>
</div>
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  background: #0f172a;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
}

.prompt-container {
  width: 100%;
  max-width: 600px;
  position: relative;
}

.glow-wrapper {
  position: relative;
  border-radius: 20px;
  padding: 2px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #3b82f6);
  background-size: 300% 300%;
  animation: gradientGlow 4s ease infinite;
  z-index: 1;
}

.glow-wrapper::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 24px;
  background: inherit;
  filter: blur(12px);
  opacity: 0.6;
  z-index: -1;
  animation: gradientGlow 4s ease infinite;
}

@keyframes gradientGlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.input-box {
  background: #1e293b;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

#prompt-area {
  background: transparent;
  border: none;
  color: #f8fafc;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 1rem;
  padding: 8px;
  line-height: 1.5;
  min-height: 44px;
  max-height: 200px;
  overflow-y: auto;
}

#prompt-area::placeholder {
  color: #64748b;
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid #334155;
  margin-top: 4px;
}

.attach-btn, 
.submit-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  transition: background 0.2s;
}

.attach-btn {
  color: #94a3b8;
}

.attach-btn:hover {
  background: #334155;
  color: #f8fafc;
}

.submit-btn {
  background: #3b82f6;
  color: #ffffff;
}

.submit-btn:hover {
  background: #2563eb;
}
const textarea = document.getElementById("prompt-area");

textarea.addEventListener("input", function() {
  this.style.height = "auto";
  this.style.height = this.scrollHeight + "px";
});
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save