Componente

Field

Primitivos de layout para campos de formulário — rótulo, controle, descrição e erro, dispostos na vertical ou horizontal, e agrupados em fieldsets e colunas.

Rótulo, descrição e erro

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, legenda e colunas

Photo details

Referência de API

hb-field

PropriedadeDescriçãoTipoPadrão
[hbOrientation] Empilha rótulo e controle, coloca-os em linha, ou alterna pela largura do contêiner. 'vertical' | 'horizontal' | 'responsive' 'vertical'
[hbInvalid] Marca o campo como inválido, tingindo o rótulo e o erro. boolean false

Parts

PropriedadeDescriçãoTipoPadrão
hb-field-label [hbRequired] O rótulo do campo; hbRequired adiciona um asterisco. boolean false
hb-field-description Texto de ajuda abaixo do controle. slot
hb-field-error [hbErrors] Mensagens de erro exibidas quando inválido. string[] []
hb-field-content Envolve rótulo e descrição como bloco (para layouts horizontais). slot

Grouping

PropriedadeDescriçãoTipoPadrão
hb-field-group [hbColumns] Grade de campos; colapsa para uma coluna em contêineres estreitos. 1 | 2 | 3 1
hb-field-set / hb-field-legend Um fieldset e sua legenda (variant: legend ou label). slot
hb-field-title / hb-field-separator Um título de seção e um divisor entre grupos. slot