EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Field·component·@astryxdesign/core

Field Label

Standalone label component with optional/required indicators and tooltip support.

Open in Playground @astryxdesign/core/Field

Showcases and examples

2 documented examples

Field Label

Standalone field labels demonstrating required, optional, tooltip, and icon variations.

Preview loads on approachPreview loads on approach
Exact source · field-label-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {FieldLabel} from '@astryxdesign/core/Field';
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>
);

export default function FieldLabelShowcase() {
  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>
  );
}

Usage

Standalone label component with optional/required indicators and tooltip support.

Typed props

PropType and behavior
labelstring · required
Label text.
inputIDstring · required
ID of the input this label is for.
isLabelHiddenboolean · default false
Visually hide the label.
isDisabledboolean · default false
Whether the associated input is disabled.
isOptionalboolean · default false
Show "Optional" indicator.
isRequiredboolean · default false
Show "Required" indicator.
labelIconIconType
Icon before the label text. See astryx docs icons for valid semantic names.
labelTooltipstring
Tooltip text for info icon at end of label.