Skip to content

TextField & TextArea ​

Material Design text fields that allow users to enter text.

Basic Usage ​

πŸ”’
Enter your password
πŸ”’
Username:
vue
<template>
  <Column :gap="20">
    <TextField
      v-model="value"
      :decoration="
        InputDecoration({
          labelText: 'Username',
          hintText: 'Enter your username',
          border: OutlineInputBorder(),
        })
      "
    />

    <TextField
      v-model="password"
      obscure-text
      :decoration="
        InputDecoration({
          labelText: 'Password',
          hintText: 'Enter your password',
          border: OutlineInputBorder(),
          prefixText: 'πŸ”’ ',
          floatingLabelBehavior: FloatingLabelBehavior.always,
        })
      "
    />
    <TextField
      v-model="password"
      obscure-text
      :decoration="
        InputDecoration({
          labelText: 'Password',
          hintText: 'Enter your password',
          border: UnderlineInputBorder(),
          prefixText: 'πŸ”’ ',
        })
      "
    />

    <Text>Username: {{ value }}</Text>
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import {
  Column,
  Text,
  TextField,
  OutlineInputBorder,
  InputDecoration,
  UnderlineInputBorder,
  FloatingLabelBehavior,
} from "fluekit";

const value = ref("");
const password = ref("");
</script>

No Label ​

TextField without a floating label, relying on hintText or layout context.

With hintText only:
Enter something...
No label, no hint:
Underline border without label:
Type here
vue
<template>
  <Column :gap="20">
    <Text>With hintText only:</Text>
    <TextField
      v-model="text1"
      :decoration="{
        hintText: 'Enter something...',
        border: OutlineInputBorder(),
      }"
    />

    <Text>No label, no hint:</Text>
    <TextField
      v-model="text2"
      :decoration="{
        border: OutlineInputBorder(),
      }"
    />

    <Text>Underline border without label:</Text>
    <TextField
      v-model="text3"
      :decoration="{
        hintText: 'Type here',
      }"
    />
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Column, Text, TextField, OutlineInputBorder } from "fluekit";

const text1 = ref("");
const text2 = ref("");
const text3 = ref("");
</script>

TextArea (Multi-line) ​

You can use the TextArea component for multi-line input, or TextField with maxLines > 1.

Using TextArea component:
Using TextField with maxLines:
vue
<template>
  <Column :gap="20">
    <Text>Using TextArea component:</Text>
    <TextArea
      v-model="bio"
      auto-grow
      :decoration="{
        labelText: 'Biography',
        hintText: 'Tell us about yourself',
        border: OutlineInputBorder(),
      }"
    />

    <Text>Using TextField with maxLines:</Text>
    <TextField
      v-model="notes"
      auto-grow
      :max-lines="3"
      :decoration="{
        labelText: 'Notes',
        border: OutlineInputBorder(),
      }"
    />
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Column, Text, TextArea, TextField, OutlineInputBorder } from "fluekit";

const bio = ref("");
const notes = ref("");
</script>

Borders ​

Outline
Underline
vue
<template>
  <Column :gap="20">
    <Text>Outline</Text>
    <TextField
      v-model="outline"
      :decoration="InputDecoration({ labelText: 'Outline', border: OutlineInputBorder() })"
    />

    <Text>Underline</Text>
    <TextField
      v-model="underline"
      :decoration="InputDecoration({ labelText: 'Underline', border: UnderlineInputBorder() })"
    />
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import {
  Column,
  Text,
  TextField,
  OutlineInputBorder,
  UnderlineInputBorder,
  InputDecoration,
} from "fluekit";
const outline = ref("");
const underline = ref("");
</script>

Prefix & Suffix ​

@
.com
Value:
vue
<template>
  <Column :gap="20">
    <TextField
      v-model="email"
      :decoration="{
        labelText: 'Email',
        hintText: 'example@domain.com',
        border: UnderlineInputBorder(),
      }"
    >
      <template #prefix>
        <Text style="color: #888">@</Text>
      </template>
      <template #suffix>
        <Text style="color: #888">.com</Text>
      </template>
    </TextField>

    <Text>Value: {{ email }}</Text>
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Column, Text, TextField, UnderlineInputBorder } from "fluekit";
const email = ref("");
</script>

Icons ​

Prefix & Suffix Text
mailto:
example
@gmail.com
With Icons
Outside Icon
vue
<template>
  <Column :gap="20">
    <Text :style="TextStyle({ fontSize: 18, fontWeight: FontWeight.bold })"
      >Prefix & Suffix Text</Text
    >
    <TextField
      v-model="email"
      :decoration="
        InputDecoration({
          labelText: 'Email',
          hintText: 'example',
          prefixText: 'mailto:',
          suffixText: '@gmail.com',
          border: OutlineInputBorder(),
          floatingLabelBehavior: FloatingLabelBehavior.always,
        })
      "
    />

    <Text :style="TextStyle({ fontSize: 18, fontWeight: FontWeight.bold })">With Icons</Text>
    <TextField
      v-model="username"
      :decoration="
        InputDecoration({
          labelText: 'Username',
          border: OutlineInputBorder(),
        })
      "
    >
      <template #prefixIcon>
        <Icon :icon="Icons.person" :size="20" color="#666" />
      </template>
      <template #suffixIcon>
        <Icon :icon="Icons.checkCircle" :size="20" color="green" />
      </template>
    </TextField>

    <Text :style="TextStyle({ fontSize: 18, fontWeight: FontWeight.bold })">Outside Icon</Text>
    <TextField
      v-model="search"
      :decoration="
        InputDecoration({
          labelText: 'Search',
          hintText: 'Type to search...',
        })
      "
    >
      <template #icon>
        <Icon :icon="Icons.search" :size="24" color="#666" />
      </template>
    </TextField>
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import {
  Column,
  Text,
  TextField,
  OutlineInputBorder,
  Icon,
  Icons,
  TextStyle,
  FontWeight,
  InputDecoration,
  FloatingLabelBehavior,
} from "fluekit";

const email = ref("");
const username = ref("");
const search = ref("");
</script>

Filled ​

vue
<template>
  <Column :gap="20">
    <TextField
      v-model="name"
      :decoration="{
        labelText: 'Name',
        filled: true,
        fillColor: '#f7f7f7',
        border: OutlineInputBorder(),
      }"
    />
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Column, TextField, OutlineInputBorder } from "fluekit";
const name = ref("");
</script>

States ​

Read-only、Disabled 与 Error ζ–‡ζœ¬θ‘¨ηŽ°γ€‚

Too short
vue
<template>
  <Column :gap="20">
    <TextField
      v-model="readonlyValue"
      read-only
      :decoration="{ labelText: 'ReadOnly', border: OutlineInputBorder() }"
    />

    <TextField
      v-model="disabledValue"
      :enabled="false"
      :decoration="{ labelText: 'Disabled', border: OutlineInputBorder() }"
    />

    <TextField
      v-model="errorValue"
      :decoration="{
        labelText: 'Error',
        errorText: errorValue.length < 3 ? 'Too short' : '',
        border: OutlineInputBorder(),
      }"
    />
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Column, TextField, OutlineInputBorder } from "fluekit";
const readonlyValue = ref("fixed");
const disabledValue = ref("");
const errorValue = ref("");
</script>

Auto Height ​

Multi-line input can automatically adjust its height based on content by setting auto-grow prop (limited by maxLines).

Auto height TextArea
Length: 0
vue
<template>
  <Column :gap="20">
    <Text>Auto height TextArea</Text>
    <TextArea
      v-model="content"
      auto-grow
      :max-lines="8"
      :decoration="{ labelText: 'Description', border: OutlineInputBorder() }"
    />
    <Text>Length: {{ content.length }}</Text>
  </Column>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Column, Text, TextArea, OutlineInputBorder } from "fluekit";
const content = ref("");
</script>

API ​

TextField ​

PropTypeDefaultDescription
modelValuestring-The current text value.
decorationInputDecoration-The decoration to show around the text field.
maxLinesnumber | null1The maximum number of lines to show at one time. If > 1 or null, it becomes a textarea.
maxLengthnumber-The maximum number of characters allowed. Shows a counter if set.
textAlignstringstartHow the text should be aligned horizontally.
textInputActionstring-The type of action button to use for the keyboard (e.g., 'enter', 'go', 'search').
textCapitalizationstringnoneConfigures how the platform should capitalize text (e.g., 'words', 'sentences').
autocorrectbooleantrueWhether to enable autocorrection.
autoGrowbooleanfalseWhether the input should automatically grow height based on content (only for multiline).
obscureTextbooleanfalseWhether to hide the text being edited (e.g., for passwords).
enabledbooleantrueWhether the text field is enabled.
readOnlybooleanfalseWhether the text can be changed.
styleTextStyle-The style to use for the text being edited.

TextArea ​

Wrapper around TextField with default maxLines and keyboardType.

PropTypeDefaultDescription
maxLinesnumber4Default lines.

InputDecoration ​

PropTypeDescription
labelTextstringText that describes the input field.
hintTextstringText that suggests what sort of input the field accepts.
helperTextstringText that provides context about the input field's value, such as how the value will be used.
errorTextstringText that appears below the field when the input is invalid.
iconstring | ComponentAn icon that appears before the editable part of the text field and outside the decoration's container.
prefixIconstring | ComponentAn icon that appears before the prefix or prefixText and before the editable part of the text field.
suffixIconstring | ComponentAn icon that appears after the editable part of the text field and after the suffix or suffixText.
prefixTextstringText to place before the input.
suffixTextstringText to place after the input.
borderInputBorderThe border to draw around the field.
enabledBorderInputBorderThe border to display when the InputDecorator is enabled and is not showing an error.
focusedBorderInputBorderThe border to display when the InputDecorator has the focus and is not showing an error.
errorBorderInputBorderThe border to display when the InputDecorator is showing an error.
focusedErrorBorderInputBorderThe border to display when the InputDecorator has the focus and is showing an error.
disabledBorderInputBorderThe border to display when the InputDecorator is disabled and is not showing an error.
filledbooleanIf true, the decoration's container is filled with fillColor.
fillColorstringThe color to fill the decoration's container with.
contentPaddingnumber | number[] | EdgeInsetsThe padding for the input decoration's container.
isDensebooleanWhether the input is part of a dense form (i.e., uses less vertical space).
isCollapsedbooleanWhether the decoration is the same size as the input field.
floatingLabelBehaviorFloatingLabelBehaviorDefines how the floating label should behave. (always, auto, never)
counterTextstringOptional text to place below the line as a character count.
labelStyleTextStyleThe style to use for the floating label.
floatingLabelStyleTextStyleThe style to use for the floating label when it is floating.
hintStyleTextStyleThe style to use for the hintText.
helperStyleTextStyleThe style to use for the helperText.
errorStyleTextStyleThe style to use for the errorText.
counterStyleTextStyleThe style to use for the counterText.

Helper Functions ​

OutlineInputBorder ​

Creates a rounded rectangle outline border.

typescript
function OutlineInputBorder(options?: {
  borderSide?: BorderSide;
  borderRadius?: BorderRadius;
}): InputBorder;

UnderlineInputBorder ​

Creates an underline border.

typescript
function UnderlineInputBorder(options?: {
  borderSide?: BorderSide;
  borderRadius?: BorderRadius;
}): InputBorder;