Skip to content
Page

Field

Groups a label, control, hint, and error message.

We never share your email.
import {
Field,
FieldLabel,
FieldHint,
FieldError,
FieldRequired,
} from "@pelagornis/page/components";

The preview above renders this file. Copy it into src/components/ to start from it.

src/components/FieldExample.tsx
import { Field, FieldError, FieldHint, FieldLabel, FieldRequired, Input, Stack } from "@pelagornis/page/components";
export default function FieldDemo() {
return (
<Stack gap="sizeLarge" className="w-full max-w-sm">
<Field>
<FieldLabel htmlFor="field-email">Email address</FieldLabel>
<Input id="field-email" type="email" placeholder="you@example.com" fullWidth />
<FieldHint>We never share your email.</FieldHint>
</Field>
<Field>
<FieldLabel htmlFor="field-password">
Password <FieldRequired />
</FieldLabel>
<Input id="field-password" type="password" error fullWidth />
<FieldError>Password is required.</FieldError>
</Field>
</Stack>
);
}

Field is composed from parts that share React state. Children written in MDX are rendered as separate islands, so the parts can’t reach each other. Put the composition in a .tsx file, like the example above, and import that file instead.

src/content/docs/example.mdx
---
title: Example
---
import FieldExample from "../../components/FieldExample";
<FieldExample client:load />

client:load hydrates the island on page load. Use client:visible for content far down the page.

Markdoc tags render Astro components, and this one needs client state. Wrap the example in an .astro file that hydrates it, then register that file as a tag.

src/components/markdoc/FieldExample.astro
---
import FieldExample from "../FieldExample";
---
<FieldExample client:load />
markdoc.config.mjs
import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";
import starlightMarkdoc from "@astrojs/starlight-markdoc";
import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({
extends: [starlightMarkdoc(), pageMarkdoc()],
tags: {
"field-example": {
render: component("./src/components/markdoc/FieldExample.astro"),
selfClosing: true,
},
},
});
src/content/docs/example.mdoc
{% field-example /%}

Values the component accepts for each variant prop.

PropValues
sizesm md lg

Parts of the component and the data-refineui role each one renders.

PartRole
rootfield
errorfield-error
hintfield-hint