Skip to content

Textfield

Tag name: <vscode-textfield>

A simple inline textfield

When participating in a form, it supports the :invalid pseudo class. Otherwise the error styles can be applied through the invalid property.

Properties

autocomplete
Nameautocomplete
Attributeautocomplete
Type

'on' | 'off' | undefined

Default

undefined

autofocusreflects
Nameautofocus
Attributeautofocus
Type

boolean

Default

false

defaultValue
NamedefaultValue
Attributedefault-value
Type

string

Default

''

disabledreflects
Namedisabled
Attributedisabled
Type

boolean

Default

false

focusedreflects
Namefocused
Attributefocused
Type

boolean

Default

false

formreadonly
Nameform
Type

HTMLFormElement | null

invalidreflects
Nameinvalid
Attributeinvalid
Type

boolean

Default

false

Description

Set error styles on the component. This is only intended to apply styles when custom error validation is implemented. To check whether the component is valid, use the checkValidity method.

max
Namemax
Attributemax
Type

number | undefined

Default

undefined

maxLength
NamemaxLength
AttributemaxLength
Type

number | undefined

Default

undefined

maxlength
Namemaxlength
Type

number | undefined

Description

Lowercase alias to maxLength

min
Namemin
Attributemin
Type

number | undefined

Default

undefined

minLength
NameminLength
AttributeminLength
Type

number | undefined

Default

undefined

minlength
Nameminlength
Type

number | undefined

Description

Lowercase alias to minLength

multiplereflects
Namemultiple
Attributemultiple
Type

boolean

Default

false

namereflects
Namename
Attributename
Type

string | undefined

Default

undefined

pattern
Namepattern
Attributepattern
Type

string | undefined

Default

undefined

Description

Specifies a regular expression the form control's value should match. MDN Reference

placeholder
Nameplaceholder
Attributeplaceholder
Type

string | undefined

Default

undefined

readonlyreflects
Namereadonly
Attributereadonly
Type

boolean

Default

false

requiredreflects
Namerequired
Attributerequired
Type

boolean

Default

false

step
Namestep
Attributestep
Type

number | undefined

Default

undefined

typereflects
Nametype
Attributetype
Type

InputType

Description

Same as the type of the native <input> element but only a subset of types are supported. The supported ones are: color,date,datetime-local,email,file,month,number,password,search,tel,text,time,url,week

validationMessagereadonly
NamevalidationMessage
validityreadonly
Namevalidity
Type

ValidityState

value
Namevalue
Attributevalue
Type

string

versionreadonly
Nameversion
Type

string

Description

VSCode Elements version

willValidatereadonly
NamewillValidate
wrappedElementreadonly
NamewrappedElement
Type

HTMLInputElement

Methods

checkValidity() : boolean
NamecheckValidity
Description

Check the component's validity state when built-in validation is used. Built-in validation is triggered when any validation-related attribute is set. Validation-related attributes are: max, maxlength, min, minlength, pattern, required, step. See this the MDN reference for more details.

reportValidity()
NamereportValidity

Events

change
Namechange
TypeEvent
input
Nameinput
TypeInputEvent
vsc-changedeprecated
Namevsc-change
TypeCustomEvent
Description
vsc-inputdeprecated
Namevsc-input
TypeCustomEvent
Description

Slots

content-after
Description

A slot after the editable area but inside of the component. It is used to place icons.

content-before
Description

A slot before the editable area but inside of the component. It is used to place icons.

CSS Custom Properties

--vscode-button-background
Name--vscode-button-background
Default value#0078d4
--vscode-button-foreground
Name--vscode-button-foreground
Default value#ffffff
--vscode-button-hoverBackground
Name--vscode-button-hoverBackground
Default value#026ec1
--vscode-focusBorder
Name--vscode-focusBorder
Default value#0078d4
--vscode-font-family
Name--vscode-font-family
Default valuesans-serif
Description

A sans-serif font type depends on the host OS.

--vscode-font-size
Name--vscode-font-size
Default value13px
--vscode-font-weight
Name--vscode-font-weight
Default valuenormal
--vscode-input-placeholderForeground
Name--vscode-input-placeholderForeground
Default value#989898
--vscode-inputValidation-errorBackground
Name--vscode-inputValidation-errorBackground
Default value#5a1d1d
--vscode-inputValidation-errorBorder
Name--vscode-inputValidation-errorBorder
Default value#be1100
--vscode-settings-textInputBackground
Name--vscode-settings-textInputBackground
Default value#313131
--vscode-settings-textInputBackground
Name--vscode-settings-textInputBackground
Default value#313131
--vscode-settings-textInputBorder
Name--vscode-settings-textInputBorder
Default valuevar(--vscode-settings-textInputBackground, #3c3c3c)
--vscode-settings-textInputForeground
Name--vscode-settings-textInputForeground
Default value#cccccc