About
Low-level form field wrapper for custom controls that need a label, description, and optional/required indicators. Astryx by Meta. Source: https://astryx.atmeta.com/components/Field
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Astryx Field to your project and fits it to your theme.
Code
How Astryx Field is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
'use client';
/* Copyright (c) 2026 Meta Platforms, Inc. See the MIT notice in astryx-field.tsx. */
import '@/components/ui/astryx-field-utils/astryx-preview.css';
import '@astryxdesign/theme-neutral/fonts.css';
import {useSyncExternalStore} from 'react';
import {Theme} from '@astryxdesign/core/theme';
import {neutralTheme} from '@astryxdesign/theme-neutral/built';
import {useState} from 'react';
import {Field} from '@/components/ui/astryx-field';
import {TextInput} from '@astryxdesign/core/TextInput';
import {Stack} from '@astryxdesign/core/Layout';
function OfficialSample() {
const [email, setEmail] = useState('');
const status =
email.length > 0 && !email.includes('@')
? {type: 'error' as const, message: 'Enter a valid email address.'}
: undefined;
return (
<Stack direction="vertical" gap={3} style={{width: 320}}>
<Field
label="Email"
inputID="field-email"
description="We will never share your email."
isRequired
status={status}>
<TextInput
label="Email"
isLabelHidden
value={email}
onChange={setEmail}
placeholder="you@example.com"
/>
</Field>
</Stack>
);
}
function readPreviewMode() {
const {classList} = document.documentElement;
return classList.contains('dark') ? 'dark' : 'light';
}
function subscribeToPreviewMode(callback: () => void) {
const observer = new MutationObserver(callback);
observer.observe(document.documentElement, {attributes: true, attributeFilter: ['class']});
return () => observer.disconnect();
}
export default function Demo() {
const mode = useSyncExternalStore(subscribeToPreviewMode, readPreviewMode, () => 'light' as const);
return (
<Theme theme={neutralTheme} mode={mode}>
<div className="astryx-demo">
<div className="astryx-demo-content" data-centered style={{maxWidth: 320}}>
<OfficialSample />
</div>
</div>
</Theme>
);
}















