Skip to content

InputDecoration

The InputDecoration class is used to configure the visual appearance of input fields, such as TextField. It allows you to define labels, borders, icons, hints, error messages, and more.

Usage

Pass an InputDecoration object to the decoration prop of a TextField component.

Basic Decoration

Username must be unique

Borders

Outline Border

Underline Border (Default)

No Border

Icons

Floating Label Behavior

Always

Never

Error State

Invalid input value

Prefix & Suffix Text

$
USD

Filled & Custom Color

Dense

Code Example

vue
<template>
  <div class="demo-container">
    <h2>Basic Decoration</h2>
    <div class="example-section">
      <TextField
        v-model="text1"
        :decoration="
          InputDecoration({
            labelText: 'Username',
            hintText: 'Enter your username',
            helperText: 'Username must be unique',
          })
        "
      />
    </div>

    <h2>Borders</h2>
    <div class="example-section">
      <h3>Outline Border</h3>
      <TextField
        v-model="text2"
        :decoration="
          InputDecoration({
            labelText: 'Outline',
            border: OutlineInputBorder(),
          })
        "
      />

      <h3>Underline Border (Default)</h3>
      <TextField
        v-model="text3"
        :decoration="
          InputDecoration({
            labelText: 'Underline',
            border: UnderlineInputBorder(),
          })
        "
      />

      <h3>No Border</h3>
      <TextField
        v-model="text4"
        :decoration="
          InputDecoration({
            labelText: 'No Border',
            border: InputBorder.none,
          })
        "
      />
    </div>

    <h2>Icons</h2>
    <div class="example-section">
      <TextField
        v-model="text5"
        :decoration="
          InputDecoration({
            labelText: 'With Icons',
            icon: Icons.person,
            prefixIcon: Icons.person,
            suffixIcon: Icons.checkCircle,
            border: OutlineInputBorder(),
          })
        "
      />
    </div>

    <h2>Floating Label Behavior</h2>
    <div class="example-section">
      <h3>Always</h3>
      <TextField
        v-model="text6"
        :decoration="
          InputDecoration({
            labelText: 'Always Floating',
            floatingLabelBehavior: FloatingLabelBehavior.always,
            border: OutlineInputBorder(),
          })
        "
      />

      <h3>Never</h3>
      <TextField
        v-model="text7"
        :decoration="
          InputDecoration({
            labelText: 'Never Floating',
            floatingLabelBehavior: FloatingLabelBehavior.never,
            border: OutlineInputBorder(),
          })
        "
      />
    </div>

    <h2>Error State</h2>
    <div class="example-section">
      <TextField
        v-model="text8"
        :decoration="
          InputDecoration({
            labelText: 'Error Input',
            errorText: 'Invalid input value',
            border: OutlineInputBorder(),
          })
        "
      />
    </div>

    <h2>Prefix & Suffix Text</h2>
    <div class="example-section">
      <TextField
        v-model="text9"
        :decoration="
          InputDecoration({
            labelText: 'Price',
            prefixText: '$',
            suffixText: 'USD',
            border: OutlineInputBorder(),
          })
        "
      />
    </div>

    <h2>Filled & Custom Color</h2>
    <div class="example-section">
      <TextField
        v-model="text10"
        :decoration="
          InputDecoration({
            labelText: 'Filled Input',
            filled: true,
            fillColor: Colors.grey200,
            border: OutlineInputBorder({
              borderSide: BorderSide({ style: 'none', width: 0 }),
              borderRadius: BorderRadius.circular(8),
            }),
          })
        "
      />
    </div>

    <h2>Dense</h2>
    <div class="example-section">
      <TextField
        v-model="text11"
        :decoration="
          InputDecoration({
            labelText: 'Dense Input',
            isDense: true,
            border: OutlineInputBorder(),
          })
        "
      />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import {
  TextField,
  InputDecoration,
  OutlineInputBorder,
  UnderlineInputBorder,
  InputBorder,
  Icons,
  Colors,
  FloatingLabelBehavior,
  BorderSide,
  BorderRadius,
} from "fluekit";

const text1 = ref("");
const text2 = ref("");
const text3 = ref("");
const text4 = ref("");
const text5 = ref("");
const text6 = ref("");
const text7 = ref("");
const text8 = ref("Wrong Value");
const text9 = ref("");
const text10 = ref("");
const text11 = ref("");
</script>

<style scoped>
.demo-container {
  padding: 20px;
  max-width: 600px;
}

.example-section {
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h2 {
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: bold;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
  color: #666;
}
</style>

Properties

PropertyTypeDescription
labelTextstringText that describes the input field.
labelStyleTextStyleStyle for the label text.
helperTextstringText that provides context about the input's value, such as how the value will be used.
helperStyleTextStyleStyle for the helper text.
hintTextstringText that suggests what sort of input the field accepts.
hintStyleTextStyleStyle for the hint text.
errorTextstringText that appears below the input when the input content is invalid.
errorStyleTextStyleStyle for the error text.
prefixIconstringAn icon that appears before the prefix or input text, inside the border.
prefixTextstringText that appears before the input text, inside the border.
suffixIconstringAn icon that appears after the suffix or input text, inside the border.
suffixTextstringText that appears after the input text, inside the border.
counterTextstringText to place below the line as a character count.
filledbooleanWhether the decoration's container is filled with fillColor.
fillColorColorThe color to fill the decoration's container with, if filled is true.
borderInputBorderThe border to display when the InputDecorator does not have the focus and is not showing an error.
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.
contentPaddingEdgeInsetsThe padding for the input decoration's container.
isDensebooleanWhether the input decoration is dense.
floatingLabelBehaviorFloatingLabelBehaviorDefines how the floating label behaves.
iconstringAn icon to show before the input field and outside of the decoration's container.

Borders

The border property (and related properties like enabledBorder, focusedBorder, etc.) accepts an InputBorder object. You can create these objects using helper functions or use the pre-defined none constant.

OutlineInputBorder

Creates a rounded rectangle border.

ts
InputDecoration({
  border: OutlineInputBorder({
    borderRadius: BorderRadius.circular(8),
    borderSide: BorderSide({ color: Colors.blue, width: 2 }),
  }),
});

UnderlineInputBorder

Creates a horizontal line at the bottom. This is the default border type for TextField.

ts
InputDecoration({
  border: UnderlineInputBorder({
    borderSide: BorderSide({ color: Colors.grey, width: 1 }),
  }),
});

InputBorder.none

Removes the border completely.

ts
InputDecoration({
  border: InputBorder.none,
});

FloatingLabelBehavior

  • auto: The label floats when the input is focused or has content. (Default)
  • always: The label always floats above the input.
  • never: The label never floats.