Skip to content
目录

Input

Simple and not simple input components

Basic Input

type Input type set up text password email number tel url default:text

html
<template>
  <dk-input placeholder="Please enter content"></dk-input>
</template>
展开

Disabled state

disabled Property can set the input to a disabled state

html
<template>
  <dk-input placeholder="Please enter content" disabled></dk-input>
</template>
展开

prefix and suffix

prefix-icon and suffix-icon Attributes can be added with icons before and after the input , prefix and suffix Slots can add custom content before and after the input .

html
<template>
  <dk-input placeholder="prefix-icon" prefix-icon="IconSearch"></dk-input>
  <dk-input placeholder="suffix-icon" suffix-icon="IconSearch"></dk-input>
  <dk-input placeholder="slot">
    <template #prefix>
      <Dk-Icon icon="IconSearch"></Dk-Icon>
    </template>
    <template #suffix>
      <Dk-Icon icon="IconSearch"></Dk-Icon>
    </template>
  </dk-input>
</template>
展开

Front and rear labels

prepend and append Slots can be labeled before and after the input , prepend-icon and append-icon Attributes can be added with icons before and after the input , prepend-text and append-text Attributes can be added with text before and after the input ,

take care ⚠ : The priority order is: prepend > prepend-icon > prepend-text

https://
.com
https://
.com
html
<template>
  <dk-input placeholder="prepend" prepend>
    <template #prepend>
      <div>https://</div>
    </template>
  </dk-input>
  <dk-input placeholder="append" append>
    <template #append>
      <div>.com</div>
    </template>
  </dk-input>
  <dk-input placeholder="prepend-icon" prepend-icon="IconSearch"></dk-input>
  <dk-input placeholder="append-icon" append-icon="IconSearch"></dk-input>
  <dk-input placeholder="prepend-text" prepend-text="https://"></dk-input>
  <dk-input placeholder="append-text" append-text=".com"></dk-input>
</template>
展开

Textarea

type Property set to textarea You can set the input as a text field, autosize The attribute can adapt to height.

html
<template>
  <dk-input placeholder="Please enter content" type="textarea"></dk-input>
  <dk-input placeholder="Please enter content" type="textarea" autosize></dk-input>
</template>
展开

Number input

type Property set to number You can set the input as a numeric input .

html
<template>
  <dk-input placeholder="Please enter content" type="number"></dk-input>
</template>
展开

Password input

type Property set to password You can set the input as a password input ,show-password The property can display a password switch button.

html
<template>
  <dk-input placeholder="Please enter content" type="password"></dk-input>
  <dk-input placeholder="Please enter content" type="password" show-password></dk-input>
</template>
展开

Length limit

The maxlength and minlength attributes can limit the maximum and minimum length of input boxes, show-length property can display the length of the input box.

0/100
10
html
<template>
  <dk-input placeholder="Please enter content" show-length maxlength="10"></dk-input>
  <dk-input placeholder="Please enter content" minlength="10"></dk-input>
</template>
展开

status

The status attribute can set the status of the input box, The status attribute supports two states: warning and error.

html
<template>
  <dk-input placeholder="Please enter content" status="warning"></dk-input>
  <dk-input placeholder="Please enter content" status="error"></dk-input>
  <dk-input
    placeholder="Please enter content"
    status="warning"
    prefix-icon="IconSysInformation"
  ></dk-input>
  <dk-input
    placeholder="Please enter content"
    status="error"
    prefix-icon="IconSysInformation"
  ></dk-input>
</template>
展开

personality

personality Enables personalization, and personal-type supports personalization types.

html
<template>
  <dk-input
    placeholder="Please enter content"
    personality
    personality-type="underline"
  ></dk-input>
  <dk-input
    placeholder="Please enter content"
    personality
    personality-type="borderRadius"
  ></dk-input>
</template>
展开

attribute

attributeexplaintypeOptional valuesDefault value
typetypestringtext textarea number password texttext
placeholderplaceholderstring--
disabledDisabledboolean-false
readonlyreadonlyboolean-false
clearableclearableboolean-false
show-passwordShow password switch buttonboolean-false
prefix-iconInput header iconstring--
suffix-iconInput tail iconstring--
prepend-iconIcon in front of inputstring--
append-iconIcon at the back of the inputstring--
prepend-textEnter text at the front of thestring--
append-textEnter the text at the end of thestring--
autosizeAdaptive height (only for textarea)boolean-false
rowsNumber of input lines (only effective for textarea)number-1
maxlengthMaximum length of inputnumber--
minlengthMinimum length of inputnumber--
show-lengthDisplay input lengthboolean-false
widthInput widthstring--
heightInput heightstring--
sizeInput sizestringlarge medium smallmedium
font-sizeInput font sizestring--
border-radiusInput rounded cornersstring--
text-colorInput font colorstring--
icon-sizeInput icon sizestring--
border-colorInput border colorstring--
focus-border-colorInput focus border colorstring--
append-backgroundInput front and back content background colorstring--
append-colorInput front and back content font colorstring--
alignInput content alignmentstringleft center rightleft
borderInput Borderstringauto noneauto
statusstatusstringwarning error-
personalitypersonalityboolean-false

Event

Event NameexplainCallback Arguments
focusTriggered when the input is focused(event: FocusEvent) => void
blurTriggered when the input is out of focus(event: FocusEvent) => void
clearTriggered when the clear button is clicked-
enterTriggered when the Enter key is pressed(value: string | number) => void

slot

Slot Nameexplain
prependInput front content
appendContent at the back of the input
prefixInput header content
suffixInput tail content

Contributors