project-form-patterns
暂无简介
- License 许可
- MIT
- 所属仓库
- AkaraChen/aghub
- 最近更新
- 2026-11-10
- Stars
- ★ 271
- Forks
- 19
03 SKILL.md 正文
aghub Form Patterns
Follow these rules when building forms in this project.
Source of Truth
- Check the official docs first, not memory and not bundled/local docs, when form behavior is in question.
- For HeroUI, prefer the official site:
https://v3.heroui.com/docs/react/components/formhttps://v3.heroui.com/docs/react/components/text-fieldhttps://v3.heroui.com/docs/react/components/field-errorhttps://v3.heroui.com/docs/react/components/select
- Use local skill docs only as a convenience after confirming the official API.
Default Stack
- Prefer
react-hook-formfor non-trivial forms. - Use
Controllerfor HeroUISelectand any custom controlled widgets. - Keep one form state. Do not create a second derived validation state unless there is a concrete need the form library cannot express.
Validation Behavior
- When RHF controls validation, set HeroUI form fields to
validationBehavior="aria". - Do not rely on HeroUI/native validation defaults together with RHF. Native validation can steal focus and submission flow while bypassing the error UI you expect from RHF.
- Let RHF own validation rules and submission blocking.
Error Rendering
- For HeroUI text fields, use:
isInvalid={Boolean(fieldState.error)}- Conditionally render
<FieldError>{fieldState.error.message}</FieldError>inside the sameTextField.
- Do not invent unsupported props. In particular, do not assume
TextFieldsupports anerrorMessageprop. - Keep the official anatomy:
<TextField isInvalid={Boolean(fieldState.error)} validationBehavior="aria">
<Label>Name</Label>
<Input {...inputProps} />
{fieldState.error && <FieldError>{fieldState.error.message}</FieldError>}
</TextField>
- For non-form or custom composite controls, prefer HeroUI
ErrorMessageinstead of hand-rolled error text. - Use
ErrorMessagefor collection-style or custom editors that are not true form fields, including key/value editors, tag selectors, and similar composite controls.
Custom Editors
- Custom widgets like
AgentSelector,EnvEditor,HttpHeaderEditor, andKeyPairEditorshould still be registered in RHF throughController. - For custom editors that manage arrays or compound values, compute validation from the current field value and surface one aggregated error below the editor when possible.
- For that aggregated error, prefer HeroUI
ErrorMessage. - Do not inject per-row error UI into tight horizontal layouts unless the design explicitly calls for it.
Key/Value Editors
- Keep row layout simple:
- two inputs
- one delete button
- no extra wrappers that change flex behavior unless necessary
- Prefer aggregate error text below the whole editor over inline row errors. This avoids breaking spacing and alignment.
- Implement that aggregate error with HeroUI
ErrorMessage, not a custom<p>block. - If you must show row-level issues, redesign the layout first; do not bolt error blocks into a row that was designed as a single-line control.
Practical Rules
- Prefer
onPressfor HeroUI buttons. - Use
type="button"for non-submit buttons inside forms. - Preserve existing visual patterns in this repo; do not restyle forms while adding validation.
- After form changes, run
bun run buildincrates/desktopwhen possible and separate unrelated existing build failures from the changes you made.
Anti-Patterns
- Do not mix RHF validation with a parallel
validationErrorsstate for the same fields. - Do not depend on HeroUI default native validation when you expect RHF errors to drive the UI.
- Do not push validation messages into each key/value row unless you intentionally redesign that editor.
- Do not trust remembered HeroUI APIs for forms without checking the official site first.
04 同仓库更多 Skills
vercel-react-best-practices
Vercel React Best Practices
init-deep
Generate hierarchical AGENTS.md and ensure paired CLAUDE.md files for codebases. Creates root AGENTS.md + CLAUDE.md plus complexity-scored subdirectory files. Use when user asks to "generate AGENTS.md files", "create codebase knowledge base", "run /init-deep", or wants comprehensive project documentation. Supports update mode (default) and --create-new flag to regenerate from scratch.
typeset
Improves typography by fixing font choices, hierarchy, sizing, weight, and readability so text feels intentional. Use when the user mentions fonts, type, readability, text hierarchy, sizing looks off, or wants more polished, intentional typography.
teach-impeccable
One-time setup that gathers design context for your project and saves it to your AI config file. Run once to establish persistent design guidelines.
quieter
Tones down visually aggressive or overstimulating designs, reducing intensity while preserving quality. Use when the user mentions too bold, too loud, overwhelming, aggressive, garish, or wants a calmer, more refined aesthetic.
polish
Performs a final quality pass fixing alignment, spacing, consistency, and micro-detail issues before shipping. Use when the user mentions polish, finishing touches, pre-launch review, something looks off, or wants to go from good to great.