kitbash Sign in Connect agent
Components

Green bar enquiry

An email field and a green gradient send bar in a grey tray; sending slides a small toast up from the tray.

Part of the style

Rainbow Slot Ticker

6 parts that belong together, with their tokens, type and rules.

Preview

Code
<section class="toast-form" aria-labelledby="toast-form-title" data-sent="Thanks. We will write back within two market days." data-empty="Add an email address so we can reply.">
  <div class="toast-form__box">
    <h2 class="toast-form__title" id="toast-form-title">Start a project</h2>
    <p class="toast-form__lede">Tell us about your stall, shop or season. One line is enough.</p>
    <form class="toast-form__tray" novalidate>
      <label class="toast-form__field">
        <span class="toast-form__label">Email</span>
        <input class="toast-form__input" type="email" name="email" placeholder="you@yourshop.example" autocomplete="email" />
      </label>
      <label class="toast-form__field">
        <span class="toast-form__label">What are you making?</span>
        <textarea class="toast-form__input toast-form__area" name="note" rows="3" placeholder="A cider label, a winter menu, a whole new stall"></textarea>
      </label>
      <div class="toast-form__pick" role="group" aria-label="Budget">
        <label class="toast-form__option"><input type="radio" name="size" value="s" checked /><span>Small</span></label>
        <label class="toast-form__option"><input type="radio" name="size" value="m" /><span>Medium</span></label>
        <label class="toast-form__option"><input type="radio" name="size" value="l" /><span>Large</span></label>
      </div>
      <button class="toast-form__send" type="submit">
        <span class="toast-form__word">Send</span>
        <span class="toast-form__hint">replies in 2 days</span>
      </button>
    </form>
  </div>
  <p class="toast-form__toast" role="status" aria-live="polite"></p>
</section>

<style>
  .toast-form {
    position: relative;
    display: grid;
    place-items: center;
    padding: var(--space-xl) var(--edge) var(--section-space);
    overflow: hidden;
  }
  .toast-form__box {
    width: min(448px, 100%);
  }
  .toast-form__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: var(--text-xl);
    font-weight: 400;
    line-height: 1.1;
  }
  .toast-form__lede {
    margin: var(--space-s) 0 var(--space-l);
    color: var(--ink-soft);
  }
  .toast-form__tray {
    display: grid;
    gap: var(--space-m);
    padding: var(--space-m);
    border-radius: var(--radius-l);
    background: var(--tray);
  }
  .toast-form__field {
    display: grid;
    gap: var(--space-xs);
  }
  .toast-form__label {
    color: var(--ink-soft);
    font-size: var(--text-s);
  }
  .toast-form__input {
    width: 100%;
    min-height: var(--hit);
    padding: 10px var(--space-m);
    border: var(--rule) solid var(--tray-line);
    border-radius: var(--radius-m);
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    transition: border-color var(--quick) var(--ease);
  }
  .toast-form__area {
    resize: vertical;
  }
  .toast-form__input::placeholder {
    color: var(--ink-soft);
  }
  .toast-form__input:focus {
    border-color: var(--blue);
    outline: none;
  }
  .toast-form__input.is-wrong {
    border-color: var(--red);
  }
  .toast-form__pick {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .toast-form__option {
    position: relative;
  }
  .toast-form__option input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }
  .toast-form__option span {
    display: grid;
    place-items: center;
    min-height: var(--hit);
    border: var(--rule) solid var(--tray-line);
    border-radius: var(--radius-m);
    background: var(--paper);
    cursor: pointer;
    transition: color var(--quick) var(--ease), border-color var(--quick) var(--ease);
  }
  .toast-form__option:nth-child(1) { --word: var(--green); }
  .toast-form__option:nth-child(2) { --word: var(--blue); }
  .toast-form__option:nth-child(3) { --word: var(--pink); }
  .toast-form__option span:hover {
    color: var(--word);
  }
  .toast-form__option input:checked + span {
    border-color: var(--word);
    color: var(--word);
  }
  .toast-form__option input:focus-visible + span {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
  }
  .toast-form__send {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 52px;
    padding: 0 var(--space-l) 0 var(--space-m);
    border: var(--rule) solid var(--lime);
    border-radius: var(--radius-m);
    background: linear-gradient(var(--lime-light), var(--lime));
    color: var(--lime-text);
    font: inherit;
    cursor: pointer;
    transition: filter var(--quick) var(--ease), transform var(--quick) var(--ease), border-color var(--quick) var(--ease);
  }
  .toast-form__send:hover {
    filter: saturate(1.25);
    border-color: var(--lime-dark);
  }
  .toast-form__send:active {
    transform: translateY(1px);
  }
  .toast-form__send:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
  }
  .toast-form__word {
    font-family: var(--font-serif);
    font-size: var(--text-l);
    line-height: 1.4;
  }
  .toast-form__hint {
    color: var(--lime-text-soft);
  }
  .toast-form__toast {
    position: absolute;
    bottom: var(--space-l);
    left: 50%;
    max-width: calc(100% - 2 * var(--edge));
    margin: 0;
    padding: 10px var(--space-l);
    border: var(--rule) solid var(--tray-line);
    border-radius: var(--radius-l);
    background: var(--paper);
    box-shadow: 0 8px 24px var(--shade);
    opacity: 0;
    transform: translate(-50%, 140%);
    transition: opacity var(--fade-time) var(--ease), transform var(--fade-time) var(--ease);
    pointer-events: none;
  }
  .toast-form__toast.is-shown {
    opacity: 1;
    transform: translate(-50%, 0);
  }
</style>

<script>
  (() => {
    for (const root of document.querySelectorAll('.toast-form')) {
      const form = root.querySelector('.toast-form__tray');
      const email = root.querySelector('input[type="email"]');
      const toast = root.querySelector('.toast-form__toast');
      let timer = 0;
      const say = (text) => {
        toast.textContent = text;
        toast.classList.add('is-shown');
        clearTimeout(timer);
        timer = setTimeout(() => toast.classList.remove('is-shown'), 2600);
      };
      email.addEventListener('input', () => email.classList.remove('is-wrong'));
      form.addEventListener('submit', (event) => {
        event.preventDefault();
        if (!email.value.includes('@')) {
          email.classList.add('is-wrong');
          email.focus();
          say(root.dataset.empty);
          return;
        }
        form.reset();
        say(root.dataset.sent);
      });
    }
  })();
</script>

Similar components

Sign-up

Sign-up

Postcard with signature pad

Postcard with signature pad

Enquiry sheet

Enquiry sheet

Send a note

Send a note

Jelly button sign-up

Jelly button sign-up

Suggest form card

Suggest form card

Sentence sign-up

Sentence sign-up

Monday page

Monday page