Fieldset
関連する入力に共通の見出しと無効状態を与えるグループ。 FieldsetLegend でグループの目的を説明し、各入力のラベルも維持します。
@neumorphism-ui/fieldsetプレビュー
インストール
インストール: fieldset
npx shadcn@latest add @neumorphism-ui/fieldsetCLI が npm 依存関係、base token、utils、コンポーネントソースを順番に処理します。
この Registry を初めて使う場合は、先に namespace の設定 を完了してください。
使い方
使い方: インストール
npx shadcn@latest add @neumorphism-ui/field @neumorphism-ui/fieldsetImport
Fieldset の import コード
"use client";
import * as React from "react";
import { Field, FieldLabel, FieldControl, FieldDescription, FieldError } from "@/components/ui/field";
import { Fieldset, FieldsetLegend } from "@/components/ui/fieldset";Example
Fieldset の使用コード
export default function Example() {
const [name, setName] = React.useState("Alex");
const nameField = <Field name="displayName"><FieldLabel>{"表示名"}</FieldLabel><FieldControl required value={name} onValueChange={setName} /><FieldDescription>{"プロフィールに表示する名前を入力してください。"}</FieldDescription><FieldError match="valueMissing">{"名前を入力してください。"}</FieldError></Field>;
return (<Fieldset className="w-full max-w-sm"><FieldsetLegend>{"プロフィール設定"}</FieldsetLegend>{nameField}</Fieldset>);
}API リファレンス
| コンポーネント | プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|---|
Fieldset | disabled | boolean | — | ユーザー操作を無効にします。 |
FieldsetLegend | children | React.ReactNode | — | 関連するフィールド群の見出しです。 |
Fieldset | className | string | function | — | 状態関数も使ってスタイルを拡張します。 |
アクセシビリティ
- 01
FieldsetLegend でグループの目的を説明し、各入力のラベルも維持します。
- 02
render や className を変更する際もラベルと可視フォーカスを保ちます。