Component

Field

Layout primitives for form fields — a label, control, description, and error, laid out vertically or horizontally, and grouped into fieldsets and columns.

Label, description & error

A short title for your photo. A city is required.
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { HbFieldImports, HbInputDirective } from '@herbst/ui';

@Component({
  selector: 'hb-demo-field-basic',
  imports: [HbFieldImports, HbInputDirective],
  template: `
    <div class="flex w-full max-w-sm flex-col gap-6">
      <hb-field>
        <label hb-field-label hbRequired>Photo title</label>
        <input hb-input placeholder="Autumn in the Black Forest" />
        <hb-field-description>A short title for your photo.</hb-field-description>
      </hb-field>

      <hb-field hbInvalid>
        <label hb-field-label hbRequired>City</label>
        <input hb-input aria-invalid="true" placeholder="Freiburg" />
        <hb-field-error [hbErrors]="['A city is required.']" />
      </hb-field>
    </div>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoFieldBasicComponent {}

Horizontal

Receive a note when a new photo is shared.

Fieldset, legend & columns

Photo details

API reference

hb-field

PropertyDescriptionTypeDefault
[hbOrientation] Stack the label and control, place them in a row, or switch by container width. 'vertical' | 'horizontal' | 'responsive' 'vertical'
[hbInvalid] Mark the field invalid, tinting the label and error. boolean false

Parts

PropertyDescriptionTypeDefault
hb-field-label [hbRequired] The field label; hbRequired adds an asterisk. boolean false
hb-field-description Helper text below the control. slot
hb-field-error [hbErrors] Error messages shown when invalid. string[] []
hb-field-content Wraps the label and description as a block (for horizontal layouts). slot

Grouping

PropertyDescriptionTypeDefault
hb-field-group [hbColumns] Grid of fields; collapses to one column on narrow containers. 1 | 2 | 3 1
hb-field-set / hb-field-legend A fieldset and its legend (variant: legend or label). slot
hb-field-title / hb-field-separator A section title and a divider between groups. slot