Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
FormsGlass surface

Field

Groups labels, controls, descriptions, and errors.

Frameworks
Astro · React · Elements · Dioxus
Registry
lumen add Field
Interaction
Enhanced runtime
01

See it and copy it

Framework example

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

AstroCode target · live preview uses Astro

We only use this for release notes.

Lowercase letters, numbers, and hyphens.

Preview access is limited to approved invites.

View Field code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
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="[email protected]"
      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
bashAstro wrapper
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.

AstroCode target · live preview uses Astro

Inputs inside a glass field pick up translucent chrome automatically.

View Field code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React and Elements use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
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. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

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.

Customize Field

Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.

cssScoped theme overrides
.product-field {
  --surface: 0 0% 100%;
  --ink: 220 20% 15%;
  --line: 220 15% 82%;
}

Apply product-field through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.

HookValuesDefaultContract
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.

Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope

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