Inputs / Form Inputs - 图1

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 element
  • **f7-input** - input element
  • **f7-label** - input label element

Since Framework7 3.5.0 it is highly recommended that you only use **f7-list-input** component. It combines f7-list-item, f7-label and f7-input components in one component and provides much better and more correct input’s state handling.

Input Properties

PropTypeDefaultDescription
<f7-list-input> properties
idstringWrapping element ID attribute
mediastringList item media image URL
labelstringInput’s label text
inline-labelbooleanfalseMakes label inline
floating-labelbooleanfalseEnables floating label (affects MD theme only)
inputbooleantrueWhether it should render input element or not. Disable if you want to use custom input inside.
typestringInput type. All default HTML5 input type, and few special ones:
  • textarea - to render textarea element
  • select - to render select element
resizablebooleanfalseMakes textarea resizable
inputStylestring
object
Value of input’s “style” attribute, in case you need to pass extra styles
clear-buttonbooleanfalseAdds input clear button that will clear input value on click
validatebooleanfalseWhen 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.
error-messagestringCustom error message to show when input value is invalid
error-message-forcebooleanfalseForce error message to force. Useful in case you use custom validation and want to show/hide error message when you need it
infostringCustom additional text with information about input
namestringInput name
placeholderstringInput placeholder
input-idstringInput element ID attribute
valuestring
number
Input value
default-valuestring
number
Input value, in case of uncontrolled component
sizestring
number
Value of input’s native “size” attribute
patternstringValue of input’s native “pattern” attribute
acceptstring
number
Value of input’s native “accept” attribute
autocompletestringValue of input’s native “autocomplete” attribute
autofocusbooleanfalseValue of input’s native “autofocus” attribute
autosavestringValue of input’s native “autosave” attribute
checkedbooleanfalseMarks input as checked
disabledbooleanfalseMarks input as disabled
maxstring
number
Value of input’s native “max” attribute
minstring
number
Value of input’s native “min” attribute
stepstring
number
Value of input’s native “step” attribute
maxlengthstring
number
Value of input’s native “maxlength” attribute
minlengthstring
number
Value of input’s native “minlength” attribute
multiplebooleanfalseValue of input’s native “multiple” attribute
readonlybooleanfalseMarks input as readonly
requiredbooleanfalseMarks input as required
tabindexstring
number
Value of input’s native “tabindex” attribute
no-store-databooleanfalseAllows to ignore input value to be stored when using with Form Storage
ignore-store-databooleanfalseSame as previous
<f7-label> properties
floatingbooleanfalseEnables floating label (affects MD theme only)
inlinebooleanfalseMakes label inline
<f7-input> properties
wrapbooleantrueDefines should the input be wraped with “item-input-wrap” element or not. Must be disabled when using outside of List View
typestringInput type. All default HTML5 input type, and few special ones:
  • textarea - to render textarea element
  • select - to render select element
resizablebooleanfalseMakes textarea resizable
inputStylestring
object
Value of input’s “style” attribute, in case you need to pass extra styles
clear-buttonbooleanfalseAdds input clear button that will clear input value on click
validatebooleanfalseWhen 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.
error-messagestringCustom error message to show when input value is invalid
error-message-forcebooleanfalseForce error message to force. Useful in case you use custom validation and want to show/hide error message when you need it
infostringCustom additional text with information about input
namestringInput name
placeholderstringInput placeholder
idstringWrapping element ID attribute
input-idstringInput element ID attribute
valuestring
number
Input value
sizestring
number
Value of input’s native “size” attribute
patternstringValue of input’s native “pattern” attribute
acceptstring
number
Value of input’s native “accept” attribute
autocompletestringValue of input’s native “autocomplete” attribute
autofocusbooleanfalseValue of input’s native “autofocus” attribute
autosavestringValue of input’s native “autosave” attribute
checkedbooleanfalseMarks input as checked
disabledbooleanfalseMarks input as disabled
maxstring
number
Value of input’s native “max” attribute
minstring
number
Value of input’s native “min” attribute
stepstring
number
Value of input’s native “step” attribute
maxlengthstring
number
Value of input’s native “maxlength” attribute
minlengthstring
number
Value of input’s native “minlength” attribute
multiplebooleanfalseValue of input’s native “multiple” attribute
readonlybooleanfalseMarks input as readonly
requiredbooleanfalseMarks input as required
tabindexstring
number
Value of input’s native “tabindex” attribute
no-store-databooleanfalseAllows to ignore input value to be stored when using with Form Storage
ignore-store-databooleanfalseSame as previous

Input Events

EventArgumentsDescription
<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 when 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

Input Slots

Input Vue component (<f7-list-input>) has additional slots for custom elements:

  • **default** - in case of type="select" or type="textarea" - element will be placed inside of select or textarea tags.
  • **info** - element will be inserted into container with info message
  • **error-message** - element will be inserted into container with error message
  • **label** - element will be inserted into container with input’s label
  • **input** - element will be inserted instead of input element (input prop must be also set to false)
  • **root-start** - element will be inserted in the beginning of <li> element
  • **root** / **root-end** - element will be inserted in the end of <li> element
  • **content-start** - element will be inserted in the beginning of <div class="item-content"> element
  • **content** / **content-end** - element will be inserted in the end of <div class="item-content"> element
  • **inner-start** - element will be inserted in the beginning of <div class="item-inner"> element
  • **inner** / **inner-end** - element will be inserted in the end of <div class="item-inner"> element
  • **media** - element will be inserted inside of <div class="item-media"> element

Input v-model

v-model is not supported on f7-list-input / f7-input vue components. Instead, just use the combination of value property and @input event:

  1. <template>
  2. ...
  3. <f7-list-input
  4. label="Name"
  5. type="text"
  6. :value="name"
  7. @input="name = $event.target.value"
  8. placeholder="Your name"
  9. clear-button
  10. ></f7-list-input>
  11. ...
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. name: '',
  17. },
  18. ...
  19. };
  20. </script>

Examples

  1. <f7-block-title>Full Layout / Inline Labels</f7-block-title>
  2. <f7-list inline-labels no-hairlines-md>
  3. <f7-list-input
  4. label="Name"
  5. type="text"
  6. placeholder="Your name"
  7. clear-button
  8. >
  9. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  10. </f7-list-input>
  11. <f7-list-input
  12. label="Password"
  13. type="password"
  14. placeholder="Your password"
  15. clear-button
  16. >
  17. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  18. </f7-list-input>
  19. <f7-list-input
  20. label="E-mail"
  21. type="email"
  22. placeholder="Your e-mail"
  23. clear-button
  24. >
  25. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  26. </f7-list-input>
  27. <f7-list-input
  28. label="URL"
  29. type="url"
  30. placeholder="URL"
  31. clear-button
  32. >
  33. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  34. </f7-list-input>
  35. <f7-list-input
  36. label="Phone"
  37. type="tel"
  38. placeholder="Your phone number"
  39. clear-button
  40. >
  41. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  42. </f7-list-input>
  43. <f7-list-input
  44. label="Gender"
  45. type="select"
  46. defaultValue="Male"
  47. placeholder="Please choose..."
  48. >
  49. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  50. <option value="Male">Male</option>
  51. <option value="Female">Female</option>
  52. </f7-list-input>
  53. <f7-list-input
  54. label="Birthday"
  55. type="date"
  56. defaultValue="2014-04-30"
  57. placeholder="Please choose..."
  58. >
  59. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  60. </f7-list-input>
  61. <f7-list-input
  62. label="Date time"
  63. type="datetime-local"
  64. placeholder="Please choose..."
  65. >
  66. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  67. </f7-list-input>
  68. <f7-list-input
  69. label="Range"
  70. :input="false"
  71. >
  72. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  73. <f7-range slot="input" :value="50" :min="0" :max="100" :step="1"></f7-range>
  74. </f7-list-input>
  75. <f7-list-input
  76. label="Textarea"
  77. type="textarea"
  78. placeholder="Bio"
  79. >
  80. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  81. </f7-list-input>
  82. <f7-list-input
  83. label="Resizable"
  84. type="textarea"
  85. resizable
  86. placeholder="Bio"
  87. >
  88. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  89. </f7-list-input>
  90. </f7-list>
  91. <f7-block-title>Full Layout / Stacked Labels</f7-block-title>
  92. <f7-list no-hairlines-md>
  93. <f7-list-input
  94. label="Name"
  95. type="text"
  96. placeholder="Your name"
  97. clear-button
  98. >
  99. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  100. </f7-list-input>
  101. <f7-list-input
  102. label="Password"
  103. type="password"
  104. placeholder="Your password"
  105. clear-button
  106. >
  107. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  108. </f7-list-input>
  109. <f7-list-input
  110. label="E-mail"
  111. type="email"
  112. placeholder="Your e-mail"
  113. clear-button
  114. >
  115. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  116. </f7-list-input>
  117. <f7-list-input
  118. label="URL"
  119. type="url"
  120. placeholder="URL"
  121. clear-button
  122. >
  123. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  124. </f7-list-input>
  125. <f7-list-input
  126. label="Phone"
  127. type="tel"
  128. placeholder="Your phone number"
  129. clear-button
  130. >
  131. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  132. </f7-list-input>
  133. <f7-list-input
  134. label="Gender"
  135. type="select"
  136. defaultValue="Male"
  137. placeholder="Please choose..."
  138. >
  139. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  140. <option value="Male">Male</option>
  141. <option value="Female">Female</option>
  142. </f7-list-input>
  143. <f7-list-input
  144. label="Birthday"
  145. type="date"
  146. defaultValue="2014-04-30"
  147. placeholder="Please choose..."
  148. >
  149. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  150. </f7-list-input>
  151. <f7-list-input
  152. label="Date time"
  153. type="datetime-local"
  154. placeholder="Please choose..."
  155. >
  156. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  157. </f7-list-input>
  158. <f7-list-input
  159. label="Range"
  160. :input="false"
  161. >
  162. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  163. <f7-range slot="input" :value="50" :min="0" :max="100" :step="1"></f7-range>
  164. </f7-list-input>
  165. <f7-list-input
  166. label="Textarea"
  167. type="textarea"
  168. placeholder="Bio"
  169. >
  170. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  171. </f7-list-input>
  172. <f7-list-input
  173. label="Resizable"
  174. type="textarea"
  175. resizable
  176. placeholder="Bio"
  177. >
  178. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  179. </f7-list-input>
  180. </f7-list>
  181. <f7-block-title>Floating Labels (MD-theme only)</f7-block-title>
  182. <f7-list no-hairlines-md>
  183. <f7-list-input
  184. label="Name"
  185. floating-label
  186. type="text"
  187. placeholder="Your name"
  188. clear-button
  189. >
  190. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  191. </f7-list-input>
  192. <f7-list-input
  193. label="Password"
  194. floating-label
  195. type="password"
  196. placeholder="Your password"
  197. clear-button
  198. >
  199. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  200. </f7-list-input>
  201. <f7-list-input
  202. label="E-mail"
  203. floating-label
  204. type="email"
  205. placeholder="Your e-mail"
  206. clear-button
  207. >
  208. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  209. </f7-list-input>
  210. <f7-list-input
  211. label="URL"
  212. floating-label
  213. type="url"
  214. placeholder="URL"
  215. clear-button
  216. >
  217. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  218. </f7-list-input>
  219. <f7-list-input
  220. label="Phone"
  221. floating-label
  222. type="tel"
  223. placeholder="Your phone number"
  224. clear-button
  225. >
  226. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  227. </f7-list-input>
  228. <f7-list-input
  229. label="Resizable"
  230. floating-label
  231. type="textarea"
  232. resizable
  233. placeholder="Bio"
  234. >
  235. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  236. </f7-list-input>
  237. </f7-list>
  238. <f7-block-title>Validation + Additional Info</f7-block-title>
  239. <f7-list no-hairlines-md>
  240. <f7-list-input
  241. label="Name"
  242. type="text"
  243. placeholder="Your name"
  244. info="Default validation"
  245. required
  246. validate
  247. clear-button
  248. >
  249. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  250. </f7-list-input>
  251. <f7-list-input
  252. label="Fruit"
  253. type="text"
  254. placeholder="Type 'apple' or 'banana'"
  255. required
  256. validate
  257. pattern="apple|banana"
  258. clear-button
  259. >
  260. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  261. <span slot="info">Pattern validation (<b>apple|banana</b>)</span>
  262. </f7-list-input>
  263. <f7-list-input
  264. label="E-mail"
  265. type="email"
  266. placeholder="Your e-mail"
  267. info="Default e-mail validation"
  268. required
  269. validate
  270. clear-button
  271. >
  272. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  273. </f7-list-input>
  274. <f7-list-input
  275. label="URL"
  276. type="url"
  277. placeholder="Your URL"
  278. info="Default URL validation"
  279. required
  280. validate
  281. clear-button
  282. >
  283. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  284. </f7-list-input>
  285. <f7-list-input
  286. label="Number"
  287. type="text"
  288. placeholder="Enter number"
  289. info="With custom error message"
  290. error-message="Only numbers please!"
  291. required
  292. validate
  293. pattern="[0-9]*"
  294. clear-button
  295. >
  296. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  297. </f7-list-input>
  298. </f7-list>
  299. <f7-block-title>Icon + Input</f7-block-title>
  300. <f7-list no-hairlines-md>
  301. <f7-list-input
  302. type="text"
  303. placeholder="Your name"
  304. clear-button
  305. >
  306. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  307. </f7-list-input>
  308. <f7-list-input
  309. type="password"
  310. placeholder="Your password"
  311. clear-button
  312. >
  313. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  314. </f7-list-input>
  315. <f7-list-input
  316. type="email"
  317. placeholder="Your e-mail"
  318. clear-button
  319. >
  320. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  321. </f7-list-input>
  322. <f7-list-input
  323. type="url"
  324. placeholder="URL"
  325. clear-button
  326. >
  327. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  328. </f7-list-input>
  329. </f7-list>
  330. <f7-block-title>Label + Input</f7-block-title>
  331. <f7-list no-hairlines-md>
  332. <f7-list-input
  333. label="Name"
  334. type="text"
  335. placeholder="Your name"
  336. clear-button
  337. ></f7-list-input>
  338. <f7-list-input
  339. label="Password"
  340. type="password"
  341. placeholder="Your password"
  342. clear-button
  343. ></f7-list-input>
  344. <f7-list-input
  345. label="E-mail"
  346. type="email"
  347. placeholder="Your e-mail"
  348. clear-button
  349. ></f7-list-input>
  350. <f7-list-input
  351. label="URL"
  352. type="url"
  353. placeholder="URL"
  354. clear-button
  355. ></f7-list-input>
  356. </f7-list>
  357. <f7-block-title>Only Inputs</f7-block-title>
  358. <f7-list no-hairlines-md>
  359. <f7-list-input
  360. type="text"
  361. placeholder="Your name"
  362. clear-button
  363. ></f7-list-input>
  364. <f7-list-input
  365. type="password"
  366. placeholder="Your password"
  367. clear-button
  368. ></f7-list-input>
  369. <f7-list-input
  370. type="email"
  371. placeholder="Your e-mail"
  372. clear-button
  373. ></f7-list-input>
  374. <f7-list-input
  375. type="url"
  376. placeholder="URL"
  377. clear-button
  378. ></f7-list-input>
  379. </f7-list>
  380. <f7-block-title>Inputs + Additional Info</f7-block-title>
  381. <f7-list no-hairlines-md>
  382. <f7-list-input
  383. type="text"
  384. placeholder="Your name"
  385. info="Full name please"
  386. clear-button
  387. ></f7-list-input>
  388. <f7-list-input
  389. type="password"
  390. placeholder="Your password"
  391. info="8 characters minimum"
  392. clear-button
  393. ></f7-list-input>
  394. <f7-list-input
  395. type="email"
  396. placeholder="Your e-mail"
  397. info="Your work e-mail address"
  398. clear-button
  399. ></f7-list-input>
  400. <f7-list-input
  401. type="url"
  402. placeholder="URL"
  403. info="Your website URL"
  404. clear-button
  405. ></f7-list-input>
  406. </f7-list>
  407. <f7-block-title>Only Inputs Inset</f7-block-title>
  408. <f7-list inset>
  409. <f7-list-input
  410. type="text"
  411. placeholder="Your name"
  412. clear-button
  413. ></f7-list-input>
  414. <f7-list-input
  415. type="password"
  416. placeholder="Your password"
  417. clear-button
  418. ></f7-list-input>
  419. <f7-list-input
  420. type="email"
  421. placeholder="Your e-mail"
  422. clear-button
  423. ></f7-list-input>
  424. <f7-list-input
  425. type="url"
  426. placeholder="URL"
  427. clear-button
  428. ></f7-list-input>
  429. </f7-list>