Skip to content

TextField & TextArea ​

Material Design text fields that allow users to enter text.

Basic Usage ​

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

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

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

<script setup lang="ts">
import { ref } from "vue";
import { Column, Text, TextField, OutlineInputBorder } 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:
No label, no hint:
Underline border without label:
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="{ labelText: 'Outline', border: OutlineInputBorder() }"
    />

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

<script setup lang="ts">
import { ref } from "vue";
import { Column, Text, TextField, OutlineInputBorder, UnderlineInputBorder } 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>

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 ζ–‡ζœ¬θ‘¨ηŽ°γ€‚

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.
errorTextstringText that appears below the field when the input is invalid.
prefixTextstringText to place before the input.
suffixTextstringText to place after the input.
borderInputBorderThe border to draw around the field.
filledbooleanIf true, the decoration's container is filled with fillColor.
fillColorstringThe color to fill the decoration's container with.

Helper Functions ​

  • OutlineInputBorder({ borderSide?, borderRadius? })
  • UnderlineInputBorder({ borderSide?, borderRadius? })