Survey Prompt

In-app request to answer questions.

What almost stopped you from signing up today?

html

<div class="sv-frame">
  <div class="sv sv--corner" style="--accent:#BFD9F2;">
    <button type="button" class="sv__close" aria-label="Not now">×</button>
    <p class="sv__question">What almost stopped you from signing up today?</p>
    <textarea class="sv__input" placeholder="Type your answer…" aria-label="Type your answer…" rows="2"></textarea>
    <div class="sv__actions">
      <button type="button" class="sv__skip">Not now</button>
      <button type="button" class="sv__submit">Send</button>
    </div>
  </div>
</div>
<style>
.sv-frame { position: relative; font: 16px/1.5 system-ui, sans-serif; color: #241430; width: 400px; height: 220px; background: #FAF7F2; border-radius: 14px; border: 1px solid #24143018; overflow: hidden; }
.sv { position: absolute; background: #fff; border-radius: 12px; box-shadow: 0 10px 26px rgba(36,20,48,.2); padding: 16px 18px; }
.sv--corner { width: 230px; right: 16px; bottom: 16px; }
.sv--banner { left: 0; right: 0; top: 0; border-radius: 0; display: flex; align-items: center; gap: 14px; padding: 12px 18px; }
.sv--banner .sv__question { margin: 0; flex: 1; }
.sv--banner .sv__input { display: none; }
.sv--center { width: 260px; left: 50%; top: 50%; transform: translate(-50%,-50%); }
.sv__close { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border: none; background: transparent; color: #24143070; font-size: 14px; cursor: pointer; border-radius: 6px; }
.sv--banner .sv__close { position: static; margin-left: 6px; }
.sv__close:hover, .sv__close:focus-visible { background: #24143012; color: #241430; }
.sv__question { margin: 0 0 10px; font-size: 13.5px; font-weight: 700; padding-right: 18px; }
.sv__input { width: 100%; box-sizing: border-box; border: 1.5px solid #24143025; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 12.5px; resize: none; margin-bottom: 10px; }
.sv__input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sv__actions { display: flex; justify-content: flex-end; gap: 8px; }
.sv--banner .sv__actions { justify-content: flex-start; }
.sv__skip { background: none; border: 1.5px solid #24143025; border-radius: 7px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.sv__submit { background: var(--accent); border: 1.5px solid var(--accent); border-radius: 7px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
</style>

tailwind

<div class="sv-tw-frame relative font-sans text-[#241430] w-[400px] h-[220px] bg-[#FAF7F2] rounded-2xl border border-[#24143018] overflow-hidden">
  <div class="sv-tw sv-tw--corner absolute bg-white rounded-xl shadow-[0_10px_26px_rgba(36,20,48,.2)] p-4" style="--accent:#BFD9F2">
    <button type="button" class="sv-tw__close absolute top-2 right-2 w-5.5 h-5.5 rounded-md text-[#24143070] hover:bg-[#24143012] hover:text-[#241430]" aria-label="Not now">×</button>
    <p class="sv-tw__question m-0 mb-2.5 text-[13.5px] font-bold pr-4.5">What almost stopped you from signing up today?</p>
    <textarea class="sv-tw__input w-full box-border border-[1.5px] border-[#24143025] rounded-lg px-2.5 py-2 text-xs mb-2.5" placeholder="Type your answer…" aria-label="Type your answer…" rows="2"></textarea>
    <div class="flex justify-end gap-2">
      <button type="button" class="rounded-lg px-3 py-1.5 text-xs font-semibold border-[1.5px] border-[#24143025]">Not now</button>
      <button type="button" class="rounded-lg px-3 py-1.5 text-xs font-semibold" style="background:#BFD9F2;border:1.5px solid #BFD9F2">Send</button>
    </div>
  </div>
</div>
<style>
.sv-tw--corner { width: 230px; right: 16px; bottom: 16px; }
.sv-tw--banner { left: 0; right: 0; top: 0; border-radius: 0; }
.sv-tw--banner .sv-tw__input { display: none; }
.sv-tw--center { width: 260px; left: 50%; top: 50%; transform: translate(-50%,-50%); }
</style>

react

export function SurveyPrompt({
  question = "What almost stopped you from signing up today?",
  placeholder = "Type your answer…",
  accent = "#BFD9F2",
  position = "corner",
  dismissLabel = "Not now",
}) {
  const pos = {
    corner: { width: 230, right: 16, bottom: 16 },
    banner: { left: 0, right: 0, top: 0, borderRadius: 0, display: "flex", alignItems: "center", gap: 14 },
    center: { width: 260, left: "50%", top: "50%", transform: "translate(-50%,-50%)" },
  }[position] ?? {};
  const isBanner = position === "banner";
  return (
    <div style={{ position: "relative", fontFamily: "system-ui, sans-serif", color: "#241430", width: 400, height: 220, background: "#FAF7F2", borderRadius: 14, border: "1px solid #24143018", overflow: "hidden" }}>
      <div style={{ position: "absolute", background: "#fff", borderRadius: 12, boxShadow: "0 10px 26px rgba(36,20,48,.2)", padding: isBanner ? "12px 18px" : "16px 18px", ...pos }}>
        <button type="button" aria-label={dismissLabel} style={{ position: "absolute", top: 8, right: 8, width: 22, height: 22, border: "none", background: "transparent", color: "#24143070", fontSize: 14, borderRadius: 6, cursor: "pointer" }}>×</button>
        <p style={{ margin: isBanner ? 0 : "0 0 10px", fontSize: 13.5, fontWeight: 700, paddingRight: isBanner ? 0 : 18, flex: isBanner ? 1 : "initial" }}>{question}</p>
        {!isBanner && (
          <textarea placeholder={placeholder} aria-label={placeholder} rows={2} style={{ width: "100%", boxSizing: "border-box", border: "1.5px solid #24143025", borderRadius: 8, padding: "8px 10px", fontSize: 12.5, resize: "none", marginBottom: 10 }} />
        )}
        <div style={{ display: "flex", justifyContent: isBanner ? "flex-start" : "flex-end", gap: 8 }}>
          <button type="button" style={{ background: "none", border: "1.5px solid #24143025", borderRadius: 7, padding: "6px 12px", fontSize: 12, fontWeight: 600, cursor: "pointer" }}>{dismissLabel}</button>
          {!isBanner && (
            <button type="button" style={{ background: accent, border: "1.5px solid " + accent, borderRadius: 7, padding: "6px 12px", fontSize: 12, fontWeight: 600, cursor: "pointer" }}>Send</button>
          )}
        </div>
      </div>
    </div>
  );
}