Float label
hx-float-label wraps one control and its <label for> (the label comes after the control). The label sits in the field and moves up when the control has focus or a value.
html
<hx-float-label variant="on">
<input hx-input id="email" [(ngModel)]="email" />
<label for="email">Email</label>
</hx-float-label>
<hx-float-label>
<hx-select inputId="color" [options]="colors" [(value)]="color" />
<label for="color">Color</label>
</hx-float-label>| Input | Type | Default | Description |
|---|---|---|---|
variant | 'over' | 'in' | 'on' | 'over' | over: above the field, in: inside it (the field gets room), on: on its top border. |
- Behaviour: a native
hx-inputortextareafloats by:focus-withinand:placeholder-shown; an input without aplaceholdergets a blank one, and an explicit placeholder is hidden while the label sits in the field.hx-select,hx-passwordandhx-input-numberfloat by thehx-filledclass they set while they hold a value; a component that holds a value sets the same class to take part. Theoverlabel leaves the field's box: give the wrapper room above (margin-top). Invalid fields (aria-invalid="true",ng-invalid ng-touched) tint the label with--h-floatlabel-invalid-color. Motion stops underprefers-reduced-motion. - Accessibility: the label stays a real
<label for>, so the control keeps its name and a click on the label focuses it. Nothing but styling changes with the focus, so keyboard use is unchanged.
Tokens
The look comes from the design tokens --h-floatlabel-* (see Theming); override them in your theme, never the component CSS.
Part of @gravionlabs/helix-ui; all components are listed in the component reference.