Astryx

Astryx Field Label

Forms

About

Standalone label group for one control or a caller-labelled group, with optional supporting text, optionality indicators, icon, and tooltip. Astryx by Meta. Source: https://astryx.atmeta.com/components/FieldLabel

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Astryx Field Label to your project and fits it to your theme.

Code

How Astryx Field Label 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-label.tsx. */

import '@/components/ui/astryx-field-label-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 {FieldLabel} from '@/components/ui/astryx-field-label';
import {VStack} from '@astryxdesign/core/Layout';

const LockIcon = (props: React.SVGProps<SVGSVGElement>) => (
  <svg
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    strokeWidth={1.5}
    strokeLinecap="round"
    strokeLinejoin="round"
    {...props}>
    <rect x="3" y="11" width="18" height="11" rx="2" />
    <path d="M7 11V7a5 5 0 0 1 10 0v4" />
  </svg>
);

function OfficialSample() {
  return (
    <VStack gap={4}>
      <FieldLabel label="Email address" inputID="email-input" isRequired />
      <FieldLabel
        label="Phone number"
        inputID="phone-input"
        isOptional
        description="Include country code for international numbers"
      />
      <FieldLabel
        label="API key"
        inputID="api-input"
        labelTooltip="Your API key can be found in the developer settings"
        labelIcon={LockIcon}
      />
      <FieldLabel label="Disabled field" inputID="disabled-input" isDisabled />
    </VStack>
  );
}

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: 280}}>
          <OfficialSample />
        </div>
      </div>
    </Theme>
  );
}

Dependencies

More by Astryx

View all
  • Astryx Banner

    Astryx Banner

    61
  • Astryx Avatar

    Astryx Avatar

    34
  • Astryx Aspect Ratio

    Astryx Aspect Ratio

    32
  • Astryx Badge

    Astryx Badge

    30
  • Astryx Button Group

    Astryx Button Group

    29
  • Astryx Chat Composer Drawer

    Astryx Chat Composer Drawer

    28
  • Astryx Toggle Button

    Astryx Toggle Button

    17
  • Astryx Chat Tokenized Text

    Astryx Chat Tokenized Text

    12

More in Forms

View all
  • Contact Form

    Contact Form

    30
  • Form

    Form

    7
  • Contact Card

    Contact Card

    1.1K
  • Premium Auth

    Premium Auth

    608
  • Book A Demo 1

    Book A Demo 1

    94
  • HeroUI Field Error

    HeroUI Field Error

    13
  • Paper Plane

    Paper Plane

    56
  • Modern & Stunning sign in

    Modern & Stunning sign in

    1.9K