Examples

A broad collection of examples with working code you can use in your project today.

Forms & structure

Add classes to the FormKit-provided submit button

The form type automatically adds a submit button. Add classes so its UI can conform to your project's styles

Using a list to repeat an input

Using the list type, we can create repeater inputs that can have multiple values. This example uses a loop to let users add/remove email addresses.

Schema

Conditionally show input based on value of another input

Use the FormKitSchema component to conditionally show an input (with validation rules) based on the value of another input.

Multi-step form built from Schema

Use the FormKitSchema component to render the multi-step form from the multi-step form guide.

Custom schema submit button with disabled state and loading spinner

Create a custom schema-powered submit button that dynamically disables while the form is submitting and provides a loading spinner.

Add a maxlength coutdown to a textarea

Adds a simple countdown of characters left in a textarea with a hover tooltip based on the textarea's maxlength prop

Plugins

Add an asterisk to the labels of all required inputs

Use a plugin to add an asterisk (*) to the label area of inputs that have the "required" rule.

Cast number inputs values from strings to numbers

Use a plugin to cast string values to numbers. Useful if you want inputs of type number to return a JS Number primitive.

Add an icon before validation messages

Use a plugin to append an icon before validation messages by extending the schema definition.

Set initial values to empty strings instead of undefined

Use a plugin to set all initial input values to an empty string "" instead of undefined.

Add a manually toggleable loading spinner to 'button'-type inputs

Use a plugin to allow inputs in the button family to have a loading spinner that can be toggled at-will with a new loading prop.

Automatically set an input's name, label, and help text based on the id

Use a plugin to automatically set an input's name, label, and help props based on the id. Reduces repetitive prop declarations in your HTML.

Adds attribute for libraries like @testing-library for testing

A plugin that adds the attribute data-testid with the node id for testing libraries.

Scroll to the first validation or error on the form.

A plugin that automatically scrolls to the first error on the page on submit or when backend errors are added.

Adds attributes to prevent autofill from password managers 1Password and LastPass

A plugin that adds the attributes data-1p-ignore and data-lpignore to prevent autofill (you of course can add these yourself; this plugin automatically applies them to every email and password input).

Inputs

Number input with custom step buttons

A custom input with +1 and -1 step buttons. Made using createInput().

Add a link (<a> tag) to a label

Use slots or the :sections-schema feature to modify a label's HTML.

Conditionally update options of a select input

Conditionally update the options of a select input based on the value of another input.

Style radio input options to look like cards

Using only new styles (Tailwind Classes in this example) apply a card treatment to the default FormKit Radio input structure.

User interface

Add a loading indicator for async validation rules

Add a loading spinner to your input when an async validation rule is pending validation.

Keep submit button disabled until a form changes

Only enable a save/submit button if a user has changed any value inside a form.

Add transitions to validation messages

Add transitions to validation messages by injecting a Vue TransitionGroup component using FormKit's :sections-schema.

Starter project with Nuxt, FormKit, and Tailwind

A working starter project on StackBlitz with Nuxt, FormKit and Tailwind CSS.

Produce dynamic classes based on an input's state

Use the classes config object and FormKit props to produce a dynamic classes based on input state. Helpful for Tailwind and other CSS utility libraries.

Create reactive UI variations of FormKit inputs using “features”

Create UI variations of FormKit inputs (like buttons) that update based on reactive data in your components.