# Fill-in-the-sentence form

> The fields live inside a sentence set in a book typeface, and each blank grows as you type into it.

- Category: [Inputs](https://library.aimran.es/components/inputs)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-in-madlib
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Instead of stacked labels and boxes, this contact form reads like a sentence: your name, your company, a topic and an email fill dashed blanks set in a serif typeface. Each input measures its own text with a hidden twin, so it widens as you write, and an empty blank shakes on submit. It suits studios, portfolios and friendly agencies.

Rewrite the sentence in your own voice and keep four or five blanks at most. Use the main color for the filled words and the button, and leave plenty of line height so the blanks breathe on small screens.

## Code

### HTML

```html
<form class="uvq06-ml"><p class="tx">Hi, my name is <span class="w"><input name="n" aria-label="Your name" placeholder="your name" autocomplete="given-name"><span class="mr" aria-hidden="true"></span></span> and I work at <span class="w"><input name="e" aria-label="Company" placeholder="your company" autocomplete="organization"><span class="mr" aria-hidden="true"></span></span>. I'd like to talk about <span class="w sl"><select aria-label="Topic"><option>a new website</option><option>an app</option><option>a brand</option></select></span>; my email is <span class="w"><input name="m" type="email" aria-label="Email" placeholder="your email" autocomplete="email"><span class="mr" aria-hidden="true"></span></span>.</p><button type="submit" class="go">Send <span aria-hidden="true">→</span></button><p class="ok" aria-live="polite"></p></form>
```

### CSS

```css
.uvq06-ml {
  --c1: #4338ca;
  --c2: #e0e7ff;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq06-ml {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 20em;
}

.uvq06-ml .tx {
  margin: 0;
  font: 400 1.3em/2 Georgia,"Iowan Old Style","Times New Roman",serif;
  letter-spacing: -.005em;
  text-wrap: pretty;
}

.uvq06-ml .w {
  position: relative;
  display: inline-block;
}

.uvq06-ml input,.uvq06-ml select {
  box-sizing: border-box;
  width: 6.5em;
  min-width: 3ch;
  max-width: 14em;
  field-sizing: content;
  margin: 0;
  padding: 0 .12em;
  border: 0;
  border-bottom: 2px dashed color-mix(in srgb,var(--fg) 55%,transparent);
  border-radius: .2em .2em 0 0;
  outline: 0;
  background: none;
  font: inherit;
  font-style: italic;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  transition: border-color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml input::placeholder {
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-ml input:not(:placeholder-shown) {
  font-style: normal;
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
}

.uvq06-ml input:hover,.uvq06-ml select:hover {
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-ml input:focus,.uvq06-ml select:focus {
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
  background: color-mix(in srgb,var(--c1) 14%,transparent);
}

.uvq06-ml select {
  width: auto;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 1.1em;
  font-style: normal;
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
  cursor: pointer;
  field-sizing: content;
}

.uvq06-ml select option {
  color: #111;
  background: #fff;
}

.uvq06-ml .sl::after {
  content: "";
  position: absolute;
  right: .2em;
  top: 52%;
  width: .32em;
  height: .32em;
  border-right: 2px solid var(--c1);
  border-bottom: 2px solid var(--c1);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.uvq06-ml .mr {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0 .12em;
  visibility: hidden;
  white-space: pre;
  font: inherit;
  pointer-events: none;
}

.uvq06-ml .w.no {
  animation: uvq06-ml calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml .w.no input {
  border-bottom-color: #e5484d;
}

.uvq06-ml .go {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: .5em;
  margin-top: 1em;
  padding: .75em 1.3em;
  border-radius: 2em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
  box-shadow: 0 .6em 1.2em -.6em var(--c1);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml .go span {
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ml .go:hover {
  transform: translateY(-2px);
}

.uvq06-ml .go:hover span {
  transform: translateX(.25em);
}

.uvq06-ml .go:active {
  transform: scale(.96);
}

.uvq06-ml .go:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-ml .ok {
  min-height: 1.2em;
  margin: .7em 0 0;
  font-size: .85em;
  font-weight: 650;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
}

@keyframes uvq06-ml {
  25% {
    transform: translateX(-.2em);
  }
  50% {
    transform: translateX(.2em);
  }
  75% {
    transform: translateX(-.1em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-ml,.uvq06-ml *,.uvq06-ml *::before,.uvq06-ml *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq06-ml").forEach(el => {
  const ins=[...el.querySelectorAll("input")],ok=el.querySelector(".ok");
const fit=i=>{const m=i.nextElementSibling;m.textContent=i.value||i.placeholder;i.style.width=m.offsetWidth+6+"px"};
ins.forEach(i=>{i.addEventListener("input",()=>{fit(i);ok.textContent=""});i.addEventListener("focus",()=>fit(i))});
ins[0].value="Lucía";ins.forEach(fit);const t=setTimeout(()=>ins.forEach(fit),400);
el.addEventListener("submit",e=>{e.preventDefault();const bad=ins.find(i=>!i.value.trim()||!i.checkValidity());if(bad){const w=bad.parentElement;w.classList.remove("no");void w.offsetWidth;w.classList.add("no");bad.focus();ok.textContent="";return}ok.textContent="Got it. We'll write back soon."});
return()=>clearTimeout(t)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq06-ml {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 20em;
}

.uvq06-ml .tx {
  margin: 0;
  font: 400 1.3em/2 Georgia,"Iowan Old Style","Times New Roman",serif;
  letter-spacing: -.005em;
  text-wrap: pretty;
}

.uvq06-ml .w {
  position: relative;
  display: inline-block;
}

.uvq06-ml input,.uvq06-ml select {
  box-sizing: border-box;
  width: 6.5em;
  min-width: 3ch;
  max-width: 14em;
  field-sizing: content;
  margin: 0;
  padding: 0 .12em;
  border: 0;
  border-bottom: 2px dashed color-mix(in srgb,var(--fg) 55%,transparent);
  border-radius: .2em .2em 0 0;
  outline: 0;
  background: none;
  font: inherit;
  font-style: italic;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  transition: border-color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml input::placeholder {
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-ml input:not(:placeholder-shown) {
  font-style: normal;
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
}

.uvq06-ml input:hover,.uvq06-ml select:hover {
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-ml input:focus,.uvq06-ml select:focus {
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
  background: color-mix(in srgb,var(--c1) 14%,transparent);
}

.uvq06-ml select {
  width: auto;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 1.1em;
  font-style: normal;
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
  cursor: pointer;
  field-sizing: content;
}

.uvq06-ml select option {
  color: #111;
  background: #fff;
}

.uvq06-ml .sl::after {
  content: "";
  position: absolute;
  right: .2em;
  top: 52%;
  width: .32em;
  height: .32em;
  border-right: 2px solid var(--c1);
  border-bottom: 2px solid var(--c1);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.uvq06-ml .mr {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0 .12em;
  visibility: hidden;
  white-space: pre;
  font: inherit;
  pointer-events: none;
}

.uvq06-ml .w.no {
  animation: uvq06-ml calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml .w.no input {
  border-bottom-color: #e5484d;
}

.uvq06-ml .go {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: .5em;
  margin-top: 1em;
  padding: .75em 1.3em;
  border-radius: 2em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
  box-shadow: 0 .6em 1.2em -.6em var(--c1);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml .go span {
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ml .go:hover {
  transform: translateY(-2px);
}

.uvq06-ml .go:hover span {
  transform: translateX(.25em);
}

.uvq06-ml .go:active {
  transform: scale(.96);
}

.uvq06-ml .go:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-ml .ok {
  min-height: 1.2em;
  margin: .7em 0 0;
  font-size: .85em;
  font-weight: 650;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
}

@keyframes uvq06-ml {
  25% {
    transform: translateX(-.2em);
  }
  50% {
    transform: translateX(.2em);
  }
  75% {
    transform: translateX(-.1em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-ml,.uvq06-ml *,.uvq06-ml *::before,.uvq06-ml *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const ins=[...el.querySelectorAll("input")],ok=el.querySelector(".ok");
const fit=i=>{const m=i.nextElementSibling;m.textContent=i.value||i.placeholder;i.style.width=m.offsetWidth+6+"px"};
ins.forEach(i=>{i.addEventListener("input",()=>{fit(i);ok.textContent=""});i.addEventListener("focus",()=>fit(i))});
ins[0].value="Lucía";ins.forEach(fit);const t=setTimeout(()=>ins.forEach(fit),400);
el.addEventListener("submit",e=>{e.preventDefault();const bad=ins.find(i=>!i.value.trim()||!i.checkValidity());if(bad){const w=bad.parentElement;w.classList.remove("no");void w.offsetWidth;w.classList.add("no");bad.focus();ok.textContent="";return}ok.textContent="Got it. We'll write back soon."});
return()=>clearTimeout(t)
}

export default function InMadlib() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#4338ca",
          "--c2": "#e0e7ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <form className="uvq06-ml"><p className="tx">Hi, my name is <span className="w"><input name="n" aria-label="Your name" placeholder="your name" autoComplete="given-name" /><span className="mr" aria-hidden="true"></span></span> and I work at <span className="w"><input name="e" aria-label="Company" placeholder="your company" autoComplete="organization" /><span className="mr" aria-hidden="true"></span></span>. I'd like to talk about <span className="w sl"><select aria-label="Topic"><option>a new website</option><option>an app</option><option>a brand</option></select></span>; my email is <span className="w"><input name="m" type="email" aria-label="Email" placeholder="your email" autoComplete="email" /><span className="mr" aria-hidden="true"></span></span>.</p><button type="submit" className="go">Send <span aria-hidden="true">→</span></button><p className="ok" aria-live="polite"></p></form>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Fill-in-the-sentence form” block (Inputs) from AIMRAN Library to my project.

## What it is
The fields live inside a sentence set in a book typeface, and each blank grows as you type into it.

## Chosen settings
- Main color: #4338ca
- Secondary color: #e0e7ff
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Send"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq06-ml {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 20em;
}

.uvq06-ml .tx {
  margin: 0;
  font: 400 1.3em/2 Georgia,"Iowan Old Style","Times New Roman",serif;
  letter-spacing: -.005em;
  text-wrap: pretty;
}

.uvq06-ml .w {
  position: relative;
  display: inline-block;
}

.uvq06-ml input,.uvq06-ml select {
  box-sizing: border-box;
  width: 6.5em;
  min-width: 3ch;
  max-width: 14em;
  field-sizing: content;
  margin: 0;
  padding: 0 .12em;
  border: 0;
  border-bottom: 2px dashed color-mix(in srgb,var(--fg) 55%,transparent);
  border-radius: .2em .2em 0 0;
  outline: 0;
  background: none;
  font: inherit;
  font-style: italic;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  transition: border-color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml input::placeholder {
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-ml input:not(:placeholder-shown) {
  font-style: normal;
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
}

.uvq06-ml input:hover,.uvq06-ml select:hover {
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-ml input:focus,.uvq06-ml select:focus {
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
  background: color-mix(in srgb,var(--c1) 14%,transparent);
}

.uvq06-ml select {
  width: auto;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 1.1em;
  font-style: normal;
  border-bottom-style: solid;
  border-bottom-color: var(--c1);
  cursor: pointer;
  field-sizing: content;
}

.uvq06-ml select option {
  color: #111;
  background: #fff;
}

.uvq06-ml .sl::after {
  content: "";
  position: absolute;
  right: .2em;
  top: 52%;
  width: .32em;
  height: .32em;
  border-right: 2px solid var(--c1);
  border-bottom: 2px solid var(--c1);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.uvq06-ml .mr {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0 .12em;
  visibility: hidden;
  white-space: pre;
  font: inherit;
  pointer-events: none;
}

.uvq06-ml .w.no {
  animation: uvq06-ml calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml .w.no input {
  border-bottom-color: #e5484d;
}

.uvq06-ml .go {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: .5em;
  margin-top: 1em;
  padding: .75em 1.3em;
  border-radius: 2em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
  box-shadow: 0 .6em 1.2em -.6em var(--c1);
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ml .go span {
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ml .go:hover {
  transform: translateY(-2px);
}

.uvq06-ml .go:hover span {
  transform: translateX(.25em);
}

.uvq06-ml .go:active {
  transform: scale(.96);
}

.uvq06-ml .go:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-ml .ok {
  min-height: 1.2em;
  margin: .7em 0 0;
  font-size: .85em;
  font-weight: 650;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
}

@keyframes uvq06-ml {
  25% {
    transform: translateX(-.2em);
  }
  50% {
    transform: translateX(.2em);
  }
  75% {
    transform: translateX(-.1em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-ml,.uvq06-ml *,.uvq06-ml *::before,.uvq06-ml *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const ins=[...el.querySelectorAll("input")],ok=el.querySelector(".ok");
const fit=i=>{const m=i.nextElementSibling;m.textContent=i.value||i.placeholder;i.style.width=m.offsetWidth+6+"px"};
ins.forEach(i=>{i.addEventListener("input",()=>{fit(i);ok.textContent=""});i.addEventListener("focus",()=>fit(i))});
ins[0].value="Lucía";ins.forEach(fit);const t=setTimeout(()=>ins.forEach(fit),400);
el.addEventListener("submit",e=>{e.preventDefault();const bad=ins.find(i=>!i.value.trim()||!i.checkValidity());if(bad){const w=bad.parentElement;w.classList.remove("no");void w.offsetWidth;w.classList.add("no");bad.focus();ok.textContent="";return}ok.textContent="Got it. We'll write back soon."});
return()=>clearTimeout(t)
}

export default function InMadlib() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#4338ca",
          "--c2": "#e0e7ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <form className="uvq06-ml"><p className="tx">Hi, my name is <span className="w"><input name="n" aria-label="Your name" placeholder="your name" autoComplete="given-name" /><span className="mr" aria-hidden="true"></span></span> and I work at <span className="w"><input name="e" aria-label="Company" placeholder="your company" autoComplete="organization" /><span className="mr" aria-hidden="true"></span></span>. I'd like to talk about <span className="w sl"><select aria-label="Topic"><option>a new website</option><option>an app</option><option>a brand</option></select></span>; my email is <span className="w"><input name="m" type="email" aria-label="Email" placeholder="your email" autoComplete="email" /><span className="mr" aria-hidden="true"></span></span>.</p><button type="submit" className="go">Send <span aria-hidden="true">→</span></button><p className="ok" aria-live="polite"></p></form>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
