# Blazor Floating Label Overview

The <a href="https://www.telerik.com/blazor-ui/floatinglabel" target="_blank">Blazor FloatingLabel component</a> provides additional features and improved user experience, compared to the standard HTML `label`. The floating label displays on top of empty non-focused components and moves above them on focus.

## Benefits

The Telerik FloatingLabel enhances HTML `label` functionality in the following ways:

* built-in animations
* integration with form validation
* integration with the `placeholder` attribute
* association with non-form elements - for example, the TelerikDropDownList component renders as a `<span>`

## Creating Blazor FloatingLabel

1. Use the `TelerikFloatingLabel` tag.
2. Set the `Text` parameter of the floating label.
3. Place a [compatible Telerik component](https://www.telerik.com/blazor-ui/documentation/components/floatinglabel/overview#compatibility) inside the floating label.
4. Set an `Id` to the Telerik component. The `Id` value will automatically render as a `for` attribute for the `<label>` element.

> caption How to use a Floating Label

<demo metaUrl="client/floatinglabel/overview/example-1/" height="300"></demo>

## Compatibility

The FloatingLabel integrates with focusable Telerik Blazor components:

* AutoComplete
* ComboBox
* DateInput
* DatePicker
* DateTimePicker
* DropDownList
* MaskedTextBox
* MultiSelect
* NumericTextBox
* TextArea
* TextBox
* TimePicker

The FloatingLabel does not support third-party components and generic HTML inputs.

## Forms and Validation

The FloatingLabel can change its styles, based on validation state. See [Validation](https://www.telerik.com/blazor-ui/documentation/components/floatinglabel/validation) for details and example.

## Placeholder Behavior

Labels and placeholders serve similar purpose for the user experience.

If a Telerik component has both a `Placeholder` and a floating label, the behavior is:

* When the floating label is **over the component**, then the placeholder is **not rendered**.
* When the floating label is **outside the component** and the focused component has no value, the placeholder **is visible**.

## Integration with Prefix Adornment

When using the [`PrefixTemplate`](https://www.telerik.com/blazor-ui/documentation/common-features/input-adornments#adding-a-prefix-adornment) for a component wrapped in a [FloatingLabel](https://www.telerik.com/blazor-ui/documentation/components/floatinglabel/overview), the label will overlap the prefix.

To ensure both the FloatingLabel and the prefix content are properly displayed, move the label with CSS:

<demo metaUrl="client/floatinglabel/prefix-adornment/" height="300"></demo>

## FloatingLabel Parameters

The following table lists the FloatingLabel parameters. Also check the [FloatingLabel API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikfloatinglabel) for a full list of properties, methods and events.

<style>
    .article table {
        table-layout: auto;
        word-break: normal;
    }
</style>

| Attribute | Type     | Description                                                                                                                                                                                                                                                                   |
| --------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Class`   | `string` | Renders additional CSS class to the `span.k-floating-label-container` element, which holds the `<label>` child element. Use `Class` to apply custom styles or [override the theme](https://www.telerik.com/blazor-ui/documentation/styling-and-themes/override-theme-styles). |
| `Id`      | `string` | Renders an `id` attribute to the `label.k-label` element. To improve accessibility, set the same string as floating label `Id` and `AriaLabelledBy` value of the associated Telerik component.                                                                                |

## Next Steps

* [Review Floating Label integration with form validation](https://www.telerik.com/blazor-ui/documentation/components/floatinglabel/validation)

## See Also

* [Live Floating Label Demos](https://demos.telerik.com/blazor-ui/floatinglabel/overview)
* [Floating Label API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikfloatinglabel)
