Field
ラベル、コントロール、ヒント、エラーメッセージをまとめます。
We never share your email.
Password is required.
インポート
「インポート」セクションimport { Field, FieldLabel, FieldHint, FieldError, FieldRequired,} from "@pelagornis/page/components";上のプレビューはこのファイルを描画したものです。src/components/ にコピーして使い始めてください。
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> );}MDX で使う
「MDX で使う」セクションField は React の状態を共有する複数のパーツで構成されます。MDX に書いた子要素はそれぞれ別のアイランドとして描画されるため、パーツ同士がつながりません。上の例のように .tsx ファイルで組み立て、そのファイルをインポートしてください。
---title: Example---
import FieldExample from "../../components/FieldExample";
<FieldExample client:load />client:load はページの読み込み時にアイランドをハイドレートします。ページの下の方にあるコンテンツには client:visible を使ってください。
Markdoc で使う
「Markdoc で使う」セクションMarkdoc のタグは Astro コンポーネントを描画しますが、このコンポーネントにはクライアントの状態が必要です。例をハイドレートする .astro ファイルで包み、そのファイルをタグとして登録してください。
---import FieldExample from "../FieldExample";---
<FieldExample client:load />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, }, },});{% field-example /%}バリアント
「バリアント」セクション各 variant prop が受け付ける値です。
| Prop | 値 |
|---|---|
size | sm md lg |
コンポーネントを構成するパーツと、それぞれが描画する data-refineui のロールです。
| パーツ | ロール |
|---|---|
root | field |
error | field-error |
hint | field-hint |
- デザインのガイドとトークンの詳細は RefineUI · Field を参照してください。
- 共通のルールは MDX で使う と Markdoc で使う を参照してください。