Lapikit

Textfield component

Textfield

The Textfield component provides a versatile input solution for capturing user data. It supports various input types, validation states, and enhanced features like character counting and clearable functionality. Designed with accessibility and user experience in mind.

Examples of textfield

Base

A simple text input field with default styling and behavior. This is the most basic form of the textfield component, suitable for general text input needs.

Type

Demonstrates different input types (text, email, password, number, etc.) to handle specific data formats and enable appropriate virtual keyboards on mobile devices.

Variant

Shows visual variants of the textfield: outlined, filled, or underlined to match different design systems and UI contexts.

Clearable

Adds a clear button that allows users to quickly empty the input field. Particularly useful for search fields and forms where users need to reset values frequently.

Counter

Displays a character counter to help users stay within specified limits. Shows current length and maximum allowed characters, with visual feedback when approaching or exceeding limits.

0
0

Size

Controls the overall size of the textfield (small, medium, large) to fit different layout requirements and visual hierarchies.

Density

Adjusts vertical spacing and padding (compact, comfortable, default) to optimize space usage in dense interfaces or provide more breathing room.

Message

Shows how to display helpful messages below the input field. Useful for providing instructions, hints, or additional context to users.

$ @gnomy.com
required
enter your custom email

Error

Demonstrates error states and validation feedback. Shows how the textfield appears when validation fails and how to display error messages to guide users.

Please enter a valid email address

Snippet

Illustrates the use of snippets to add custom content like icons, buttons, or decorative elements before or after the input field.

Form

Shows the textfield in a complete form context with labels, validation, and proper form integration. Demonstrates real-world usage patterns.

User Information Form

First Name
Please enter your first name
Last Name
Please enter your last name
Age
Please enter your age

API Reference

propstypedescriptiondefaulttype_extend
ref $bindableHTMLElementDirect access to DOM elementundefined
valuestringThe input value""
typeenumDefines the input typetexttext | email | password | number | tel | url
variantenumSets the visual style of the textfieldoutlinedoutlined | filled | underlined
sizeenumControls the overall size of the componentmediumsmall | medium | large
densityenumControls vertical spacing and paddingdefaultcompact | comfortable | default
labelstringLabel text displayed above or inside the fieldundefined
placeholderstringPlaceholder text shown when field is emptyundefined
disabledbooleanDisables the input fieldfalse
readonlybooleanMakes the field read-onlyfalse
requiredbooleanMarks the field as requiredfalse
errorbooleanShows error state stylingfalse
clearablebooleanShows a clear button when field has contentfalse
counterbooleanShows character counterfalse
maxlengthnumberMaximum number of characters allowedundefined
messagestringHelper or error message displayed below the fieldundefined
darkbooleanEnable dark theme for componentfalse
lightbooleanEnable light theme for componentfalse
colorstringApplies a custom color themeundefined
backgroundstringApply a custom background colorundefined

Variables CSS

variabledefaultdescription
--textfield-color--kit-label-primaryText color
--textfield-background--kit-background-primaryBackground color
--textfield-border--kit-stroke-secondaryBorder color
--textfield-radius--system-shape-mdBorder radius
--textfield-focus--kit-accent-primaryFocus state color
--textfield-error--kit-status-errorError state color

Textfield works great with Form validation and can be enhanced with Icons and Buttons using snippets.

Do you have a question? Ask on GitHub or Discord server

Do you see a bug? Open an issue on GitHub