Input | Web Component

dk-input

Properties

Use properties and attributes to control the web component as well as pass required data to it. Some properties won't have an attribute name, this is because to use that property you can't use it as an html attribute it must be set using javascript as a property of the element.

PropertyAttributeDescriptionTypeDefault
autocapitalizeautocapitalizeIndicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.string"off"
autocompleteautocompleteIndicates whether the value of the control can be automatically completed by the browser.string"off"
autocorrectautocorrectWhether auto correction should be enabled when the user is entering/editing the text value."off" | "on""off"
autofocusautofocusThis Boolean attribute lets you specify that a form control should have input focus when the page loads.booleanfalse
clearButtonclear-buttonIf set to true, when the input is filled there will be an X 'clear input' button in the right of the input.boolean
disableddisabledIf true input is greyed out and can'd be usedboolean
errorerrorIf true input will be red and the error message, either error-message attribute or slot="error" field, will be shownboolean
errorMessageerror-messageError message text to be shown below input when error attribute is true. If this undefined, then a child with slot="error-message" can be used instead.string
hasFloatingLabelfloating-labelIf set to true, the label will be shown as the placeholder, and move up to show as the label when the user starts typing. This only works with the label attribute, not a child with slot="label". EXPERIMENTAL: This feature is not ready for production usebooleanfalse
helperhelperOptional description of the input below the label.string
hideLabelhide-labelSetting this to true hides the label.boolean
inputSizeinput-size"md" | "sm""md"
inputmodeinputmodeType of specialized keyboard shown on mobile for this input."decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url""text"
labellabelLabel shown above input. Mandatory for accessibility, but can be hidden with the hide-label attributestring
maxmaxThe maximum value, which must not be less than its minimum (min attribute) value.string
maxlengthmaxlengthIf the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters that the user can enter.number
minminThe minimum value, which must not be greater than its maximum (max attribute) value.string
minlengthminlengthIf the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters that the user can enter.number
multiplemultipleIf true, the user can enter more than one value. This attribute applies when the type attribute is set to "email" or "file", otherwise it is ignored.boolean
namenameForm name of input. This identifies the input in a form. Defaults to id of input.string
placeholderplaceholderPlaceholder textstring
readonlyreadonlyIf true, the user cannot modify the value.booleanfalse
requiredrequiredIf true, the user must fill in a value before submitting a form.booleanfalse
sizesizeSize of the input"md" | "sm""md"
spellcheckspellcheckIf true, the element will have its spelling and grammar checked.booleanfalse
stepstepWorks with the min and max attributes to limit the increments at which a value can be set. Possible values are: "any" or a positive floating point number.string
typetypeType of input. This component is only for text-based inputs. Supported types are: text, date, email, number, password, search, tel, time, url, week, month."email" | "number" | "password" | "search" | "tel" | "text" | "url""text"
valuevalueValue of input.string""

Events

EventDescriptionType
dkChange{ value: string; }

Input Label

<dk-input
        label="Labeled Input"
        placeholder="Label"></dk-input>

Input Helper

<dk-input
        label="Labeled Input"
        placeholder="Helper"
        helper="more information about input"></dk-input>

Input Disabled

<dk-input
        disabled="true"
        label="Disabled"
        placeholder="Disabled"></dk-input>