121
GitHub
FormsGlass surface

Field

Groups labels, controls, descriptions, and errors.

FrameworksAstro · React · Elements

Registry commandlumen add Field

InteractionEnhanced runtime

01

See it in context

Preview

We only use this for release notes.

Lowercase letters, numbers, and hyphens.

Preview access is limited to approved invites.

02

Copy a working example

Usage

Astro examples assume UIPrimitives is mounted once in your root layout. Do not add the runtime next to each component instance.

astro
---
import {
  Button,
  Field,
  Input,
  Label
} from '@santi020k/lumen-astro'
---

<form data-ui-form data-ex-validated-form style="display: grid; gap: 1rem; max-width: 26rem;">
  <Field>
    <Label for="ex-email">Email</Label>
    <Input
      data-error-required="Add an email address."
      id="ex-email"
      name="email"
      placeholder="you@example.com"
      required
      type="email"
    />
    <p data-ui-field-hint>We only use this for release notes.</p>
    <p data-ui-field-error hidden></p>
  </Field>

  <Field>
    <Label for="ex-workspace">Workspace slug</Label>
    <Input
      data-error-pattern="Use lowercase letters, numbers, and hyphens only."
      id="ex-workspace"
      name="workspace"
      pattern="[a-z0-9-]+"
      placeholder="lumen-team"
      required
    />
    <p data-ui-field-hint>Lowercase letters, numbers, and hyphens.</p>
    <p data-ui-field-error hidden></p>
  </Field>

  <Field>
    <Label for="ex-invite">Invite code</Label>
    <Input
      data-error-custom="Use LUMEN-2026 for the preview."
      id="ex-invite"
      name="inviteCode"
      placeholder="LUMEN-2026"
      required
    />
    <p data-ui-field-hint>Preview access is limited to approved invites.</p>
    <p data-ui-field-error hidden></p>
  </Field>

  <Button type="submit">Request access</Button>
  <p data-ex-form-status aria-live="polite" style="margin: 0;"></p>
</form>

<script>
  const form = document.querySelector('[data-ex-validated-form]')
  const status = document.querySelector('[data-ex-form-status]')

  form?.addEventListener('ui:validate', event => {
    const control = event instanceof CustomEvent ? event.detail?.control : null

    if (!(control instanceof HTMLInputElement) || control.name !== 'inviteCode') return

    control.setCustomValidity(!control.value || control.value === 'LUMEN-2026'
      ? ''
      : 'Use LUMEN-2026 for the preview.')
  })

  form?.addEventListener('submit', event => {
    event.preventDefault()
  })

  form?.addEventListener('ui:invalid', () => {
    if (status) status.textContent = 'Resolve the highlighted fields.'
  })

  form?.addEventListener('ui:valid', () => {
    if (status) status.textContent = 'Form is ready to submit.'
  })
</script>
---
import {
  Button,
  Field,
  Input,
  Label
} from '@santi020k/lumen-astro'
---

<form data-ui-form data-ex-validated-form style="display: grid; gap: 1rem; max-width: 26rem;">
  <Field>
    <Label for="ex-email">Email</Label>
    <Input
      data-error-required="Add an email address."
      id="ex-email"
      name="email"
      placeholder="you@example.com"
      required
      type="email"
    />
    <p data-ui-field-hint>We only use this for release notes.</p>
    <p data-ui-field-error hidden></p>
  </Field>

  <Field>
    <Label for="ex-workspace">Workspace slug</Label>
    <Input
      data-error-pattern="Use lowercase letters, numbers, and hyphens only."
      id="ex-workspace"
      name="workspace"
      pattern="[a-z0-9-]+"
      placeholder="lumen-team"
      required
    />
    <p data-ui-field-hint>Lowercase letters, numbers, and hyphens.</p>
    <p data-ui-field-error hidden></p>
  </Field>

  <Field>
    <Label for="ex-invite">Invite code</Label>
    <Input
      data-error-custom="Use LUMEN-2026 for the preview."
      id="ex-invite"
      name="inviteCode"
      placeholder="LUMEN-2026"
      required
    />
    <p data-ui-field-hint>Preview access is limited to approved invites.</p>
    <p data-ui-field-error hidden></p>
  </Field>

  <Button type="submit">Request access</Button>
  <p data-ex-form-status aria-live="polite" style="margin: 0;"></p>
</form>

<script>
  const form = document.querySelector('[data-ex-validated-form]')
  const status = document.querySelector('[data-ex-form-status]')

  form?.addEventListener('ui:validate', event => {
    const control = event instanceof CustomEvent ? event.detail?.control : null

    if (!(control instanceof HTMLInputElement) || control.name !== 'inviteCode') return

    control.setCustomValidity(!control.value || control.value === 'LUMEN-2026'
      ? ''
      : 'Use LUMEN-2026 for the preview.')
  })

  form?.addEventListener('submit', event => {
    event.preventDefault()
  })

  form?.addEventListener('ui:invalid', () => {
    if (status) status.textContent = 'Resolve the highlighted fields.'
  })

  form?.addEventListener('ui:valid', () => {
    if (status) status.textContent = 'Form is ready to submit.'
  })
</script>
03

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add Field
lumen add Field

Glass

Add the glass prop to apply the shared blur, saturation, border, and highlight tokens. Glass reads best over vivid content, so place the surface above imagery or color.

Inputs inside a glass field pick up translucent chrome automatically.

astro
---
import { Button, Field, Input, Label } from '@santi020k/lumen-astro'
---

<div class="docs-glass-demo" style="justify-items: center;">
  <Field glass style="min-width: min(100%, 22rem); padding: 1.25rem; border-radius: 0.75rem;">
    <Label for="glass-workspace">Workspace</Label>
    <Input id="glass-workspace" placeholder="Lumen Labs" />
    <p>Inputs inside a glass field pick up translucent chrome automatically.</p>
    <Button size="sm">Save</Button>
  </Field>
</div>
---
import { Button, Field, Input, Label } from '@santi020k/lumen-astro'
---

<div class="docs-glass-demo" style="justify-items: center;">
  <Field glass style="min-width: min(100%, 22rem); padding: 1.25rem; border-radius: 0.75rem;">
    <Label for="glass-workspace">Workspace</Label>
    <Input id="glass-workspace" placeholder="Lumen Labs" />
    <p>Inputs inside a glass field pick up translucent chrome automatically.</p>
    <Button size="sm">Save</Button>
  </Field>
</div>

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
glassboolean | "subtle" | "strong"falseApplies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity.
controlIdstring-Connects the field to a control elsewhere in the field root.
describedByspace-separated ids-Adds ids to the control aria-describedby value.
data-ui-formboolean attribute-Opts a form into native Constraint Validation API enhancement.
data-error-required, data-error-pattern, data-error-min, data-error-max, data-error-customstring-Overrides browser validationMessage text for matching constraints.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Runtime events

CustomEvents dispatched by the Astro UIPrimitives runtime for this component.

EventTargetDetailWhen
ui:validateForm ([data-ui-form]){ control: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, form: HTMLFormElement, value: string }Fires before the runtime reads native validity so custom validators can call control.setCustomValidity(message).
ui:invalidForm ([data-ui-form]){ control?: HTMLElement, controls?: HTMLElement[], form: HTMLFormElement }Fires after blur or submit validation finds one or more invalid controls.
ui:validForm ([data-ui-form]){ control?: HTMLElement, controls?: HTMLElement[], form: HTMLFormElement }Fires after blur or submit validation finds the checked control or form valid.