VEUI

VEUI on GitHub
Play!中文

Input

Examples

Size variants

Available size variants of the ui prop: xs / s / m / l.

Edit this demo on GitHubEdit
<template>
<article>
  <section>
    <veui-input
      ui="l"
      value="Large"
    />
  </section>
  <section><veui-input value="Normal"/></section>
  <section>
    <veui-input
      ui="s"
      value="Small"
    />
  </section>
  <section>
    <veui-input
      ui="xs"
      value="Extra small"
    />
  </section>
</article>
</template>

<script>
import { Input } from 'veui'

export default {
  components: {
    'veui-input': Input
  }
}
</script>

<style lang="less" scoped>
section {
  margin-bottom: 1em;
}
</style>

Read-only

Set the readonly prop to make the input field readonly.

Edit this demo on GitHubEdit
<template>
<article>
  <section>
    <veui-checkbox v-model="readonly">
      Read-only
    </veui-checkbox>
  </section>
  <section>
    <section>
      <veui-input
        :readonly="readonly"
        ui="l"
        value="Large"
      />
    </section>
    <section>
      <veui-input
        :readonly="readonly"
        value="Normal"
      />
    </section>
    <section>
      <veui-input
        :readonly="readonly"
        ui="s"
        value="Small"
      />
    </section>
    <section>
      <veui-input
        :readonly="readonly"
        ui="xs"
        value="Extra small"
      />
    </section>
  </section>
</article>
</template>

<script>
import { Input, Checkbox } from 'veui'

export default {
  components: {
    'veui-input': Input,
    'veui-checkbox': Checkbox
  },
  data () {
    return {
      readonly: true
    }
  }
}
</script>

<style lang="less" scoped>
section {
  margin-bottom: 1em;
}
</style>

Disabled

Set the disabled prop to disable the input field.

Edit this demo on GitHubEdit
<template>
<article>
  <section>
    <veui-checkbox v-model="disabled">
      Disabled
    </veui-checkbox>
  </section>
  <section>
    <section>
      <veui-input
        :disabled="disabled"
        ui="l"
        value="Large"
      />
    </section>
    <section>
      <veui-input
        :disabled="disabled"
        value="Normal"
      />
    </section>
    <section>
      <veui-input
        :disabled="disabled"
        ui="s"
        value="Small"
      />
    </section>
    <section>
      <veui-input
        :disabled="disabled"
        ui="xs"
        value="Extra small"
      />
    </section>
  </section>
</article>
</template>

<script>
import { Input, Checkbox } from 'veui'

export default {
  components: {
    'veui-input': Input,
    'veui-checkbox': Checkbox
  },
  data () {
    return {
      disabled: true
    }
  }
}
</script>

<style lang="less" scoped>
section {
  margin-bottom: 1em;
}
</style>

Composition

Set the composition prop to handle input composition.

Input value:
Edit this demo on GitHubEdit
<template>
<article>
  <section>
    <veui-checkbox v-model="composition">
      Composition
    </veui-checkbox>
  </section>
  <section>Input value: {{ value }}</section>
  <section>
    <veui-input
      v-model="value"
      :composition="composition"
    />
  </section>
</article>
</template>

<script>
import { Input, Checkbox } from 'veui'

export default {
  components: {
    'veui-input': Input,
    'veui-checkbox': Checkbox
  },
  data () {
    return {
      composition: true,
      value: ''
    }
  }
}
</script>

<style lang="less" scoped>
section {
  margin-bottom: 20px;
}
</style>

Trimming white spaces

Set the trim prop to automatically remove leading and trailing white spaces from user input.

Input value: ``

Edit this demo on GitHubEdit
<template>
<article>
  <section>
    <p class="respect-whitespace">Input value: `{{ value }}`</p>
    <veui-input
      v-model="value"
      trim
    />
  </section>
</article>
</template>

<script>
import { Input } from 'veui'

export default {
  components: {
    'veui-input': Input
  },
  data () {
    return {
      composition: true,
      value: ''
    }
  }
}
</script>

<style scoped>
.respect-whitespace {
  white-space: pre;
}
</style>

API

Props

NameTypeDefaultDescription
uistring-

Predefined styles.

ValueDescription
xsExtra small size style.
sSmall size style.
mMedium size style.
lLarge size style.
inlineInline style.
valuestring''

v-model

The value of the input field.

disabledbooleanfalseWhether the input field is disabled.
readonlybooleanfalseWhether the input field is read-only.
typestring'text'

The type of input. See type in the native <input> element.

ValueDescription
textText input field.
passwordPassword input field.
hiddenHidden input field, but the value can be submitted.
placeholderstring-Placeholder text for the input field.
clearablebooleanfalseWhether to show the clear button.
compositionbooleanfalseWhether to handle input composition.
autofocusbooleanfalseWhether to autofocus the input.
select-on-focusbooleanfalseWhether to select the input field text on focus.
maxlengthnumber-The maximum length of input characters.
get-lengthfunction(string): number-Custom function to calculate the length of input characters.
strictbooleanfalseWhether to disallow input after maximum character limit is reached.
trimboolean | stringfalse

Whether to trim leading and trailing white spaces. When set to true, leading and trailing white spaces will be removed. When set to false, they won't be removed. When set to a string, trimming will follow the specified method.

ValueDescription
bothRemove both leading and trailing spaces. Equivalent to true.
startRemove leading spaces.
endRemove trailing spaces.

Slots

NameDescription
beforeContent to be placed before the input field.
afterContent to be placed after the input field.
placeholderPlaceholder content when no value is entered.

Events

NameDescription
change

Triggered when the content of the input changes, i.e. when the native change event is triggered. The callback parameters are (value, event).

NameTypeDescription
valuestringThe value of the input.
eventEventThe native change event object.
input

v-model

Triggered when valid input is entered, affected by the composition prop. The callback parameter is (value: string), where value is the value of the input.

clearTriggered when the clear button is clicked.

In addition, Input supports the following native events:

auxclick, click, contextmenu, dblclick, mousedown, mouseenter, mouseleave, mousemove, mouseover, mouseout, mouseup, select, wheel, keydown, keypress, keyup, focus, blur, focusin, focusout.

The callback functions of these events receive the native event object as a parameter.

Icons

NameDescription
removeClear button.
Edit this page on GitHubEdit
© Baidu, Inc. 2024