Emit static fallback tokens for forced-colors mode
Map semantic border and focus-ring variables to system color keywords when Windows High Contrast is active.
Label, control, helper text, and error slots with vertical and horizontal orientations.
We never share your email.
12345678910111213141516171819import { Field } from "#components/ui/ui-sdk/field.tsx";import { Input } from "#components/ui/ui-sdk/input.tsx";
export function Example() { return ( // UI SDK controls (Input, Textarea, Select, Checkbox...) wire themselves // to the field; every part gets data-invalid / data-required / // data-disabled. Error shows once a submit finds the control invalid. <Field.Root orientation="vertical"> <Field.Label> Email <Field.RequiredIndicator /> </Field.Label> <Input required type="email" placeholder="you@company.com" /> <Field.Description>We never share your email.</Field.Description> <Field.Error /> </Field.Root> );}We never share your email.
We never share your email.
1npx stylexblocks add field123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159import * as stylex from "@stylexjs/stylex";import { Field as UiSdkField, FieldControl as UiSdkFieldControl, FieldDescription as UiSdkFieldDescription, FieldError as UiSdkFieldError, FieldLabel as UiSdkFieldLabel,} from "@ui-sdk/react/field";import { createSlotRecipeContext } from "#lib/ui-sdk/create-slot-recipe-context.tsx";import { defineSlotRecipe } from "#lib/recipe-props.ts";import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'import { fontWeights } from '@stylexblocks/ui/tokens/font-weights.stylex.ts'import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'
const fieldRequiredIndicator = stylex.create({ base: { color: semanticColors.fgError, lineHeight: 1, },})
const fieldRoot = stylex.create({ base: { display: 'flex', width: '100%', position: 'relative', gap: spacing._1_5, },})
const fieldRootOrientations = stylex.create({ vertical: { flexDirection: 'column', alignItems: 'flex-start', }, horizontal: { display: 'grid', gridTemplateColumns: 'var(--field-label-width, 8rem) 1fr', alignItems: 'center', },})
const fieldLabel = stylex.create({ base: { display: 'flex', alignItems: 'center', textAlign: 'start', fontSize: fontSizes.sm, lineHeight: lineHeights.sm, fontWeight: fontWeights.medium, gap: spacing._1, userSelect: 'none', opacity: { default: null, ':is(:disabled, [disabled], [data-disabled])': 0.5, }, },})
const fieldErrorText = stylex.create({ base: { display: 'inline-flex', alignItems: 'center', fontWeight: fontWeights.medium, gap: spacing._1, color: semanticColors.fgError, fontSize: fontSizes.xs, lineHeight: lineHeights.xs, },})
const fieldErrorTextOrientations = stylex.create({ horizontal: { gridColumn: 2, },})
const fieldHelperText = stylex.create({ base: { color: semanticColors.fgMuted, fontSize: fontSizes.xs, lineHeight: lineHeights.xs, },})
const fieldHelperTextOrientations = stylex.create({ horizontal: { gridColumn: 2, },})
export type FieldOrientation = keyof typeof fieldRootOrientations
const fieldRecipe = defineSlotRecipe({ slots: { requiredIndicator: { styles: fieldRequiredIndicator }, root: { styles: fieldRoot, orientations: fieldRootOrientations }, label: { styles: fieldLabel }, errorText: { styles: fieldErrorText, orientations: fieldErrorTextOrientations }, helperText: { styles: fieldHelperText, orientations: fieldHelperTextOrientations }, }, defaultVariants: { orientation: "vertical" },});
function RequiredIndicatorNode({ children, ...props }: React.ComponentProps<"span">) { return <span {...props}>{children ?? "*"}</span>;}
const { withProvider, withContext } = createSlotRecipeContext(fieldRecipe);
const StyledRoot = withProvider(UiSdkField, "root", "FieldRoot");
function Root( props: React.ComponentProps<typeof StyledRoot> & { /** Marks the field as required (stamps `data-required` on the root for cross-engine parity). */ required?: boolean; },) { const { required, ...rest } = props; return ( <StyledRoot {...rest} {...(required ? { "data-required": "" } : undefined)} /> );}Root.displayName = "FieldRoot";
/** * Field — UI SDK's field (label/control wiring, browser validation surfaced * as `data-invalid` / `data-valid` on every part, `data-required`, * `data-focused`, `data-disabled`) wearing the field slot recipe. * `<Field.Root orientation>` resolves the recipe once and every part * inherits it through context. Any UI SDK control (Input, Textarea, Select, * Checkbox...) placed inside wires itself to the field; `Field.Control` is * for anything else, like a native `<select>` via `render`. */export const Field = { Root, Label: withContext(UiSdkFieldLabel, "label", "FieldLabel"), RequiredIndicator: withContext( RequiredIndicatorNode, "requiredIndicator", "FieldRequiredIndicator", ), Control: UiSdkFieldControl, Description: withContext(UiSdkFieldDescription, "helperText", "FieldDescription"), Error: withContext(UiSdkFieldError, "errorText", "FieldError"),};
export type FieldRootProps = React.ComponentProps<typeof Field.Root>;export type FieldLabelProps = React.ComponentProps<typeof Field.Label>;export type FieldRequiredIndicatorProps = React.ComponentProps<typeof Field.RequiredIndicator>;export type FieldControlProps = React.ComponentProps<typeof UiSdkFieldControl>;export type FieldDescriptionProps = React.ComponentProps<typeof Field.Description>;export type FieldErrorProps = React.ComponentProps<typeof Field.Error>;
Installable blocks built with Field — real use cases, delivered as source you own.
Minimal, zero-chrome centered credential sign-in form resting directly on the canvas with inline validation, password visibility toggle, inline forgot-password feedback, remember-me persistence, and toast confirmation.
Two-column storefront checkout with express wallets, shipping and billing address fields, selectable delivery cards, auto-formatted card entry with network detection, promo code discounts, gift notes, inline validation, and a sticky collapsible order summary.
Four-step two-column checkout flow with live cart quantities and promo codes, country-aware shipping validation, delivery method selection, payment review, sticky order summary, and local order confirmation.
Studio project inquiry form with response-time status, three value-proposition cards, validated contact and scope fields, multi-select topic toggles, team-size and budget selects, referral attribution, and a structured submission confirmation view.
Responsive two-column vendor onboarding and payout profile form with sectioned Fieldset cards, paired field grids, live inline validation, dirty-state tracking, settlement cadence controls, Reset and Save footer actions, and Toaster confirmation feedback.
Four-step cloud workspace onboarding wizard with a pinned horizontal stepper, per-step validation on advance, plan tier radio cards, live monthly cost estimate, optional skippable team setup, editable review cards, and local launch confirmation.
Three-step scheduled backup policy wizard inside a modal Dialog over a live Arbor Cloud workspace. Features a pinned title and compact stepper header, scrollable per-step validation for target cluster, region, cadence, retention, replication, and KMS encryption, a pinned Back/Continue/Create footer, and live host table updates with toast confirmation.
Single-column accordion-style inline wizard for custom domain and TLS provisioning, featuring compact summary rows with inline Edit/Re-run actions, downstream stale invalidation, a self-running nested DNS preflight check stepper with mismatch simulation and retry recovery, and live cutover activation.
Five-step enterprise SSO and workspace provisioning wizard with a persistent vertical stepper rail, live per-step statuses and summary subtitles, overall progress indicator, draft save tracking, conditional protocol and SIEM fields, broken-step validation flagging, container-responsive top bar collapse, and grouped review and confirmation screens.
Interactive four-lane sprint board with pointer drag-and-drop, keyboard and menu column movement, search and priority/assignee filters, quick-add task dialog, task detail drawer, and toast feedback.
Centered workspace sign-in card with inline field validation, password visibility toggle, remember-device persistence, Google, GitHub, and passkey provider buttons, and toast feedback.
Split-screen sign-in card pairing an interactive authentication form with validation, password visibility toggle, remember-me control, and social/SAML SSO actions beside an atmospheric architectural brand showcase.
Enterprise single sign-on flow with work-email domain lookup, SAML 2.0 and OIDC identity provider confirmation (Okta, Microsoft Entra ID, Google Workspace), password fallback with inline validation, and toast feedback.
Account and workspace preferences page with quick-jump settings search, responsive sidebar-to-tabs navigation, profile details, timezone and appearance controls, notification switches, password and security options, dirty-state detection, and Save / Reset actions.
Multi-section workspace settings layout with grouped sidebar navigation, responsive mobile tabs, a sticky dirty-state save bar, API token management, session controls, and team billing quotas.
Focused Cinder Cloud API keys and service tokens table with environment segment filter, status select, live search, sortable column headers, multi-row selection with a contextual floating ActionBar, per-row overflow menus, create-token dialog, destructive confirmation AlertDialog, pagination, and empty state.