Pro installation quickstart 🚀

    Basic example

    The repeater input is for repeating groups of inputs. You can use any number of FormKit inputs within a repeater, and repeaters themselves can be infinitely nested.

    By default, the repeater input has the ability to shift, add, and remove items:

    Load Live Example

    Unlike most other FormKit input types, the repeater input is of type list. You can see above that the users property (our repeater's value) is an array.

    Add button attrs

    In the previous example, the 'Add Users' button is provided by default, and the button label is derived from the repeater's label. We're able to customize the label by using the add-button prop and setting it to a string, or remove it completely by setting it to false. Alternatively, similar to the submit-attrs prop on the FormKit's forms, we can provide an object of attributes to be applied to the button with add-attrs. In this example, we change the label of the repeater from Add Users to My custom label using the add-label prop:

    Load Live Example

    Min/max

    Like many other FormKit inputs, the repeater comes with a min and max prop. You can use these props to limit the number of items to be added or removed.

    Load Live Example

    Controls

    The repeater input by default comes with a set of controls that allow you to shift, add, and remove items. You can control the visibility of these controls by setting the upControl, downControl, insertControl, and removeControl props to true or false.

    Load Live Example

    Custom controls

    With FormKit's repeater, you are not restricted to our default controls. You can manipulate the repeater in anyway you want:

    Load Live Example

    Setting errors

    You can set errors on a repeater or any repeatable item using dot notation. Here we are using the setErrors helper, but there are other methods as well:

    Remember, your submit handler is passed the form's core node and can be used to conveniently set errors at depth. Read more about error handling here. Here's an example of a fake backend returning errors for both the repeater and one child:

    Load Live Example

    Props & Attributes

    Prop Type Default Description
    add-labelstringnullUsed to change the label of the add button.
    add-attrsobject{}Used to apply attributes to the add button element.
    add-buttonbooleantrueConditional for whether to show the add button.
    up-controlbooleantrueConditional for whether to show the up control.
    down-controlbooleantrueConditional for whether to show the down control.
    insert-controlbooleanfalseConditional for whether to show the insert control.
    remove-controlbooleantrueConditional for whether to show the remove control.
    minNumber1The minimum number of children.
    maxNumbernullThe maximum number of children.
    Show universal props
    configObject{}Configuration options to provide to the input’s node and any descendent node of this input.
    delayNumber20Number of milliseconds to debounce an input’s value before the commit hook is dispatched.
    errorsArray[]Array of strings to show as error messages on this field.
    helpString''Text for help text associated with the input.
    idStringinput_{n}The unique id of the input. Providing an id also allows the input’s node to be globally accessed.
    ignoreBooleanfalsePrevents an input from being included in any parent (group, list, form etc). Useful when using inputs for UI instead of actual values.
    indexNumberundefinedAllows an input to be inserted at the given index if the parent is a list. If the input’s value is undefined, it inherits the value from that index position. If it has a value it inserts it into the lists’s values at the given index.
    labelString''Text for the label element associated with the input.
    nameStringinput_{n}The name of the input as identified in the data object. This should be unique within a group of fields.
    parentFormKitNodecontextualBy default the parent is a wrapping group, list or form — but this props allows explicit assignment of the parent node.
    prefix-iconString''Specifies an icon to put in the prefixIcon section.
    preservebooleanfalsePreserves the value of the input on a parent group, list, or form when the input unmounts.
    preserve-errorsbooleanfalseBy default errors set on inputs using setErrors are automatically cleared on input, setting this prop to true maintains the error until it is explicitly cleared.
    sections-schemaObject{}An object of section keys and schema partial values, where each schema partial is applied to the respective section.
    suffix-iconString''Specifies an icon to put in the suffixIcon section.
    typeStringtextThe type of input to render from the library.
    validationString, Array[]The validation rules to be applied to the input.
    validation-visibilityStringblurDetermines when to show an input's failing validation rules. Valid values are blur, dirty, and live.
    validation-labelString{label prop}Determines what label to use in validation error messages, by default it uses the label prop if available, otherwise it uses the name prop.
    validation-rulesObject{}Additional custom validation rules to make available to the validation prop.
    valueAnyundefinedSeeds the initial value of an input and/or its children. Not reactive. Can seed entire groups (forms) and lists..

    Sections

    You can target a specific section of an input using that section's "key", allowing you to modify that section's classes, HTML (via :sections-schema), or content (via slots). Read more about sections here.

      Guests
      Note guests you will bring to the race track.
      Repeated fields here.
      🗑
      Add guest
      Sorry, you may not add more than 3 guests.
        Section-key Description
        fieldsetA fieldset element that acts as the repeater's wrapper.
        legendA legend element that renders the label.
        itemsA ul element that wraps the repeater's items.
        itemA li element that is rendered for each repeater item.
        contentA container for the group section.
        groupDoes not render an element. It structures the default slot into an object data structure.
        controlsA ul element that wraps the repeater's controls.
        controlLabelA span element that renders the label of the given control.
        upA li element that renders the up control.
        upControlA button element that renders the up control.
        moveUpIconA span element that renders the upControl's icon.
        downA li element that renders the down control.
        downControlA button element that renders the down control.
        moveDownIconA span element that renders the downControl's icon.
        insertA li element that renders the insert control.
        insertControlA button element that renders the insert control.
        insertIconA span element that renders the insertControl's icon.
        removeA li element that renders the remove control.
        removeControlA button element that renders the remove control.
        removeIconA span element that renders the removeControl's icon.
        Show universal section keys
        outerThe outermost wrapping element.
        wrapperA wrapper around the label and input.
        labelThe label of the input.
        prefixHas no output by default, but allows content directly before an input element.
        prefixIconAn element for outputting an icon before the prefix section.
        innerA wrapper around the actual input element.
        suffixHas no output by default, but allows content directly after an input element.
        suffixIconAn element for outputting an icon after the suffix section.
        inputThe input element itself.
        helpThe element containing help text.
        messagesA wrapper around all the messages.
        messageThe element (or many elements) containing a message — most often validation and error messages.