Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mcwv/textfield

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mcwv/textfield

The Vue Material Adapter for the web textfield component

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Usage

Single-line

<mdc-textfield v-model="text" label="Hint text" />
<mdc-textfield v-model="text" label="Hint text dense" />
var vm = new Vue({
  data: {
    text: ""
  }
})

Help text

<mdc-textfield v-model="text" label="Hint text"  helptext="Help text...">

Multiline

<mdc-textfield v-model="text" label="Hint text" multiline rows="8" cols="40" />

Full width

<mdc-textfield v-model="text" fullwidth label="Hint text" />
<mdc-textfield v-model="text" fullwidth multiline rows="10" label="Hint text" />

box and outline style

<mdc-textfield v-model="text" label="Hint text" box/>
<mdc-textfield v-model="text" label="Hint text" outline/>

use props to set trailing or leading icon

<mdc-textfield v-model="text" label="Hint text" box leading-icon="event"/>
<mdc-textfield v-model="text" label="Hint text" outline trailing-icon="event"/>

custom icon

<mdc-textfield v-model="text" label="Hint text" box :leading-icon="{className: 'fa fa-font-awesome'}" />
<mdc-textfield v-model="text" label="Hint text" outline>
  <svg slot="traling-icon">...</svg>
</mdc-textfield>

Validation

  • Native validation: use type, required, minlength and maxlength properties
<mdc-textfield type="password" label="Password"
  required minlength=8 maxlength=10
  helptext="passord must be 8 to 10 characters"
  helptext-persistent helptext-validation
  v-model="password" />
  • Custom Validation: use :valid property:
<mdc-textfield
  :valid="isValid"
  helptext="custom check"
  helptext-persistent helptext-validation
  v-model="value" />
var vm = new Vue({
  data: {
    text: ""
  }
  computed: {
    isValid () {
      return myCustomCheck(this.text)
    }
  }
})

Once set, native validition is ignored.

props

propsTypedefaultDescription
v-modelStringbinds textfield value
disabled[Number, String]binds to disabled state
typeStringtextinput type attribute
labelStringhint text
denseBooleancompresses the textfield to make it slightly smaller
outlineBooleanwhether the textfield is outlined
boxBooleanwhether the textfield is a box
helptextStringhelp text
helptext-persistentBooleanwhether help text is persistent
helptext-validationBooleanwhether help text is a validation
requiredBooleanvalidation: whether this field is required
minlength[Number, String]validation: minimal length
maxlength[Number, String]validation: max length
valid[Number, String]validation: custom validation property
size[Number, String]20textfield size (chars)
fullwidthBooleanwhether the textfield is full width
multilineBooleanwhether the textfield is multiline
rows[Number, String]8multiline: number of rows
cols[Number, String]40multiline: number of columns
trailing-icon[String, Array, Object ]trailing icon *
leading-icon[String, Array, Object ]leading icon *

other input attributes (name, readonly, ... ) are being passed down to the rendered input element.

(*) icon prop usage: use String for material icons, Array to specify icon classList, {className: String, textContent: String} for custom class and/or content, or use trailing-icon or leading-icon slots for custom icon markup (svg, ...).

events

eventargsDescription
@focus-emitted on focus gained
@blur-emitted on focus lost
@icon-action-emitted on icon action
@[listener]-emitted on icon action

Other bound listeners are being passsed down to the rendered input element

<mdc-textfield v-model="text" label="Hint text" 
  @keypress.enter="handleEnterKey"/>

methods

eventargsDescription
focus()-focus the input element
blur()-blur the input element

Reference

  • https://material.io/components/web/catalog/input-controls/text-fields

Keywords

FAQs

Package last updated on 10 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc