Skip to content

Poll form

Preview Available in release assets

Progressively enhance a canonical server-submitted POST form while keeping results, counts, and validation server-owned.

Server contract

POST /api/advanced/marketing-search?view=poll renders the complete native response; a Datastar request to the same action receives the stable server-authored fragment. Preserve the form action, method, names, values, and returned server markup.

The browser performs the ordinary request and renders a complete server response without enhancement.

Poll form primary example

Show code
<section aria-labelledby="poll-title">
  <h2 id="poll-title">Which topic next?</h2>
  <form action="/polls/topics/votes" method="post">
    <fieldset>
      <legend>Choose one topic</legend>
      <label>
        <input type="radio" name="choice" value="fieldwork" required> Fieldwork</label>
        <label>
          <input type="radio" name="choice" value="publishing"> Publishing</label>
        </fieldset>
        <button class="thin-button">Vote</button>
      </form>
      <p class="thin-status">Server-confirmed total: 248 votes</p>
    </section>

Anatomy

  • Named section
  • Native form
  • Server response status
  • Durable result or recovery content

Variants and sizes

  • Default
  • Long content
  • No JavaScript

Gallery coverage: No structured variant fixtures are published yet; the primary example above is the only verified production markup.

Rendered fixtures exercise authored content and constrained layouts with the same production assets.

  • Pending
  • Results
  • Empty
  • Validation error
  • Server error
  • Reconnect
  • Long localized content

Structured state fixtures are not published for this item yet.

Interaction and keyboard behavior

The ordinary form submits normally. Datastar may morph returned HTML and announce only server-confirmed state; it must not calculate result truth, vote totals, or validation.

Accessibility

Keep visible labels, native controls, semantic result headings, useful errors, focus on returned error summaries, and restrained live announcements.

Contract
LIVE
Basis
Native search/poll forms, labelled results, links, radio controls, and status
Evidence
  • tests/unit/site/marketing-search.test.ts

API

POST /api/advanced/marketing-search?view=poll renders the complete native response; a Datastar request to the same action receives the stable server-authored fragment. Preserve the form action, method, names, values, and returned server markup.

Behavior tier: datastar-required

Structured host, property, and example tables are not authored for this item yet. Use the summary above and the primary example.

Fallback

The browser performs the ordinary request and renders a complete server response without enhancement.

Assets and dependencies

  • /foundation.css
  • /layouts.css
  • /components.css
  • /behaviors.js

Dependencies: datastar@1.0.2

Source: packages/ui/src/items/marketing-search/style.ts

Composition

Derived from the examples and style specs, not authored.

Composes