x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<div class="flex items-center justify-center p-16"> <form data-controller="midwest-form" data-midwest-form-autosave-value="true" data-midwest-form-autosave-delay-value="100" data-midwest-form-ajax-value="true" data-turbo="true" onsubmit="return false" class="flex flex-col gap-4 w-full max-w-sm" action="#" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="XEqekUr4AnZ6gJeY4UFYtcy8m1jlbZTB04L7dJ1a5q2G_hoIdHDJ_IYON56G3Wmy3aCbgiOD6i6jOuO5qGb8GA" autocomplete="off" /> <div class="midwest-input midwest-form-group type-text" data-controller="midwest-input"> <div class="midwest-form-group__top"> <label class="midwest-label " for="username-d4c8"> Username </label> </div> <input type="text" name="username" id="username-d4c8" placeholder="jane_smith" data-midwest-input-target="input" /> </div> <button type="submit" class="midwest-button variant-default size-default fill theme-primary" name="button"> <span class="midwest-button-content">Save</span> <div class="midwest-loading-icon" role="img" aria-label="Loading" aria-hidden="true" style="display: none"> <div class="midwest-loading-icon-inner"> <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <svg viewbox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="Midwest-LoadingIcon__Svg" focusable="false" aria-hidden="true"> <circle cx="15" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="60" cy="15" r="9" fill-opacity="0.3"> <animate attributename="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="105" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> </svg> </div> </div> </button> </form></div>1
2
3
4
5
6
<div class="flex items-center justify-center p-16"> <%= midwest_form_with(url: "#", autosave: 100, ajax: true, html: { onsubmit: "return false", class: "flex flex-col gap-4 w-full max-w-sm" }) do %> <%= midwest_form_input(name: "username", label: "Username", placeholder: "jane_smith") %> <%= midwest_button("Save", as: :submit, fill: true) %> <% end %></div>Autosave & Ajax Form
Demonstrates the opt-in midwestformwith behaviors: autosave: submits in
the background (debounced) on field change, and ajax: emits
midwest-form:success / midwest-form:error events after an in-page submit.
No params configured.
No assets to display.
Add a .js or .css file alongside the component to see it here.
Figma embed for Button/autosave_and_ajax_form
Annotate a preview to embed its Figma design here:
@figma "https://figma.com/..."