Provides guidance for using SmartHR UI FormControl component: attaching labels, help/error messages, and required indicators to single input elements. Includes a11y linting rules.
How this skill is triggered — by the user, by Claude, or both
Slash command
/smarthr-design-system:smarthr-ui-form-controlThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
単一の入力要素にラベル、ヘルプ/エラー/補足のメッセージテキスト、入力必須か否かを紐づけるためのコンポーネントです。1つの入力欄にラベル付けするとき、入力欄にエラーや補足メッセージを表示するときに使います。
単一の入力要素にラベル、ヘルプ/エラー/補足のメッセージテキスト、入力必須か否かを紐づけるためのコンポーネントです。1つの入力欄にラベル付けするとき、入力欄にエラーや補足メッセージを表示するときに使います。
FaCircleExclamationIcon, StatusLabel, Cluster, Text } from 'smarthr-ui'
import { FormControl } from 'smarthr-ui'
| Props 名 | 型 | デフォルト値 | 必須 | 説明 |
|---|---|---|---|---|
| label | ReactNode | { text: ReactNode; styleType?: TextProps; icon?: any; unrecommendedHide?: boolean; htmlFor?: string; id?: string; } | - | ✓ | グループのラベル名 |
| subActionArea | ReactNode | - | - | タイトル右の領域 |
| innerMargin | Gap | - | - | タイトル群と子要素の間の間隔調整用(基本的には不要) |
| statusLabels | FunctionComponentElement | FunctionComponentElement[] | - | - | タイトルの隣に表示する StatusLabel の配列 |
| helpMessage | ReactNode | - | - | タイトルの下に表示するヘルプメッセージ |
| exampleMessage | ReactNode | - | - | タイトルの下に表示する入力例 |
| errorMessages | ReactNode | ReactNode[] | - | - | タイトルの下に表示するエラーメッセージ |
| autoBindErrorInput | boolean | true | - | エラーがある場合に自動的に入力要素を error にするかどうか |
| supplementaryMessage | ReactNode | - | - | フォームコントロールの下に表示する補足メッセージ |
fieldset, Fieldset, FormControl を利用する場合、form要素で囲むことを促すルールです。 このルールはsmarthr/a11y-input-in-form-control と組み合わせることでより厳密なチェックを行えます。
❌ NG:
// formで囲まれていないためNG
const Sample = () => (
<>
<FormControl />
<HogeFieldset />
<fieldset />
</>
)
✅ OK:
// form要素で囲まれているならOK
const Sample1 = () => (
// form要素と推測されるコンポーネントならOK
<StyledForm>
<FormControl />
<HogeFieldset />
<fieldset />
</StyledForm>
)
const Sample2 = () => (
// as, forwardedAsでform要素にされているコンポーネントの場合もOK
<Hoge as="form">
<FormControl />
<HogeFieldset />
<fieldset />
</Hoge>
)
入力要素をsmarthr-ui/FormControl、もしくはsmarthr-ui/Fieldsetで囲むことを促すルールです
❌ NG:
// RadioButton, Checkboxは内部にlabel要素を持つためFormControlで囲むことは不適切
// 見出しを設定したい場合、Fieldsetでグルーピングする
<FormControl title="any heading">
<RadioButton>{a.label}</RadioButton>
</FormControl>
// FormControlが複数の入力要素を持ってしまっているのでNG
<FormControl title="any heading">
<Input />
<Combobox />
</FormControl>
// FormControlがネストしてしまっているのでNG
<FormControl>
<SubFormControl>
<Checkbox />
</SubFormControl>
</FormControl>
✅ OK:
<FormControl title="any heading">
<Input />
</FormControl>
<Fieldset title="date range">
<FormControl label={{ text: "start", unrecommendedHide: true }}>
<WarekiPicker />
</FormControl>
~
<FormControl label={{ text: "end", unrecommendedHide: true }}>
<WarekiPicker />
</FormControl>
</Fieldset>
詳細は eslint-plugin-smarthr の各ルール README を参照してください。
placeholder の代替として、入力例は exampleMessage を使用するerror 状態を付加するdisabled を使用する
readOnly を使用するnpx claudepluginhub kufu/smarthr-design-system --plugin smarthr-design-systemProvides context and usage rules for the smarthr-ui Fieldset component, which groups related form inputs under a heading with accessibility enforcement.
Builds accessible forms with proper labeling, grouped controls, inline validation (aria-describedby/aria-errormessage), and error summaries linked to inputs.
Designs form labels, instructions, and grouping for screen reader and cognitive accessibility. Use when creating or reviewing forms, input fields, checkboxes, radio buttons, select menus, or any data entry interface.