← Back to Forms

Forms pattern

Labeled contact form

A compact form with persistent labels, useful instructions, and visible field focus.

Live example

See the pattern in isolation

The preview uses the same locked-down composition policy as the Agate IDE.

PreviewSandboxed

Canonical source

Copy it, change it, keep it plain

These exact files power the preview and the IDE handoff.

Source

HTML

<form class="contact-form" method="post" aria-labelledby="contact-title" aria-describedby="contact-help">
  <header>
    <p class="contact-form__eyebrow">Send a note</p>
    <h1 id="contact-title">Tell us what you are making.</h1>
    <p id="contact-help">All fields are required. We usually reply within two working days.</p>
  </header>

  <div class="field-row">
    <div class="field">
      <label for="name">Name</label>
      <input id="name" name="name" autocomplete="name" required>
    </div>
    <div class="field">
      <label for="email">Email</label>
      <input id="email" name="email" type="email" autocomplete="email" required>
    </div>
  </div>

  <div class="field">
    <label for="message">Project note</label>
    <p id="message-help">Include the goal and the part that feels unresolved.</p>
    <textarea id="message" name="message" rows="5" aria-describedby="message-help" required></textarea>
  </div>

  <button type="submit">Send project note</button>
</form>
Source

CSS

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: clamp(1rem, 5vw, 3rem);
  background: #f2e3de;
  color: #2b151d;
  font-family: system-ui, sans-serif;
}

.contact-form {
  width: min(100%, 42rem);
  margin-inline: auto;
  padding: clamp(1.25rem, 5vw, 3rem);
  border: 4px solid #2b151d;
  background: #f7efe6;
}

.contact-form__eyebrow {
  margin: 0 0 0.6rem;
  color: #8e2f50;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#contact-help {
  max-width: 42ch;
  margin: -0.75rem 0 1.5rem;
  color: #5c3b45;
  line-height: 1.55;
}

.contact-form h1 {
  max-width: 13ch;
  margin: 0 0 2rem;
  font-size: clamp(2rem, 7vw, 3.5rem);
  line-height: 1.05;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 850;
}

.field p {
  margin: -0.1rem 0 0.5rem;
  color: #7a5560;
  font-size: 0.85rem;
}

.field input,
.field textarea {
  width: 100%;
  border: 2px solid #2b151d;
  background: #ffffff;
  color: #2b151d;
  font: inherit;
}

.field input {
  min-height: 3rem;
  padding: 0.6rem 0.75rem;
}

.field textarea {
  min-height: 8rem;
  padding: 0.75rem;
  resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible,
.contact-form button:focus-visible {
  outline: 4px solid #d94f9d;
  outline-offset: 3px;
}

.contact-form button {
  min-height: 3rem;
  padding: 0.7rem 1.1rem;
  border: 2px solid #2b151d;
  background: #b0436a;
  color: #f7efe6;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.contact-form button:hover {
  background: #8e2f50;
}

@media (max-width: 34rem) {
  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

How it works

A small pattern with visible decisions

Every field keeps a visible label instead of relying on placeholder text. The short instruction is connected to the message field with aria-describedby.

The grid becomes two columns only when there is comfortable room. Required fields are described in text as well as by the browser’s native validation. Connect the form to a real processing endpoint before publishing it.

Make it yours

Open both files in the workspace.

Agate will protect different saved work before loading this example.