Twitter0

Field

Combine labels, controls, and help text to compose accessible form fields and grouped inputs.

Payment Method

All transactions are secure and encrypted

Enter your 16-digit card number without spaces or dashes.

Billing Address

The billing address associated with your payment method

Installation

npx nx g @spartan-ng/cli:ui field

Usage

import { HlmFieldImports } from "@spartan-ng/helm/field";
<fieldset hlmFieldSet>
    <legend hlmFieldLegend>Profile</legend>
    <p hlmFieldDescription>This appears on invoices and emails.</p>
    <div hlmFieldGroup>
        <div hlmField>
            <label hlmFieldLabel for="field-preview-fullname">Full name</label>
            <input hlmInput id="field-preview-fullname" type="text" placeholder="John Doe" />
            <p hlmFieldDescription>This appears on invoices and emails.</p>
        </div>
        <div hlmField>
            <label hlmFieldLabel for="field-preview-username">Username</label>
            <input hlmInput id="field-preview-username" type="text" placeholder="john_doe_99" />
            <hlm-field-error>Choose another username.</hlm-field-error>
        </div>
        <div hlmField orientation="horizontal">
            <hlm-switch id="field-preview-subscribe-newsletter" />
            <label hlmFieldLabel for="field-preview-subscribe-newsletter">Subscribe to the newsletter</label>
        </div>
    </div>
</fieldset>

Anatomy

The Field family is designed for composing accessible forms. A typical field is structured as follows:

<div hlmField>
    <label hlmFieldLabel for="field-preview-fullname">Label</label>
    <!-- Input, Select, Switch, etc. -->
    <p hlmFieldDescription>Optional helper text.</p>
    <hlm-field-error>Validation message.</hlm-field-error>
</div>
  • HlmField is the core wrapper for a single field.
  • HlmFieldContent is a flex column that groups label and description. Not required if you have no description.
  • Wrap related fields with HlmFieldGroup , and use HlmFieldSet with HlmFieldLegend for semantic grouping.

Examples

Input

Choose a unique username for your account.

Must be at least 8 characters long.

Textarea

Share your thoughts about our service.

Select

Select your department or area of work.

Slider

Set your budget range ($0 - 500).

Fieldset

Address Information

Choose a unique username for your account.

Checkbox

Show these items on the desktop

Select the items you want to show on the desktop.

Your Desktop & Documents folders are being synced with iCloud Drive. You can access them from other devices.

Radio

Yearly and lifetime plans offer significant savings.

Switch

Enable multi-factor authentication. If you do not have a two-factor device, you can use a one-time code sent to your email.

Choice Card

Wrap HlmField directives inside HlmFieldLabel to create selectable field groups. This works with RadioItem , Checkbox and Switch components.

Select the compute environment for your cluster.

Field Group

Stack HlmField directives with HlmFieldGroup . Add HlmFieldSeparator to divide them.

Get notified when ChatGPT responds to requests that take time, like research or image generation.

Get notified when tasks you've created have updates. Manage tasks

Responsive Layout

  • Vertical fields: Default orientation stacks label, control, and helper text—ideal for mobile-first layouts.
  • Horizontal fields: Set orientation="horizontal" on HlmField to align the label and control side-by-side. Pair with HlmFieldContent to keep descriptions aligned.
  • Responsive fields: Set orientation="responsive" for automatic column layouts inside container-aware parents. Apply @container/field-group classes on HlmFieldGroup to switch orientations at specific breakpoints.
Profile

Fill in your profile information.

Provide your full name for identification

You can write your message here. Keep it short, preferably under 100 characters.

Validation and Errors

  • Add data-invalid to HlmField to switch the entire block into an error state.
  • Add aria-invalid on the input itself for assistive technologies.
  • Render FieldError immediately after the control or inside FieldContent to keep error messages aligned with the field.
<div hlmField data-invalid="true">
	<label hlmFieldLabel for="validation-error-email">Email</label>
	<input hlmInput id="validation-error-email" type="email" aria-invalid="true" />
	<hlm-field-error>Enter a valid email address.</hlm-field-error>
</div>

Accessibility

  • HlmFieldSet and HlmFieldLegend keep related controls grouped for keyboard and assistive tech users.
  • HlmField outputs role="group" so nested controls inherit labeling from HlmFieldLabel and HlmFieldLegend when combined.
  • Apply HlmFieldSeparator sparingly to ensure screen readers encounter clear section boundaries.

Helm API

HlmFieldContent

Selector: [hlmFieldContent],hlm-field-content

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmFieldDescription

Selector: [hlmFieldDescription],hlm-field-description

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmFieldError

Selector: hlm-field-error

Inputs

PropTypeDefaultDescription
class ClassValue --
error Array<{ message: string } | undefined> --

HlmFieldGroup

Selector: [hlmFieldGroup],hlm-field-group

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmFieldLabel

Selector: [hlmFieldLabel]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmFieldLegend

Selector: legend[hlmFieldLegend]

Inputs

PropTypeDefaultDescription
class ClassValue --
variant 'label' | 'legend' legend -

HlmFieldSeparator

Selector: hlm-field-separator

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmFieldSet

Selector: fieldset[hlmFieldSet]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmFieldTitle

Selector: [hlmFieldTitle],hlm-field-title

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmField

Selector: [hlmField],hlm-field

Inputs

PropTypeDefaultDescription
orientation FieldVariants['orientation'] vertical -
class ClassValue --
Form Field Empty