Skip to main content
161

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
FormsGlass surface

Field

Groups labels, controls, descriptions, and errors.

FrameworksAstro · React · Elements

Registry commandlumen add Field

InteractionEnhanced runtime

01

See it and copy it

Framework example

Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroSame visual contract, native framework API

We only use this for release notes.

Lowercase letters, numbers, and hyphens.

Preview access is limited to approved invites.

Framework usage

Switch targets to compare the adapter code. The preview stays visually stable because all three packages share the same tokens and ui-* class contract.
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>
Edit Field in browser
02

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.

AstroSame visual contract, native framework API

Inputs inside a glass field pick up translucent chrome automatically.

Framework usage

Switch targets to compare the adapter code. The preview stays visually stable because all three packages share the same tokens and ui-* class contract.
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>
Edit Field in browser

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.

Web docsFull catalog