Skip to content
On this page

WARNING

While the documentation is fairly complete, it is still in first draft.

FormInput (BonesFormInput)

Overview

The Barebones FormInput component is an input element that is wrapped in a FormGroup component. FormInput accepts all input types, including textarea.

Component parts

Part nameDescription
componentThe components root element.

Props

Prop nameDescription
labelThe label is a string prop and is passed to the FormGroup and used to label the input.
errorThe error is a string prop and is passed to the FormGroup and used to display an error if one exists.
valueThe value prop is the value as set by the parent component.
placeholderThe placeholder prop is a string and sets a placeholder on the input
disabledThe disabled prop is a boolean that sets the disabled state as true or false
formGroupPropsformGroupProps are props that are passed to FormGroup if you'd like to override defaults
typeThe type prop accepts type FormInputType which accepts all input types including textarea. See types.
multipleFilesmultipleFiles is a boolean and used only on file inputs. It will set whether file upload accepts 1 or multiple files.
minmin is a number used on range to set the minimum value. It defaults to 0.
maxmax is a number used on range to set the maximum value. It defaults to 100.
stepstep is a number used on range to set the step value. It defaults to 1.
checkedOnMountcheckedOnMount is a boolean used on checkbox and radio types to declare if it is checked on load.

Slots

Slot nameDescription
customInputThe customInput slot allows you to create an app level higher order component and add custom switches
iconThe icon slot allows you to create an app level higher order component and add custom icons

Prop Types

FormInputType

export type FormInputType =
  | "text"
  | "number"
  | "date"
  | "email"
  | "password"
  | "search"
  | "url"
  | "file"
  | "textarea"
  | "checkbox"
  | "tel"
  | "range"
  | "radio";

WARNING

When using input type file you should add a value prop with an empty string.

Component Type

export interface FormInput {
  parts: DynamicParts;
}

Examples

WARNING

Examples use tailwind/salient theme, to use this theme you may add it using the theme npx command and installing Tailwind JIT in your application. Read more about themes.

Code

<script setup>
  /* */
  const formData = reactive({
    firstName: "",
  });
  /* */
</script>
<FormInput 
  name="first-name" 
  label="First Name" 
  v-model:value="formData.firstName" 
/>

Output