--- 
title: Formfield
description: Form field wrapper with label, hints, and error messages
category: components
alias: control
a1Full: true
group: Forms & Inputs

module: NxFormfieldModule
components:
  - name: NxFormfieldComponent
    selector: nx-formfield
    inputs:
      - name: label
        desc: "Sets the label which will act as a floating label. In addition, the component uses input and label to properly support accessibility."
        default: input<string | null>()
        type: "InputSignal<string | null | undefined>"
      - name: inline
        desc: "Whether the form field is rendered inline. When enabled the reserved space around the field (top floating-label space and bottom hint/error/note space) is removed and the label as well as the hints, errors, notes and status message are visually hidden. They are kept in the accessibility tree, so the control still references them via `aria-describedby` and a screen reader still announces them. Surface anything a sighted user needs to see some other way, for example with a `nx-signal-button` in the `nxFormfieldSuffix` slot."
        default: input(false, { transform: booleanAttribute })
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: status
        desc: "Colors the border of the formfield in the given signal color and renders a plain message below the field. Mark the message content with the `nxFormfieldStatusMessage` attribute — always provide it, as a status without a message leaves a colored border with no explanation of why.  Only supported for `appearance='outline'`. An error (an invalid, touched form control together with a `nxFormfieldError`) takes precedence over the status."
        default: input<NxFormfieldStatus | null>(null)
        type: "InputSignal<'positive' | 'warning' | 'info' | null>"
      - name: optionalLabelInput
        desc: "Set optional text, which will additionally show in label if a field is not mandatory."
        default: input<string>(undefined, { alias: 'optionalLabel' })
        type: "InputSignal<string | undefined>"
      - name: size
        desc: "Sets the size of the formfield.  Only supported under A1."
        default: input<NxFormfieldSize>('m')
        type: "InputSignal<'s' | 'm'>"
      - name: floatLabel
        desc: "Whether the label should float once the input is focused or filled (auto, default) or force it to always float with a value of always to simulate a more static form. Can be changed for NDBX only. A1 enforces always floating labels."
        type: "'always' | 'auto'"
      - name: negative
        desc: "Sets the styling of the formfield. If 'negative', a negative set of stylings is used."
        type: "string"
      - name: appearance
        desc: "**Expert option**  Sets the appearance of the formfield. Can be changed for NDBX only. A1 enforces outline appearance."
        type: "'outline' | 'auto'"
      - name: updateOn
        desc: "Sets the event that triggers change detection in the formfield."
        type: "'change' | 'blur'"
    methods:
      - name: getDisplayedMessage
        params: 
        returnType: "" | "error" | "note" | "status"
      - name: getConnectedOverlayOrigin
        params: 
        desc: "Returns an element that overlays can attach to."
        returnType: ElementRef<any>
  - name: NxFormfieldHintDirective
    selector: [nxFormfieldHint]
    inputs:
      - name: id
        desc: "Sets the id of the formfield hint."
        default: input(inject(IdGenerationService).nextId('nx-formfield-hint'))
        type: "InputSignal<any>"
  - name: NxFormfieldErrorDirective
    selector: [nxFormfieldError], [nxError]
    inputs:
      - name: id
        desc: "Sets the id of the formfield error."
        default: input(inject(IdGenerationService).nextId('nx-formfield-error'))
        type: "InputSignal<any>"
  - name: NxFormfieldNoteDirective
    selector: [nxFormfieldNote]
    inputs:
      - name: id
        desc: "Sets the id of the formfield note."
        default: input(inject(IdGenerationService).nextId('nx-formfield-note'))
        type: "InputSignal<any>"
  - name: NxFormfieldPrefixDirective
    selector: [nxFormfieldPrefix]
  - name: NxFormfieldSuffixDirective
    selector: [nxFormfieldSuffix]
  - name: NxFormfieldAppendixDirective
    selector: [nxFormfieldAppendix]
    inputs:
      - name: id
        desc: "Sets the id of the formfield appendix."
        default: input(inject(IdGenerationService).nextId('nx-formfield-appendix'))
        type: "InputSignal<any>"
  - name: NxFormfieldLabelDirective
    selector: nx-formfield-label
    desc: |
      A directive for passing more complex custom label content.

---
# Overview
In most cases it is sufficient to only import the nxInputModule - this **already includes the NxFormfieldModule module**.

```ts
import { NxInputModule } from '@allianz/ng-aquila/input';
```

Alternatively you could import NxFormfieldModule, but in this case you are required to also add an [nxInput](./documentation/input/overview) control to the html template, like in the Basic Example below.

```ts
import { NxFormfieldModule } from '@allianz/ng-aquila/formfield';
```

The formfield component is only usable in combination with a compatible input like nxInput. You will get floating labels, hints and a space to properly render additional information and errors below the input.

You can't use the formfield without a matching input. A matching input fulfills the requirements of the `NxFormfieldControl` interface.

**Changes to formfield paddings:** Starting v16, bottom padding is now applied to both Error and Hint messages. The new bottom padding for Expert is 16px, Retail (Desktop) 32px and Retail (Mobile) 24px. If you would like to keep the old padding values, include `@allianz/ng-aquila/css/compatibility/formfield-padding.css` in your `angular.json`.
