Field
Groups labels, controls, descriptions, and errors.
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.
View Field code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
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>import {
Button,
Field,
Input,
Label
} from '@santi020k/lumen-react'
export const Example = () => (
<>
<form data-ui-form data-ex-validated-form style={{ "display": "grid", "gap": "1rem", "maxWidth": "26rem" }}>
<Field>
<Label htmlFor="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 htmlFor="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 htmlFor="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 type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<form data-ui-form data-ex-validated-form style="display: grid; gap: 1rem; max-width: 26rem;">
<lumen-field>
<lumen-label for="ex-email">Email</lumen-label>
<lumen-input
data-error-required="Add an email address."
id="ex-email"
name="email"
placeholder="[email protected]"
required
type="email"></lumen-input>
<p data-ui-field-hint>We only use this for release notes.</p>
<p data-ui-field-error hidden></p>
</lumen-field>
<lumen-field>
<lumen-label for="ex-workspace">Workspace slug</lumen-label>
<lumen-input
data-error-pattern="Use lowercase letters, numbers, and hyphens only."
id="ex-workspace"
name="workspace"
pattern="[a-z0-9-]+"
placeholder="lumen-team"
required></lumen-input>
<p data-ui-field-hint>Lowercase letters, numbers, and hyphens.</p>
<p data-ui-field-error hidden></p>
</lumen-field>
<lumen-field>
<lumen-label for="ex-invite">Invite code</lumen-label>
<lumen-input
data-error-custom="Use LUMEN-2026 for the preview."
id="ex-invite"
name="inviteCode"
placeholder="LUMEN-2026"
required></lumen-input>
<p data-ui-field-hint>Preview access is limited to approved invites.</p>
<p data-ui-field-error hidden></p>
</lumen-field>
<lumen-button type="submit">Request access</lumen-button>
<p data-ex-form-status aria-live="polite" style="margin: 0;"></p>
</form>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.
pnpm add @santi020k/lumen-astropnpm add @santi020k/lumen-astrolumen add Fieldlumen add Fieldpnpm add @santi020k/lumen-reactpnpm add @santi020k/lumen-reactlumen add Field --target reactlumen add Field --target reactpnpm add @santi020k/lumen-elementspnpm add @santi020k/lumen-elementslumen add Field --target elementslumen add Field --target elementsGlass
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.
View Field code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
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-react'
export const Example = () => (
<>
<div className="docs-glass-demo" style={{ "justifyItems": "center" }}>
<Field glass style={{ "minWidth": "min(100%, 22rem)", "padding": "1.25rem", "borderRadius": "0.75rem" }}>
<Label htmlFor="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>
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<div class="docs-glass-demo" style="justify-items: center;">
<lumen-field glass style="min-width: min(100%, 22rem); padding: 1.25rem; border-radius: 0.75rem;">
<lumen-label for="glass-workspace">Workspace</lumen-label>
<lumen-input id="glass-workspace" placeholder="Lumen Labs"></lumen-input>
<p>Inputs inside a glass field pick up translucent chrome automatically.</p>
<lumen-button size="sm">Save</lumen-button>
</lumen-field>
</div>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.
| Attribute | Values | Default | Description |
|---|---|---|---|
| glass | boolean | "subtle" | "strong" | false | Applies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity. |
| controlId | string | - | Connects the field to a control elsewhere in the field root. |
| describedBy | space-separated ids | - | Adds ids to the control aria-describedby value. |
| data-ui-form | boolean attribute | - | Opts a form into native Constraint Validation API enhancement. |
| data-error-required, data-error-pattern, data-error-min, data-error-max, data-error-custom | string | - | Overrides browser validationMessage text for matching constraints. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML 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.
| Event | Target | Detail | When |
|---|---|---|---|
| ui:validate | Form ([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:invalid | Form ([data-ui-form]) | { control?: HTMLElement, controls?: HTMLElement[], form: HTMLFormElement } | Fires after blur or submit validation finds one or more invalid controls. |
| ui:valid | Form ([data-ui-form]) | { control?: HTMLElement, controls?: HTMLElement[], form: HTMLFormElement } | Fires after blur or submit validation finds the checked control or form valid. |