Skip to the content

Form 01

A contact form with underline fields. Each label rests in the line of its field like a placeholder and floats up to its place when the field takes the focus or a value; a line is drawn under the field from the left on focus and leaves by the right; a tick draws itself at the end of a field that is right; a wrong field turns its line and label red, and its reason takes the place of the hint under it, then leaves at the keystroke that fixes it, so nothing below ever moves.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    The look of the preview is the form-set-* classes of the paste: the fields at rest and the button. The Embed holds what moves, and it reads its colours from five variables, --form-set-ink, --form-set-ground, --form-set-rule, --form-set-accent and --form-set-error: set them on the form, or on anything above it, in a rule of your own. The send button is a Link block, because a Webflow submit button is an input and cannot hold the layers that move; the script makes it send the form, and Enter in a field does too.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-form-set Marks the form. It takes no value: leave the value field empty. In the paste it is on the Form inside the Form block. The settings below go on the same element.
    data-form-set-field On the box of one field: one label and one control (a text, email or phone input, a select, a textarea), with its hint when it has one. It takes no value. The engine writes the state on it and adds what it draws inside it. A control outside such a box is sent with the form but has no state and is not checked. [ Required ]
    data-form-set-field="check" On the label that holds a checkbox and its sentence. A required box left empty is refused with the words of the setting check. [ Optional ]
    data-form-set-submit On the send button: a submit button in plain HTML, a Link block in Webflow, which has no button that can hold layers. It takes no value. Without it the form is still checked when it is sent, by Enter for one, but nothing shows it leaving. [ Required ]
    data-form-set-hint On the line of help under a control. It takes no value. The reason takes its place while the field is wrong, then the hint comes back. A field without one gets a line from the engine, dressed like the first hint of the form. [ Optional ]
    data-form-set-fit On a field whose control is as wide as what is written in it, for a control set in a line of text. It takes no value. [ Optional ]
    data-form-set-required="Your name, please." On one field: its own words for a reason, in place of the form's. The same goes for email, tel, short, pattern and check. [ Optional ]
    data-form-set-select="native" On one field: leaves its select to the list of the system, in place of the list the engine draws. On the form it is the setting select, for every select at once. A touch screen gets the system's picker either way, and the native select is what the form sends in both cases. [ Optional ]
    data-form-set-dialog Optional, for a form that opens in a dialog as Form 03 does: on a layer that holds a panel, the panel holding the form. With no value the panel rises in the middle of the window; with the value sheet, data-form-set-dialog="sheet", it slides in from the right. The stylesheet lays the layer over the window and hides it until it is opened. [ Optional ]
    data-form-set-open On what opens the dialog: any button or link, anywhere on the page, as many as you like. It takes no value, or the id of the dialog when the page has several: data-form-set-open="quote". [ Optional ]
    data-form-set-close On what closes the dialog, inside it. It takes no value, or cross to draw a cross in place of its word, which stays its name for a screen reader. Escape and a click outside the panel close it too, and so does the form, the time of the setting closeAfter after it was sent. [ Optional ]
    data-form-set-state Written by the engine. On a field: up, focus, filled, valid, error, disabled, several at once. On the send button: loading, done or failed. On the form: done. On a dialog: open. A field whose list is open also carries data-form-set-list="open". Never written by hand; the stylesheet reads them, and so can a rule of yours. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-form-set-send auto How the form leaves once every field is right. Options: auto lets a Webflow Form block send it to Webflow, and anywhere else posts the form to its action the usual way, the page changing; fetch posts the values to the action without leaving the page and reads the status of the answer.
    data-form-set-sending Sending The word on the button while the form is on its way. Options: any text, in the language of the page.
    data-form-set-sent Sent The word on the button once the form has left, beside the tick. Options: any text.
    data-form-set-failed Try again The word on the button when the send failed; the button can be pressed again. Options: any text.
    data-form-set-required This field is required. The reason under a required field left empty. Options: any text; data-form-set-required on one field gives it its own, "Your name, please.".
    data-form-set-email Enter a valid email address. The reason under a field of type email that does not hold an address. Options: any text.
    data-form-set-tel Enter a valid phone number. The reason under a field of type tel that does not hold a phone number, six digits at least. Options: any text.
    data-form-set-short A little more, please. The reason under a text shorter than the minlength of its control. Options: any text.
    data-form-set-pattern Check the format. The reason under a text the pattern of its control refuses. Options: any text; say the format expected, "Two letters, then four digits.".
    data-form-set-check Please tick this box. The reason under a required checkbox left empty. Options: any text.
    data-form-set-select drawn The list a select opens. Options: drawn, a list the engine draws under the control in the colours of the form, the native select staying underneath; native, the list of the system, which a touch screen gets either way. data-form-set-select="native" on one field leaves that select alone.
    data-form-set-close-after 2400 How long a dialog stays on the answer once its form is sent, in milliseconds. Only read by a form in a dialog.
    The way the form is sent
    Nothing to connect: the paste is a native Webflow Form block, and Webflow receives what it sends. The entries are listed in Site settings, Forms, each field under the name of its label, and the address told of a new entry is set in the same place, under Form notifications. Entries only arrive from a published site, its webflow.io address included: the Designer and its preview send nothing. Once Webflow has the entry it hides the form and shows its Success message; when it could not, it shows its Error message and the button says Try again. Both are Webflow's own blocks, under the Form in the Navigator: select the Form block, open its settings and choose the state to see, restyle and rewrite each one. To add a field, duplicate a field block and give the new field its own name in its settings; to remove one, delete its block; Required is a switch in the same settings. Leave the Action of the form empty, or Webflow receives nothing. Only when the form is not a Webflow Form block do the attributes below apply.
    Custom attributeWhat it does
    action="https://..." On the form: the address the values are posted to, an endpoint of your own or one of a form service such as Formspree or Basin. Not a custom attribute in Webflow, where it is the Action field of the Form settings, to leave empty for Webflow to receive the entries.
    data-form-set-send="fetch" On the form: posts the values to the action without leaving the page, as FormData, with the header Accept: application/json. An answer in the 200s shows Sent, anything else Try again. It is the setting send, so it may also be set for the whole site.
    method="post" On the form: how the values are sent, POST when nothing is written. With GET and fetch they travel in the address.

What it does

Form 01 is an animated form for Webflow and vanilla JavaScript, with no library. Also called animated contact form, floating label form or underline input animation.

A contact form with underline fields. Each label rests in the line of its field like a placeholder and floats up to its place when the field takes the focus or a value; a line is drawn under the field from the left on focus and leaves by the right; a tick draws itself at the end of a field that is right; a wrong field turns its line and label red, and its reason takes the place of the hint under it, then leaves at the keystroke that fixes it, so nothing below ever moves. The textarea grows with its text and counts its characters, the select turns its chevron, the checkbox draws its tick. The fields are checked as the visitor leaves them, with what the controls already say: required, an email, a phone number, a minimum length, a pattern. The send button has a plate of colour that rises on hover, shakes its head once when a field is still wrong, runs a bar while the form leaves, then says Sent with a tick, or Try again. It is a real form: pasted in Webflow it is a native Form block whose entries land in the site's Forms tab; elsewhere it posts to its action, with fetch or the usual way, or hands the values to the page. Labels, reasons read out by a screen reader, keyboard throughout, reduced motion respected. No library. Form 01 of the Form set. Pattern type contact form, floating label, form validation.

Updated

Questions

Paste the form: it arrives as a native Webflow Form block whose Form carries data-form-set, each field sitting in a block marked data-form-set-field with its label and its control. The label rests in the line of the field and floats up when the field takes the focus or a value, and a line is drawn under the field from the left.

Yes. The paste is a real Form block with no action, so Webflow receives it: the entries are listed in Site settings, Forms, each field under the name of its label, and the notification address is set there. Entries only arrive from a published site, and the success and error messages are Webflow's own two blocks.

Yes. Outside a Webflow Form block the form posts to its action; with data-form-set-send="fetch" it posts there without leaving the page and the button shows Sent or Try again from the status of the answer. A listener on formset:submit can also send the values itself and call detail.done(true).

It reads what the control already says: required, type="email", type="tel", minlength and pattern. A field is checked when the visitor leaves it and again at every key while it is wrong; the reason replaces the hint under the field, and each one is a setting such as data-form-set-required or data-form-set-email on the form or on one field.

A native Webflow Submit button is an input, which cannot hold the plate that rises on hover, the label and the running bar. The paste uses a Link block marked data-form-set-submit, and the script makes it send the form; Enter in a field sends it too.