Input / Form Elements Vue Components
Form elements allow you to create flexible and beautiful Form layout. Form elements are just well known List View (List and List Item Vue components) but with few additional components.
Check out Framework7's Inputs / Form Elements for their appearance.
Input Components
There are following components included:
f7-list-input
- list item input elementf7-input
- input element
Input Properties
Prop | Type | Default | Description |
---|---|---|---|
<f7-list-input> properties | |||
media | string | List item media image URL | |
label | string | Input's label text | |
floating-label | boolean | false | Enables floating label |
outline | boolean | false | Makes input outline |
input | boolean | true | Whether it should render input element or not. Disable if you want to use custom input inside. |
type | string | Input type. All default HTML5 input type, and few special ones:
| |
resizable | boolean | false | Makes textarea resizable |
inputStyle | string object | Value of input's "style" attribute, in case you need to pass extra styles | |
clear-button | boolean | false | Adds input clear button that will clear input value on click |
validate | boolean | false | When enabled then input value will be validated on change based on passed "pattern" or based on input type. If you use custom validation and need more control on where to show/hide error message, then it is better to disable validation and use error-message together with error-message-force props. |
validate-on-blur | boolean | false | When enabled then input will be validated on blur only. |
onValidate | function | Callback to be executed on input validation, returns boolean value indication whether the input is valid or not.
| |
error-message | string | Custom error message to show when input value is invalid | |
error-message-force | boolean | false | Force error message to force. Useful in case you use custom validation and want to show/hide error message when you need it |
info | string | Custom additional text with information about input | |
name | string | Input name | |
placeholder | string | Input placeholder | |
id | string | Wrapping element ID attribute | |
input-id | string | Input element ID attribute | |
value | string number array object | Input value. If If If | |
inputmode | string | Value of input's native "inputmode" attribute | |
size | string number | Value of input's native "size" attribute | |
pattern | string | Value of input's native "pattern" attribute | |
accept | string number | Value of input's native "accept" attribute | |
autocomplete | string | Value of input's native "autocomplete" attribute | |
autofocus | boolean | false | Value of input's native "autofocus" attribute |
autosave | string | Value of input's native "autosave" attribute | |
disabled | boolean | false | Marks input as disabled |
max | string number | Value of input's native "max" attribute | |
min | string number | Value of input's native "min" attribute | |
step | string number | Value of input's native "step" attribute | |
maxlength | string number | Value of input's native "maxlength" attribute | |
minlength | string number | Value of input's native "minlength" attribute | |
multiple | boolean | false | Value of input's native "multiple" attribute |
readonly | boolean | false | Marks input as readonly |
required | boolean | false | Marks input as required |
tabindex | string number | Value of input's native "tabindex" attribute | |
no-store-data | boolean | false | Allows to ignore input value to be stored when using with Form Storage |
ignore-store-data | boolean | false | Same as previous |
wrap | boolean | true | When enabled it will be wrapped in <li> element |
calendar-params | object | Object with Calendar Parameters which is used when type="datepicker" | |
color-picker-params | object | Object with Color Picker Parameters which is used when type="colorpicker" | |
text-editor-params | object | Object with Text Editor Parameters which is used when type="texteditor" | |
<f7-input> properties | |||
outline | boolean | false | Makes input outline |
wrap | boolean | true | Defines should the input be wraped with <div class="input"> element or not. |
type | string | Input type. All default HTML5 input type, and few special ones:
| |
resizable | boolean | false | Makes textarea resizable |
inputStyle | string object | Value of input's "style" attribute, in case you need to pass extra styles | |
clear-button | boolean | false | Adds input clear button that will clear input value on click |
validate | boolean | false | When enabled then input value will be validated on change based on passed "pattern" or based on input type. If you use custom validation and need more control on where to show/hide error message, then it is better to disable validation and use error-message together with error-message-force props. |
validate-on-blur | boolean | false | When enabled then input will be validated on blur only. |
onValidate | function | Callback to be executed on input validation, returns boolean value indication whether the input is valid or not.
| |
error-message | string | Custom error message to show when input value is invalid | |
error-message-force | boolean | false | Force error message to force. Useful in case you use custom validation and want to show/hide error message when you need it |
info | string | Custom additional text with information about input | |
name | string | Input name | |
placeholder | string | Input placeholder | |
id | string | Wrapping element ID attribute | |
input-id | string | Input element ID attribute | |
value | string number | Input value. If If If | |
inputmode | string | Value of input's native "inputmode" attribute | |
size | string number | Value of input's native "size" attribute | |
pattern | string | Value of input's native "pattern" attribute | |
accept | string number | Value of input's native "accept" attribute | |
autocomplete | string | Value of input's native "autocomplete" attribute | |
autofocus | boolean | false | Value of input's native "autofocus" attribute |
autosave | string | Value of input's native "autosave" attribute | |
checked | boolean | false | Marks input as checked |
disabled | boolean | false | Marks input as disabled |
max | string number | Value of input's native "max" attribute | |
min | string number | Value of input's native "min" attribute | |
step | string number | Value of input's native "step" attribute | |
maxlength | string number | Value of input's native "maxlength" attribute | |
minlength | string number | Value of input's native "minlength" attribute | |
multiple | boolean | false | Value of input's native "multiple" attribute |
readonly | boolean | false | Marks input as readonly |
required | boolean | false | Marks input as required |
tabindex | string number | Value of input's native "tabindex" attribute | |
no-store-data | boolean | false | Allows to ignore input value to be stored when using with Form Storage |
ignore-store-data | boolean | false | Same as previous |
calendar-params | object | Object with Calendar Parameters which is used when type="datepicker" | |
color-picker-params | object | Object with Color Picker Parameters which is used when type="colorpicker" | |
text-editor-params | object | Object with Text Editor Parameters which is used when type="texteditor" |
Input Events
Event | Arguments | Description |
---|---|---|
<f7-list-input>, <f7-input> events | ||
focus | (event) | Fired when user focused to input. |
blur | (event) | Fired when user lost focus from input. |
input | (event) | Fired immediately when input value changed. Note: Input event triggers after beforeinput, keypress, keyup, keydown events. |
change | (event) | Fired on blur if value changed. |
input:clear | (event) | Fired when input clear button clicked |
textarea:resize | (event) | Fired if resizable textarea resized. event.detail will contain object with the initialHeight , currentHeight and scrollHeight properties |
input:empty | (event) | Fired when input value becomes empty |
input:notempty | (event) | Fired when input value becomes not empty |
calendar:change | (value) | Fired when type="datepicker" Calendar value changed. As an argument it receives array with selected dates. |
colorpicker:change | (value) | Fired when type="colorpicker" Color Picker value changed. As an argument it receives object with Color Picker value. |
texteditor:change | (value) | Fired when type="texteditor" Text Editor value changed. As an argument it receives Texteditor value (HTML string). |
Input Slots
<f7-list-input>
has additional slots for custom elements:
default
- in case oftype="select"
ortype="textarea"
- element will be placed inside ofselect
ortextarea
tags.info
- element will be inserted into container with info messageerror-message
- element will be inserted into container with error messagelabel
- element will be inserted into container with input's labelinput
- element will be inserted instead of input element (input
prop must be also set tofalse
)root-start
- element will be inserted in the beginning of<li>
elementroot
/root-end
- element will be inserted in the end of<li>
elementcontent-start
- element will be inserted in the beginning of<div class="item-content">
elementcontent
/content-end
- element will be inserted in the end of<div class="item-content">
elementinner-start
- element will be inserted in the beginning of<div class="item-inner">
elementinner
/inner-end
- element will be inserted in the end of<div class="item-inner">
elementmedia
- element will be inserted inside of<div class="item-media">
element
Input v-model
f7-list-input
and f7-input
Vue components support v-model
on value
prop:
<template>
<p>Name is {{ name }}</p>
<p>Email is {{ email }}</p>
...
<f7-list-input
label="Name"
type="text"
placeholder="Your name"
clear-button
v-model:value="name"
/>
<f7-input
type="text"
placeholder="Your email"
clear-button
v-model:value="email"
/>
...
</template>
<script>
export default {
data() {
name: '',
email: '',
},
...
};
</script>
Examples
<template>
<f7-page>
<f7-navbar title="Form Inputs"></f7-navbar>
<f7-block-title>Full Layout / Stacked Labels</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input label="Name" type="text" placeholder="Your name" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="Password" type="password" placeholder="Your password" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="E-mail" type="email" placeholder="Your e-mail" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="URL" type="url" placeholder="URL" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="Phone" type="tel" placeholder="Your phone number" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="Gender" type="select" placeholder="Please choose...">
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
<option value="Male">Male</option>
<option value="Female">Female</option>
</f7-list-input>
<f7-list-input label="Birthday" type="date" placeholder="Please choose...">
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="Date time" type="datetime-local" placeholder="Please choose...">
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="Range" :input="false">
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
<template #input>
<f7-range :value="50" :min="0" :max="100" :step="1" />
</template>
</f7-list-input>
<f7-list-input label="Textarea" type="textarea" placeholder="Bio">
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="Resizable" type="textarea" resizable placeholder="Bio">
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
</f7-list>
<f7-block-title>Floating Labels</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input label="Name" floating-label type="text" placeholder="Your name" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
label="Password"
floating-label
type="password"
placeholder="Your password"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
label="E-mail"
floating-label
type="email"
placeholder="Your e-mail"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="URL" floating-label type="url" placeholder="URL" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
label="Phone"
floating-label
type="tel"
placeholder="Your phone number"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input label="Resizable" floating-label type="textarea" resizable placeholder="Bio">
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
</f7-list>
<f7-block-title>Floating Labels + Outline Inputs</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input
outline
label="Name"
floating-label
type="text"
placeholder="Your name"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
outline
label="Password"
floating-label
type="password"
placeholder="Your password"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
outline
label="E-mail"
floating-label
type="email"
placeholder="Your e-mail"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input outline label="URL" floating-label type="url" placeholder="URL" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
outline
label="Phone"
floating-label
type="tel"
placeholder="Your phone number"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
outline
label="Bio"
floating-label
type="textarea"
resizable
placeholder="Bio"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
</f7-list>
<f7-block-title>Validation + Additional Info</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input
label="Name"
type="text"
placeholder="Your name"
info="Default validation"
required
validate
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
label="Fruit"
type="text"
placeholder="Type 'apple' or 'banana'"
required
validate
pattern="apple|banana"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
<template #info>
<span>Pattern validation (<b>apple|banana</b>)</span>
</template>
</f7-list-input>
<f7-list-input
label="E-mail"
type="email"
placeholder="Your e-mail"
info="Default e-mail validation"
required
validate
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
label="URL"
type="url"
placeholder="Your URL"
info="Default URL validation"
required
validate
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input
label="Number"
type="text"
placeholder="Enter number"
info="With custom error message"
error-message="Only numbers please!"
required
validate
pattern="[0-9]*"
clear-button
>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
</f7-list>
<f7-block-title>Icon + Input</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input type="text" placeholder="Your name" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input type="password" placeholder="Your password" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input type="email" placeholder="Your e-mail" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
<f7-list-input type="url" placeholder="URL" clear-button>
<template #media>
<f7-icon icon="demo-list-icon" />
</template>
</f7-list-input>
</f7-list>
<f7-block-title>Label + Input</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input label="Name" type="text" placeholder="Your name" clear-button></f7-list-input>
<f7-list-input
label="Password"
type="password"
placeholder="Your password"
clear-button
></f7-list-input>
<f7-list-input
label="E-mail"
type="email"
placeholder="Your e-mail"
clear-button
></f7-list-input>
<f7-list-input label="URL" type="url" placeholder="URL" clear-button></f7-list-input>
</f7-list>
<f7-block-title>Only Inputs</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input type="text" placeholder="Your name" clear-button></f7-list-input>
<f7-list-input type="password" placeholder="Your password" clear-button></f7-list-input>
<f7-list-input type="email" placeholder="Your e-mail" clear-button></f7-list-input>
<f7-list-input type="url" placeholder="URL" clear-button></f7-list-input>
</f7-list>
<f7-block-title>Inputs + Additional Info</f7-block-title>
<f7-list strong-ios dividers-ios inset-ios>
<f7-list-input
type="text"
placeholder="Your name"
info="Full name please"
clear-button
></f7-list-input>
<f7-list-input
type="password"
placeholder="Your password"
info="8 characters minimum"
clear-button
></f7-list-input>
<f7-list-input
type="email"
placeholder="Your e-mail"
info="Your work e-mail address"
clear-button
></f7-list-input>
<f7-list-input
type="url"
placeholder="URL"
info="Your website URL"
clear-button
></f7-list-input>
</f7-list>
</f7-page>
</template>
<script>
import {
f7Navbar,
f7Page,
f7BlockTitle,
f7List,
f7Icon,
f7ListInput,
f7Range,
} from 'framework7-vue';
export default {
components: {
f7Navbar,
f7Page,
f7BlockTitle,
f7List,
f7Icon,
f7ListInput,
f7Range,
},
};
</script>