skillfullstack 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (775) hide show
  1. package/.skillsRegistry/catalog.json +231 -0
  2. package/AGENTS.md +89 -0
  3. package/README.md +210 -2
  4. package/bin/index.js +508 -0
  5. package/package.json +57 -4
  6. package/skills/backend/apiEngineering/SKILL.md +102 -0
  7. package/skills/backend/apiEngineering/evals/evalApiEngineering.py +81 -0
  8. package/skills/backend/apiEngineering/evals/fixtures/invalid/sampleInvalidOpenApi.json +40 -0
  9. package/skills/backend/apiEngineering/evals/fixtures/valid/sampleValidOpenApi.json +47 -0
  10. package/skills/backend/apiEngineering/policies/compatibility.md +42 -0
  11. package/skills/backend/apiEngineering/policies/mandatory.md +48 -0
  12. package/skills/backend/apiEngineering/policies/performance.md +39 -0
  13. package/skills/backend/apiEngineering/policies/security.md +36 -0
  14. package/skills/backend/apiEngineering/references/apiObservability.md +39 -0
  15. package/skills/backend/apiEngineering/references/apiReference.md +3 -0
  16. package/skills/backend/apiEngineering/references/apiSecurityOwasp.md +47 -0
  17. package/skills/backend/apiEngineering/references/contractCompatibility.md +26 -0
  18. package/skills/backend/apiEngineering/references/databaseTransactions.md +40 -0
  19. package/skills/backend/apiEngineering/references/distributedReliability.md +26 -0
  20. package/skills/backend/apiEngineering/references/multiTenancy.md +27 -0
  21. package/skills/backend/apiEngineering/references/openApi32Standards.md +58 -0
  22. package/skills/backend/apiEngineering/references/paginationVersioning.md +57 -0
  23. package/skills/backend/apiEngineering/references/responseStandards.md +94 -0
  24. package/skills/backend/apiEngineering/scripts/auditApiContract.py +123 -0
  25. package/skills/backend/apiEngineering/scripts/checkBreakingChanges.py +77 -0
  26. package/skills/backend/apiEngineering/scripts/generateResponseEnvelope.py +88 -0
  27. package/skills/backend/apiEngineering/templates/apiChecklist.md +27 -0
  28. package/skills/backend/apiEngineering/templates/openapi.yaml +125 -0
  29. package/skills/backend/apiEngineering/templates/problemDetails.json +44 -0
  30. package/skills/backend/databaseArchitecture/SKILL.md +118 -0
  31. package/skills/backend/databaseArchitecture/evals/evalDatabaseArchitecture.py +85 -0
  32. package/skills/backend/databaseArchitecture/evals/fixtures/dangerousMigration.sql +4 -0
  33. package/skills/backend/databaseArchitecture/evals/fixtures/invalidSchema.sql +23 -0
  34. package/skills/backend/databaseArchitecture/evals/fixtures/safeMigration.sql +3 -0
  35. package/skills/backend/databaseArchitecture/evals/fixtures/validSchema.sql +37 -0
  36. package/skills/backend/databaseArchitecture/policies/integrity.md +25 -0
  37. package/skills/backend/databaseArchitecture/policies/mandatory.md +32 -0
  38. package/skills/backend/databaseArchitecture/policies/migration.md +22 -0
  39. package/skills/backend/databaseArchitecture/policies/normalization.md +25 -0
  40. package/skills/backend/databaseArchitecture/policies/performance.md +26 -0
  41. package/skills/backend/databaseArchitecture/policies/recovery.md +23 -0
  42. package/skills/backend/databaseArchitecture/policies/security.md +26 -0
  43. package/skills/backend/databaseArchitecture/policies/tableCreationChecklist.md +70 -0
  44. package/skills/backend/databaseArchitecture/references/analyticsWarehousing.md +32 -0
  45. package/skills/backend/databaseArchitecture/references/apiReference.md +3 -0
  46. package/skills/backend/databaseArchitecture/references/backupDisasterRecovery.md +27 -0
  47. package/skills/backend/databaseArchitecture/references/dataModelingLifecycle.md +30 -0
  48. package/skills/backend/databaseArchitecture/references/databaseTaxonomy.md +32 -0
  49. package/skills/backend/databaseArchitecture/references/indexingOptimization.md +32 -0
  50. package/skills/backend/databaseArchitecture/references/normalizationTheory.md +61 -0
  51. package/skills/backend/databaseArchitecture/references/scalabilitySharding.md +37 -0
  52. package/skills/backend/databaseArchitecture/references/transactionConcurrency.md +39 -0
  53. package/skills/backend/databaseArchitecture/scripts/analyzeMigration.py +99 -0
  54. package/skills/backend/databaseArchitecture/scripts/auditDatabaseSchema.py +177 -0
  55. package/skills/backend/databaseArchitecture/scripts/inspectDatabaseIndexes.py +149 -0
  56. package/skills/backend/databaseArchitecture/templates/adrTemplate.md +32 -0
  57. package/skills/backend/databaseArchitecture/templates/databaseChecklist.md +29 -0
  58. package/skills/backend/databaseArchitecture/templates/migrationPlan.md +40 -0
  59. package/skills/backend/durableBackgroundJobs/SKILL.md +112 -0
  60. package/skills/backend/durableBackgroundJobs/evals/durableJobVerification.json +14 -0
  61. package/skills/backend/durableBackgroundJobs/references/apiReference.md +3 -0
  62. package/skills/backend/durableBackgroundJobs/references/durableStepPatterns.md +6 -0
  63. package/skills/backend/durableBackgroundJobs/references/idempotencyKeys.md +5 -0
  64. package/skills/backend/durableBackgroundJobs/scripts/testWorkflowDispatch.py +24 -0
  65. package/skills/backend/golangStandard/SKILL.md +155 -0
  66. package/skills/backend/golangStandard/evals/goVerification.json +14 -0
  67. package/skills/backend/golangStandard/references/apiReference.md +3 -0
  68. package/skills/backend/golangStandard/references/layoutGuide.md +26 -0
  69. package/skills/backend/golangStandard/references/slogPatterns.md +26 -0
  70. package/skills/backend/golangStandard/scripts/scaffoldGoModule.py +105 -0
  71. package/skills/backend/pythonStandard/SKILL.md +138 -0
  72. package/skills/backend/pythonStandard/evals/pythonVerification.json +14 -0
  73. package/skills/backend/pythonStandard/references/apiReference.md +3 -0
  74. package/skills/backend/pythonStandard/references/pydanticPatterns.md +16 -0
  75. package/skills/backend/pythonStandard/references/pyprojectSpecs.md +37 -0
  76. package/skills/backend/pythonStandard/scripts/scaffoldUvProject.py +79 -0
  77. package/skills/backend/upstash/SKILL.md +98 -0
  78. package/skills/backend/upstash/evals/upstashVerification.json +14 -0
  79. package/skills/backend/upstash/references/apiReference.md +3 -0
  80. package/skills/backend/upstash/references/qstashFlowControl.md +34 -0
  81. package/skills/backend/upstash/references/ratelimitPatterns.md +53 -0
  82. package/skills/backend/upstash/references/workflowPatterns.md +35 -0
  83. package/skills/backend/upstash/scripts/testRedisConnection.py +36 -0
  84. package/skills/cicdDevops/cicdPipeline/SKILL.md +148 -0
  85. package/skills/cicdDevops/cicdPipeline/evals/evalCicd.py +37 -0
  86. package/skills/cicdDevops/cicdPipeline/references/apiReference.md +3 -0
  87. package/skills/cicdDevops/cicdPipeline/references/cicdDeploymentPatterns.md +27 -0
  88. package/skills/cicdDevops/cicdPipeline/scripts/auditDockerfileSecurity.py +56 -0
  89. package/skills/dataAi/mcpServerDevelopment/SKILL.md +123 -0
  90. package/skills/dataAi/mcpServerDevelopment/evals/mcpVerification.json +14 -0
  91. package/skills/dataAi/mcpServerDevelopment/references/apiReference.md +3 -0
  92. package/skills/dataAi/mcpServerDevelopment/references/mcpClientConfigs.md +38 -0
  93. package/skills/dataAi/mcpServerDevelopment/references/toolSchemaDesign.md +6 -0
  94. package/skills/dataAi/mcpServerDevelopment/scripts/runFastMcpBoilerplate.py +36 -0
  95. package/skills/dataAi/ragPipelineProduction/SKILL.md +113 -0
  96. package/skills/dataAi/ragPipelineProduction/evals/ragVerification.json +14 -0
  97. package/skills/dataAi/ragPipelineProduction/references/apiReference.md +3 -0
  98. package/skills/dataAi/ragPipelineProduction/references/chunkingStrategies.md +10 -0
  99. package/skills/dataAi/ragPipelineProduction/references/rrfAlgorithm.md +13 -0
  100. package/skills/dataAi/ragPipelineProduction/scripts/runHybridRrfSearch.py +33 -0
  101. package/skills/devopsCloud/cloudflare/SKILL.md +282 -0
  102. package/skills/devopsCloud/cloudflare/assets/README.md +48 -0
  103. package/skills/devopsCloud/cloudflare/assets/ai/agents-sdk.md +118 -0
  104. package/skills/devopsCloud/cloudflare/assets/ai/ai-gateway.md +105 -0
  105. package/skills/devopsCloud/cloudflare/assets/ai/ai-search.md +129 -0
  106. package/skills/devopsCloud/cloudflare/assets/ai/workers-ai.md +127 -0
  107. package/skills/devopsCloud/cloudflare/assets/cli/c3.md +292 -0
  108. package/skills/devopsCloud/cloudflare/assets/cli/cf-cli.md +90 -0
  109. package/skills/devopsCloud/cloudflare/assets/cli/wrangler.md +43 -0
  110. package/skills/devopsCloud/cloudflare/assets/compute/cron-triggers.md +486 -0
  111. package/skills/devopsCloud/cloudflare/assets/compute/service-bindings.md +251 -0
  112. package/skills/devopsCloud/cloudflare/assets/compute/smart-placement.md +435 -0
  113. package/skills/devopsCloud/cloudflare/assets/compute/static-assets.md +220 -0
  114. package/skills/devopsCloud/cloudflare/assets/compute/workers.md +129 -0
  115. package/skills/devopsCloud/cloudflare/assets/database-storage/d1.md +105 -0
  116. package/skills/devopsCloud/cloudflare/assets/database-storage/durable-objects.md +122 -0
  117. package/skills/devopsCloud/cloudflare/assets/database-storage/hyperdrive.md +210 -0
  118. package/skills/devopsCloud/cloudflare/assets/database-storage/kv.md +198 -0
  119. package/skills/devopsCloud/cloudflare/assets/database-storage/queues.md +105 -0
  120. package/skills/devopsCloud/cloudflare/assets/database-storage/r2.md +105 -0
  121. package/skills/devopsCloud/cloudflare/assets/database-storage/vectorize.md +97 -0
  122. package/skills/devopsCloud/cloudflare/assets/database-storage/workflows.md +141 -0
  123. package/skills/devopsCloud/cloudflare/assets/llms.txt +143 -0
  124. package/skills/devopsCloud/cloudflare/assets/networking-security/cache-cdn.md +109 -0
  125. package/skills/devopsCloud/cloudflare/assets/networking-security/dns.md +71 -0
  126. package/skills/devopsCloud/cloudflare/assets/networking-security/rate-limiting.md +130 -0
  127. package/skills/devopsCloud/cloudflare/assets/networking-security/tunnels.md +57 -0
  128. package/skills/devopsCloud/cloudflare/assets/networking-security/waf.md +143 -0
  129. package/skills/devopsCloud/cloudflare/assets/troubleshooting/1xxx-errors.md +209 -0
  130. package/skills/devopsCloud/cloudflare/assets/troubleshooting/5xx-errors.md +111 -0
  131. package/skills/devopsCloud/cloudflare/assets/troubleshooting/http-status-codes.md +38 -0
  132. package/skills/devopsCloud/cloudflare/evals/evals.json +75 -0
  133. package/skills/devopsCloud/cloudflare/references/ai-gateway/README.md +27 -0
  134. package/skills/devopsCloud/cloudflare/references/ai-gateway/configuration.md +18 -0
  135. package/skills/devopsCloud/cloudflare/references/ai-gateway/dynamic-routing.md +15 -0
  136. package/skills/devopsCloud/cloudflare/references/ai-gateway/features.md +22 -0
  137. package/skills/devopsCloud/cloudflare/references/ai-gateway/sdk-integration.md +19 -0
  138. package/skills/devopsCloud/cloudflare/references/ai-gateway/troubleshooting.md +16 -0
  139. package/skills/devopsCloud/cloudflare/references/ai-search/README.md +25 -0
  140. package/skills/devopsCloud/cloudflare/references/ai-search/api.md +13 -0
  141. package/skills/devopsCloud/cloudflare/references/ai-search/configuration.md +16 -0
  142. package/skills/devopsCloud/cloudflare/references/ai-search/gotchas.md +13 -0
  143. package/skills/devopsCloud/cloudflare/references/ai-search/patterns.md +15 -0
  144. package/skills/devopsCloud/cloudflare/references/bindings/README.md +16 -0
  145. package/skills/devopsCloud/cloudflare/references/bindings/api.md +19 -0
  146. package/skills/devopsCloud/cloudflare/references/bindings/configuration.md +20 -0
  147. package/skills/devopsCloud/cloudflare/references/bindings/gotchas.md +18 -0
  148. package/skills/devopsCloud/cloudflare/references/bindings/patterns.md +20 -0
  149. package/skills/devopsCloud/cloudflare/references/browser-rendering/README.md +18 -0
  150. package/skills/devopsCloud/cloudflare/references/browser-rendering/api.md +12 -0
  151. package/skills/devopsCloud/cloudflare/references/browser-rendering/configuration.md +12 -0
  152. package/skills/devopsCloud/cloudflare/references/browser-rendering/gotchas.md +15 -0
  153. package/skills/devopsCloud/cloudflare/references/browser-rendering/patterns.md +12 -0
  154. package/skills/devopsCloud/cloudflare/references/cliComparison.md +93 -0
  155. package/skills/devopsCloud/cloudflare/references/containers/README.md +23 -0
  156. package/skills/devopsCloud/cloudflare/references/containers/api.md +13 -0
  157. package/skills/devopsCloud/cloudflare/references/containers/configuration.md +15 -0
  158. package/skills/devopsCloud/cloudflare/references/containers/gotchas.md +16 -0
  159. package/skills/devopsCloud/cloudflare/references/containers/patterns.md +18 -0
  160. package/skills/devopsCloud/cloudflare/references/cron-triggers/README.md +20 -0
  161. package/skills/devopsCloud/cloudflare/references/cron-triggers/api.md +16 -0
  162. package/skills/devopsCloud/cloudflare/references/cron-triggers/configuration.md +16 -0
  163. package/skills/devopsCloud/cloudflare/references/cron-triggers/gotchas.md +17 -0
  164. package/skills/devopsCloud/cloudflare/references/cron-triggers/patterns.md +18 -0
  165. package/skills/devopsCloud/cloudflare/references/d1/README.md +15 -0
  166. package/skills/devopsCloud/cloudflare/references/d1/api.md +18 -0
  167. package/skills/devopsCloud/cloudflare/references/d1/configuration.md +18 -0
  168. package/skills/devopsCloud/cloudflare/references/d1/gotchas.md +18 -0
  169. package/skills/devopsCloud/cloudflare/references/d1/patterns.md +21 -0
  170. package/skills/devopsCloud/cloudflare/references/frameworkCompatibility.md +110 -0
  171. package/skills/devopsCloud/cloudflare/references/hyperdrive/README.md +28 -0
  172. package/skills/devopsCloud/cloudflare/references/hyperdrive/api.md +26 -0
  173. package/skills/devopsCloud/cloudflare/references/hyperdrive/configuration.md +34 -0
  174. package/skills/devopsCloud/cloudflare/references/hyperdrive/gotchas.md +20 -0
  175. package/skills/devopsCloud/cloudflare/references/hyperdrive/patterns.md +15 -0
  176. package/skills/devopsCloud/cloudflare/references/images/README.md +12 -0
  177. package/skills/devopsCloud/cloudflare/references/images/api.md +13 -0
  178. package/skills/devopsCloud/cloudflare/references/images/configuration.md +17 -0
  179. package/skills/devopsCloud/cloudflare/references/images/gotchas.md +16 -0
  180. package/skills/devopsCloud/cloudflare/references/images/patterns.md +16 -0
  181. package/skills/devopsCloud/cloudflare/references/kv/README.md +15 -0
  182. package/skills/devopsCloud/cloudflare/references/kv/api.md +18 -0
  183. package/skills/devopsCloud/cloudflare/references/kv/configuration.md +16 -0
  184. package/skills/devopsCloud/cloudflare/references/kv/gotchas.md +17 -0
  185. package/skills/devopsCloud/cloudflare/references/kv/patterns.md +21 -0
  186. package/skills/devopsCloud/cloudflare/references/miniflare/README.md +22 -0
  187. package/skills/devopsCloud/cloudflare/references/miniflare/api.md +16 -0
  188. package/skills/devopsCloud/cloudflare/references/miniflare/configuration.md +16 -0
  189. package/skills/devopsCloud/cloudflare/references/miniflare/gotchas.md +15 -0
  190. package/skills/devopsCloud/cloudflare/references/miniflare/patterns.md +19 -0
  191. package/skills/devopsCloud/cloudflare/references/observability/README.md +27 -0
  192. package/skills/devopsCloud/cloudflare/references/observability/api.md +20 -0
  193. package/skills/devopsCloud/cloudflare/references/observability/configuration.md +23 -0
  194. package/skills/devopsCloud/cloudflare/references/observability/gotchas.md +25 -0
  195. package/skills/devopsCloud/cloudflare/references/observability/patterns.md +14 -0
  196. package/skills/devopsCloud/cloudflare/references/pages/README.md +20 -0
  197. package/skills/devopsCloud/cloudflare/references/pages/api.md +13 -0
  198. package/skills/devopsCloud/cloudflare/references/pages/configuration.md +16 -0
  199. package/skills/devopsCloud/cloudflare/references/pages/gotchas.md +19 -0
  200. package/skills/devopsCloud/cloudflare/references/pages/patterns.md +15 -0
  201. package/skills/devopsCloud/cloudflare/references/pages-functions/README.md +20 -0
  202. package/skills/devopsCloud/cloudflare/references/pages-functions/api.md +13 -0
  203. package/skills/devopsCloud/cloudflare/references/pages-functions/configuration.md +14 -0
  204. package/skills/devopsCloud/cloudflare/references/pages-functions/gotchas.md +17 -0
  205. package/skills/devopsCloud/cloudflare/references/pages-functions/patterns.md +16 -0
  206. package/skills/devopsCloud/cloudflare/references/productSelectionMatrix.md +54 -0
  207. package/skills/devopsCloud/cloudflare/references/queues/README.md +24 -0
  208. package/skills/devopsCloud/cloudflare/references/queues/api.md +16 -0
  209. package/skills/devopsCloud/cloudflare/references/queues/configuration.md +20 -0
  210. package/skills/devopsCloud/cloudflare/references/queues/gotchas.md +18 -0
  211. package/skills/devopsCloud/cloudflare/references/queues/patterns.md +21 -0
  212. package/skills/devopsCloud/cloudflare/references/r2/README.md +26 -0
  213. package/skills/devopsCloud/cloudflare/references/r2/api.md +16 -0
  214. package/skills/devopsCloud/cloudflare/references/r2/configuration.md +19 -0
  215. package/skills/devopsCloud/cloudflare/references/r2/gotchas.md +17 -0
  216. package/skills/devopsCloud/cloudflare/references/r2/patterns.md +18 -0
  217. package/skills/devopsCloud/cloudflare/references/secrets-store/README.md +22 -0
  218. package/skills/devopsCloud/cloudflare/references/secrets-store/api.md +21 -0
  219. package/skills/devopsCloud/cloudflare/references/secrets-store/configuration.md +25 -0
  220. package/skills/devopsCloud/cloudflare/references/secrets-store/gotchas.md +19 -0
  221. package/skills/devopsCloud/cloudflare/references/secrets-store/patterns.md +27 -0
  222. package/skills/devopsCloud/cloudflare/references/skill-feedback.md +41 -0
  223. package/skills/devopsCloud/cloudflare/references/static-assets/README.md +21 -0
  224. package/skills/devopsCloud/cloudflare/references/static-assets/api.md +16 -0
  225. package/skills/devopsCloud/cloudflare/references/static-assets/configuration.md +16 -0
  226. package/skills/devopsCloud/cloudflare/references/static-assets/gotchas.md +18 -0
  227. package/skills/devopsCloud/cloudflare/references/static-assets/patterns.md +17 -0
  228. package/skills/devopsCloud/cloudflare/references/stream/README.md +22 -0
  229. package/skills/devopsCloud/cloudflare/references/stream/api-live.md +18 -0
  230. package/skills/devopsCloud/cloudflare/references/stream/api.md +21 -0
  231. package/skills/devopsCloud/cloudflare/references/stream/configuration.md +18 -0
  232. package/skills/devopsCloud/cloudflare/references/stream/gotchas.md +18 -0
  233. package/skills/devopsCloud/cloudflare/references/stream/patterns.md +22 -0
  234. package/skills/devopsCloud/cloudflare/references/tail-workers/README.md +21 -0
  235. package/skills/devopsCloud/cloudflare/references/tail-workers/api.md +13 -0
  236. package/skills/devopsCloud/cloudflare/references/tail-workers/configuration.md +15 -0
  237. package/skills/devopsCloud/cloudflare/references/tail-workers/gotchas.md +16 -0
  238. package/skills/devopsCloud/cloudflare/references/tail-workers/patterns.md +15 -0
  239. package/skills/devopsCloud/cloudflare/references/tunnel/README.md +20 -0
  240. package/skills/devopsCloud/cloudflare/references/tunnel/api.md +14 -0
  241. package/skills/devopsCloud/cloudflare/references/tunnel/configuration.md +14 -0
  242. package/skills/devopsCloud/cloudflare/references/tunnel/gotchas.md +15 -0
  243. package/skills/devopsCloud/cloudflare/references/tunnel/networking.md +14 -0
  244. package/skills/devopsCloud/cloudflare/references/tunnel/patterns.md +15 -0
  245. package/skills/devopsCloud/cloudflare/references/vectorize/README.md +22 -0
  246. package/skills/devopsCloud/cloudflare/references/vectorize/api.md +18 -0
  247. package/skills/devopsCloud/cloudflare/references/vectorize/configuration.md +19 -0
  248. package/skills/devopsCloud/cloudflare/references/vectorize/gotchas.md +15 -0
  249. package/skills/devopsCloud/cloudflare/references/vectorize/patterns.md +24 -0
  250. package/skills/devopsCloud/cloudflare/references/waf/README.md +21 -0
  251. package/skills/devopsCloud/cloudflare/references/waf/api.md +17 -0
  252. package/skills/devopsCloud/cloudflare/references/waf/configuration.md +18 -0
  253. package/skills/devopsCloud/cloudflare/references/waf/gotchas.md +19 -0
  254. package/skills/devopsCloud/cloudflare/references/waf/patterns.md +17 -0
  255. package/skills/devopsCloud/cloudflare/references/workers-ai/README.md +24 -0
  256. package/skills/devopsCloud/cloudflare/references/workers-ai/api.md +13 -0
  257. package/skills/devopsCloud/cloudflare/references/workers-ai/configuration.md +16 -0
  258. package/skills/devopsCloud/cloudflare/references/workers-ai/gotchas.md +15 -0
  259. package/skills/devopsCloud/cloudflare/references/workers-ai/patterns.md +14 -0
  260. package/skills/devopsCloud/cloudflare/references/workflows/README.md +23 -0
  261. package/skills/devopsCloud/cloudflare/references/workflows/api.md +17 -0
  262. package/skills/devopsCloud/cloudflare/references/workflows/configuration.md +18 -0
  263. package/skills/devopsCloud/cloudflare/references/workflows/gotchas.md +19 -0
  264. package/skills/devopsCloud/cloudflare/references/workflows/patterns.md +30 -0
  265. package/skills/devopsCloud/cloudflare/scripts/auditCloudflareProduction.py +95 -0
  266. package/skills/foundation/promptEvalTesting/SKILL.md +114 -0
  267. package/skills/foundation/promptEvalTesting/evals/promptEvalVerification.json +14 -0
  268. package/skills/foundation/promptEvalTesting/references/apiReference.md +3 -0
  269. package/skills/foundation/promptEvalTesting/references/evalMetricsCatalog.md +7 -0
  270. package/skills/foundation/promptEvalTesting/references/promptfooConfigSpecs.md +16 -0
  271. package/skills/foundation/promptEvalTesting/scripts/runPromptEvalSuite.py +29 -0
  272. package/skills/frontend/astro/SKILL.md +327 -0
  273. package/skills/frontend/astro/assets/README.md +71 -0
  274. package/skills/frontend/astro/assets/add-content-to-your-site/content-collections.md +1061 -0
  275. package/skills/frontend/astro/assets/add-content-to-your-site/data-fetching.md +109 -0
  276. package/skills/frontend/astro/assets/add-content-to-your-site/images.md +719 -0
  277. package/skills/frontend/astro/assets/add-content-to-your-site/markdown.md +725 -0
  278. package/skills/frontend/astro/assets/build-your-ui/components.md +402 -0
  279. package/skills/frontend/astro/assets/build-your-ui/fonts.md +437 -0
  280. package/skills/frontend/astro/assets/build-your-ui/front-end-frameworks.md +245 -0
  281. package/skills/frontend/astro/assets/build-your-ui/layouts.md +267 -0
  282. package/skills/frontend/astro/assets/build-your-ui/scripts-and-event-handling.md +229 -0
  283. package/skills/frontend/astro/assets/build-your-ui/styles-and-css.md +782 -0
  284. package/skills/frontend/astro/assets/build-your-ui/syntax-highlighting.md +269 -0
  285. package/skills/frontend/astro/assets/configuration/build-with-ai.md +389 -0
  286. package/skills/frontend/astro/assets/configuration/configuration-overview.md +122 -0
  287. package/skills/frontend/astro/assets/configuration/dev-toolbar.md +86 -0
  288. package/skills/frontend/astro/assets/configuration/editor-setup.md +166 -0
  289. package/skills/frontend/astro/assets/configuration/environment-variables.md +352 -0
  290. package/skills/frontend/astro/assets/configuration/typescript.md +379 -0
  291. package/skills/frontend/astro/assets/configuration/working-with-integrations.md +606 -0
  292. package/skills/frontend/astro/assets/reference/adapter-reference.md +1242 -0
  293. package/skills/frontend/astro/assets/reference/cli-reference.md +575 -0
  294. package/skills/frontend/astro/assets/reference/configuration-reference.md +3144 -0
  295. package/skills/frontend/astro/assets/reference/content-loader-reference.md +1682 -0
  296. package/skills/frontend/astro/assets/reference/directives-reference.md +324 -0
  297. package/skills/frontend/astro/assets/reference/image-service-reference.md +346 -0
  298. package/skills/frontend/astro/assets/reference/integrations-reference.md +2813 -0
  299. package/skills/frontend/astro/assets/reference/modules/astro-actions.md +604 -0
  300. package/skills/frontend/astro/assets/reference/modules/astro-app.md +460 -0
  301. package/skills/frontend/astro/assets/reference/modules/astro-assets.md +1657 -0
  302. package/skills/frontend/astro/assets/reference/modules/astro-config.md +395 -0
  303. package/skills/frontend/astro/assets/reference/modules/astro-content.md +720 -0
  304. package/skills/frontend/astro/assets/reference/modules/astro-env.md +46 -0
  305. package/skills/frontend/astro/assets/reference/modules/astro-fetch.md +346 -0
  306. package/skills/frontend/astro/assets/reference/modules/astro-hono.md +37 -0
  307. package/skills/frontend/astro/assets/reference/modules/astro-i18n.md +462 -0
  308. package/skills/frontend/astro/assets/reference/modules/astro-middleware.md +292 -0
  309. package/skills/frontend/astro/assets/reference/modules/astro-static-paths.md +74 -0
  310. package/skills/frontend/astro/assets/reference/modules/astro-transitions.md +595 -0
  311. package/skills/frontend/astro/assets/reference/modules/astro-zod.md +120 -0
  312. package/skills/frontend/astro/assets/reference/session-driver-reference.md +205 -0
  313. package/skills/frontend/astro/assets/routing-and-navigation/endpoints.md +251 -0
  314. package/skills/frontend/astro/assets/routing-and-navigation/internationalization.md +374 -0
  315. package/skills/frontend/astro/assets/routing-and-navigation/middleware.md +288 -0
  316. package/skills/frontend/astro/assets/routing-and-navigation/pages.md +205 -0
  317. package/skills/frontend/astro/assets/routing-and-navigation/prefetch.md +273 -0
  318. package/skills/frontend/astro/assets/routing-and-navigation/routing.md +760 -0
  319. package/skills/frontend/astro/assets/routing-and-navigation/view-transitions.md +792 -0
  320. package/skills/frontend/astro/assets/server-rendering/actions.md +770 -0
  321. package/skills/frontend/astro/assets/server-rendering/caching.md +255 -0
  322. package/skills/frontend/astro/assets/server-rendering/on-demand-rendering.md +289 -0
  323. package/skills/frontend/astro/assets/server-rendering/server-islands.md +126 -0
  324. package/skills/frontend/astro/assets/server-rendering/sessions.md +270 -0
  325. package/skills/frontend/astro/assets/start-a-new-project/develop-and-build.md +147 -0
  326. package/skills/frontend/astro/assets/start-a-new-project/installation.md +342 -0
  327. package/skills/frontend/astro/assets/start-a-new-project/project-structure.md +137 -0
  328. package/skills/frontend/astro/assets/upgrade-and-troubleshooting/testing.md +412 -0
  329. package/skills/frontend/astro/assets/upgrade-and-troubleshooting/troubleshooting.md +229 -0
  330. package/skills/frontend/astro/assets/upgrade-and-troubleshooting/upgrade-astro.md +205 -0
  331. package/skills/frontend/astro/assets/welcome/courses.md +46 -0
  332. package/skills/frontend/astro/assets/welcome/islands-architecture.md +135 -0
  333. package/skills/frontend/astro/assets/welcome/why-astro.md +90 -0
  334. package/skills/frontend/astro/evals/evals.json +66 -0
  335. package/skills/frontend/astro/references/contentCollections.md +164 -0
  336. package/skills/frontend/astro/references/islandsArchitecture.md +128 -0
  337. package/skills/frontend/astro/references/serverIslandsAndActions.md +187 -0
  338. package/skills/frontend/astro/scripts/auditAstroProduction.py +78 -0
  339. package/skills/frontend/generativeUi/SKILL.md +128 -0
  340. package/skills/frontend/generativeUi/evals/generativeUiVerification.json +14 -0
  341. package/skills/frontend/generativeUi/references/apiReference.md +3 -0
  342. package/skills/frontend/generativeUi/references/clientToolComponentMapping.md +8 -0
  343. package/skills/frontend/generativeUi/references/dataStreamProtocol.md +10 -0
  344. package/skills/frontend/generativeUi/scripts/generateUiComponentStub.py +46 -0
  345. package/skills/frontend/nextjs/SKILL.md +138 -0
  346. package/skills/frontend/nextjs/assets/README.md +67 -0
  347. package/skills/frontend/nextjs/assets/api-reference/cli/create-next-app.md +210 -0
  348. package/skills/frontend/nextjs/assets/api-reference/cli/next.md +484 -0
  349. package/skills/frontend/nextjs/assets/api-reference/components/font.md +952 -0
  350. package/skills/frontend/nextjs/assets/api-reference/components/form.md +387 -0
  351. package/skills/frontend/nextjs/assets/api-reference/components/image.md +1372 -0
  352. package/skills/frontend/nextjs/assets/api-reference/components/link.md +954 -0
  353. package/skills/frontend/nextjs/assets/api-reference/components/script.md +421 -0
  354. package/skills/frontend/nextjs/assets/api-reference/directives/use-cache-private.md +211 -0
  355. package/skills/frontend/nextjs/assets/api-reference/directives/use-cache-remote.md +652 -0
  356. package/skills/frontend/nextjs/assets/api-reference/directives/use-cache.md +848 -0
  357. package/skills/frontend/nextjs/assets/api-reference/directives/use-client.md +149 -0
  358. package/skills/frontend/nextjs/assets/api-reference/directives/use-server.md +234 -0
  359. package/skills/frontend/nextjs/assets/api-reference/edge-runtime.md +188 -0
  360. package/skills/frontend/nextjs/assets/api-reference/file-conventions/default.md +80 -0
  361. package/skills/frontend/nextjs/assets/api-reference/file-conventions/dynamic-routes.md +417 -0
  362. package/skills/frontend/nextjs/assets/api-reference/file-conventions/error.md +361 -0
  363. package/skills/frontend/nextjs/assets/api-reference/file-conventions/forbidden.md +75 -0
  364. package/skills/frontend/nextjs/assets/api-reference/file-conventions/instrumentation-client.md +308 -0
  365. package/skills/frontend/nextjs/assets/api-reference/file-conventions/instrumentation.md +177 -0
  366. package/skills/frontend/nextjs/assets/api-reference/file-conventions/intercepting-routes.md +78 -0
  367. package/skills/frontend/nextjs/assets/api-reference/file-conventions/layout.md +803 -0
  368. package/skills/frontend/nextjs/assets/api-reference/file-conventions/loading.md +209 -0
  369. package/skills/frontend/nextjs/assets/api-reference/file-conventions/mdx-components.md +84 -0
  370. package/skills/frontend/nextjs/assets/api-reference/file-conventions/metadata/app-icons.md +302 -0
  371. package/skills/frontend/nextjs/assets/api-reference/file-conventions/metadata/manifest.md +90 -0
  372. package/skills/frontend/nextjs/assets/api-reference/file-conventions/metadata/opengraph-image.md +580 -0
  373. package/skills/frontend/nextjs/assets/api-reference/file-conventions/metadata/robots.md +234 -0
  374. package/skills/frontend/nextjs/assets/api-reference/file-conventions/metadata/sitemap.md +459 -0
  375. package/skills/frontend/nextjs/assets/api-reference/file-conventions/not-found.md +278 -0
  376. package/skills/frontend/nextjs/assets/api-reference/file-conventions/page.md +283 -0
  377. package/skills/frontend/nextjs/assets/api-reference/file-conventions/parallel-routes.md +517 -0
  378. package/skills/frontend/nextjs/assets/api-reference/file-conventions/proxy.md +857 -0
  379. package/skills/frontend/nextjs/assets/api-reference/file-conventions/public-folder.md +47 -0
  380. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-groups.md +40 -0
  381. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-segment-config/dynamicParams.md +40 -0
  382. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-segment-config/ensureStatic.md +195 -0
  383. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-segment-config/instant.md +204 -0
  384. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-segment-config/maxDuration.md +42 -0
  385. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-segment-config/preferredRegion.md +55 -0
  386. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-segment-config/prefetch.md +113 -0
  387. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route-segment-config/runtime.md +43 -0
  388. package/skills/frontend/nextjs/assets/api-reference/file-conventions/route.md +772 -0
  389. package/skills/frontend/nextjs/assets/api-reference/file-conventions/src-folder.md +42 -0
  390. package/skills/frontend/nextjs/assets/api-reference/file-conventions/template.md +174 -0
  391. package/skills/frontend/nextjs/assets/api-reference/file-conventions/unauthorized.md +143 -0
  392. package/skills/frontend/nextjs/assets/api-reference/functions/after.md +332 -0
  393. package/skills/frontend/nextjs/assets/api-reference/functions/cacheLife.md +642 -0
  394. package/skills/frontend/nextjs/assets/api-reference/functions/cacheTag.md +272 -0
  395. package/skills/frontend/nextjs/assets/api-reference/functions/catchError.md +267 -0
  396. package/skills/frontend/nextjs/assets/api-reference/functions/connection.md +114 -0
  397. package/skills/frontend/nextjs/assets/api-reference/functions/cookies.md +349 -0
  398. package/skills/frontend/nextjs/assets/api-reference/functions/draft-mode.md +173 -0
  399. package/skills/frontend/nextjs/assets/api-reference/functions/fetch.md +141 -0
  400. package/skills/frontend/nextjs/assets/api-reference/functions/forbidden.md +327 -0
  401. package/skills/frontend/nextjs/assets/api-reference/functions/generate-image-metadata.md +311 -0
  402. package/skills/frontend/nextjs/assets/api-reference/functions/generate-metadata.md +1510 -0
  403. package/skills/frontend/nextjs/assets/api-reference/functions/generate-sitemaps.md +102 -0
  404. package/skills/frontend/nextjs/assets/api-reference/functions/generate-static-params.md +606 -0
  405. package/skills/frontend/nextjs/assets/api-reference/functions/generate-viewport.md +347 -0
  406. package/skills/frontend/nextjs/assets/api-reference/functions/headers.md +92 -0
  407. package/skills/frontend/nextjs/assets/api-reference/functions/image-response.md +225 -0
  408. package/skills/frontend/nextjs/assets/api-reference/functions/io.md +131 -0
  409. package/skills/frontend/nextjs/assets/api-reference/functions/navigation.md +220 -0
  410. package/skills/frontend/nextjs/assets/api-reference/functions/next-request.md +116 -0
  411. package/skills/frontend/nextjs/assets/api-reference/functions/next-response.md +219 -0
  412. package/skills/frontend/nextjs/assets/api-reference/functions/next-root-params.md +479 -0
  413. package/skills/frontend/nextjs/assets/api-reference/functions/not-found.md +269 -0
  414. package/skills/frontend/nextjs/assets/api-reference/functions/permanentRedirect.md +92 -0
  415. package/skills/frontend/nextjs/assets/api-reference/functions/prefetch.md +202 -0
  416. package/skills/frontend/nextjs/assets/api-reference/functions/redirect.md +255 -0
  417. package/skills/frontend/nextjs/assets/api-reference/functions/refresh.md +91 -0
  418. package/skills/frontend/nextjs/assets/api-reference/functions/revalidatePath.md +248 -0
  419. package/skills/frontend/nextjs/assets/api-reference/functions/revalidateTag.md +175 -0
  420. package/skills/frontend/nextjs/assets/api-reference/functions/unauthorized.md +389 -0
  421. package/skills/frontend/nextjs/assets/api-reference/functions/unstable_cache.md +131 -0
  422. package/skills/frontend/nextjs/assets/api-reference/functions/unstable_noStore.md +61 -0
  423. package/skills/frontend/nextjs/assets/api-reference/functions/unstable_rethrow.md +79 -0
  424. package/skills/frontend/nextjs/assets/api-reference/functions/updateTag.md +173 -0
  425. package/skills/frontend/nextjs/assets/api-reference/functions/use-link-status.md +268 -0
  426. package/skills/frontend/nextjs/assets/api-reference/functions/use-offline.md +222 -0
  427. package/skills/frontend/nextjs/assets/api-reference/functions/use-params.md +102 -0
  428. package/skills/frontend/nextjs/assets/api-reference/functions/use-pathname.md +189 -0
  429. package/skills/frontend/nextjs/assets/api-reference/functions/use-report-web-vitals.md +175 -0
  430. package/skills/frontend/nextjs/assets/api-reference/functions/use-router.md +214 -0
  431. package/skills/frontend/nextjs/assets/api-reference/functions/use-search-params.md +416 -0
  432. package/skills/frontend/nextjs/assets/api-reference/functions/use-selected-layout-segment.md +214 -0
  433. package/skills/frontend/nextjs/assets/api-reference/functions/use-selected-layout-segments.md +116 -0
  434. package/skills/frontend/nextjs/assets/api-reference/functions/use-server-inserted-html.md +145 -0
  435. package/skills/frontend/nextjs/assets/api-reference/functions/userAgent.md +95 -0
  436. package/skills/frontend/nextjs/assets/api-reference/turbopack.md +552 -0
  437. package/skills/frontend/nextjs/assets/architecture/accessibility.md +47 -0
  438. package/skills/frontend/nextjs/assets/architecture/fast-refresh.md +122 -0
  439. package/skills/frontend/nextjs/assets/architecture/nextjs-compiler.md +376 -0
  440. package/skills/frontend/nextjs/assets/architecture/supported-browsers.md +146 -0
  441. package/skills/frontend/nextjs/assets/community/contribution-guide.md +459 -0
  442. package/skills/frontend/nextjs/assets/community/rspack.md +25 -0
  443. package/skills/frontend/nextjs/assets/getting-started/caching.md +626 -0
  444. package/skills/frontend/nextjs/assets/getting-started/css.md +336 -0
  445. package/skills/frontend/nextjs/assets/getting-started/deploying.md +115 -0
  446. package/skills/frontend/nextjs/assets/getting-started/error-handling.md +485 -0
  447. package/skills/frontend/nextjs/assets/getting-started/fetching-data.md +743 -0
  448. package/skills/frontend/nextjs/assets/getting-started/fonts.md +232 -0
  449. package/skills/frontend/nextjs/assets/getting-started/images.md +272 -0
  450. package/skills/frontend/nextjs/assets/getting-started/installation.md +446 -0
  451. package/skills/frontend/nextjs/assets/getting-started/layouts-and-pages.md +386 -0
  452. package/skills/frontend/nextjs/assets/getting-started/linking-and-navigating.md +475 -0
  453. package/skills/frontend/nextjs/assets/getting-started/metadata-and-og-images.md +370 -0
  454. package/skills/frontend/nextjs/assets/getting-started/mutating-data.md +679 -0
  455. package/skills/frontend/nextjs/assets/getting-started/project-structure.md +290 -0
  456. package/skills/frontend/nextjs/assets/getting-started/proxy.md +107 -0
  457. package/skills/frontend/nextjs/assets/getting-started/revalidating.md +241 -0
  458. package/skills/frontend/nextjs/assets/getting-started/route-handlers.md +233 -0
  459. package/skills/frontend/nextjs/assets/getting-started/server-and-client-components.md +683 -0
  460. package/skills/frontend/nextjs/assets/getting-started/upgrading.md +137 -0
  461. package/skills/frontend/nextjs/assets/glossary.md +315 -0
  462. package/skills/frontend/nextjs/evals/nextjsVerification.json +14 -0
  463. package/skills/frontend/nextjs/references/apiReference.md +3 -0
  464. package/skills/frontend/nextjs/references/dataAccessLayer.md +39 -0
  465. package/skills/frontend/nextjs/references/nextjsFeatureMap.md +276 -0
  466. package/skills/frontend/nextjs/references/productionChecklist.md +49 -0
  467. package/skills/frontend/nextjs/references/securityHeadersCsp.md +44 -0
  468. package/skills/frontend/nextjs/scripts/auditProductionReadiness.py +85 -0
  469. package/skills/frontend/shadcn-ui/SKILL.md +102 -0
  470. package/skills/frontend/shadcn-ui/assets/README.md +82 -0
  471. package/skills/frontend/shadcn-ui/assets/advanced/javascript.md +44 -0
  472. package/skills/frontend/shadcn-ui/assets/advanced/monorepo.md +254 -0
  473. package/skills/frontend/shadcn-ui/assets/advanced/react-19.md +166 -0
  474. package/skills/frontend/shadcn-ui/assets/advanced/tailwind-v4.md +333 -0
  475. package/skills/frontend/shadcn-ui/assets/ai-elements/chain-of-thought.md +519 -0
  476. package/skills/frontend/shadcn-ui/assets/ai-elements/chat.md +581 -0
  477. package/skills/frontend/shadcn-ui/assets/ai-elements/checkpoint.md +243 -0
  478. package/skills/frontend/shadcn-ui/assets/ai-elements/confirmation.md +382 -0
  479. package/skills/frontend/shadcn-ui/assets/ai-elements/context.md +188 -0
  480. package/skills/frontend/shadcn-ui/assets/ai-elements/file-tree.md +248 -0
  481. package/skills/frontend/shadcn-ui/assets/ai-elements/index.md +307 -0
  482. package/skills/frontend/shadcn-ui/assets/ai-elements/inline-citation.md +219 -0
  483. package/skills/frontend/shadcn-ui/assets/ai-elements/message.md +298 -0
  484. package/skills/frontend/shadcn-ui/assets/ai-elements/model-selector.md +368 -0
  485. package/skills/frontend/shadcn-ui/assets/ai-elements/plan.md +398 -0
  486. package/skills/frontend/shadcn-ui/assets/ai-elements/prompt-input.md +403 -0
  487. package/skills/frontend/shadcn-ui/assets/ai-elements/queue.md +517 -0
  488. package/skills/frontend/shadcn-ui/assets/ai-elements/reasoning.md +349 -0
  489. package/skills/frontend/shadcn-ui/assets/ai-elements/sources.md +303 -0
  490. package/skills/frontend/shadcn-ui/assets/ai-elements/stack-trace.md +514 -0
  491. package/skills/frontend/shadcn-ui/assets/ai-elements/subagent.md +551 -0
  492. package/skills/frontend/shadcn-ui/assets/ai-elements/suggestion.md +246 -0
  493. package/skills/frontend/shadcn-ui/assets/ai-elements/task.md +380 -0
  494. package/skills/frontend/shadcn-ui/assets/ai-elements/terminal.md +463 -0
  495. package/skills/frontend/shadcn-ui/assets/ai-elements/test-results.md +641 -0
  496. package/skills/frontend/shadcn-ui/assets/ai-elements/tool.md +915 -0
  497. package/skills/frontend/shadcn-ui/assets/components/accordion.md +490 -0
  498. package/skills/frontend/shadcn-ui/assets/components/alert-dialog.md +520 -0
  499. package/skills/frontend/shadcn-ui/assets/components/alert.md +351 -0
  500. package/skills/frontend/shadcn-ui/assets/components/aspect-ratio.md +206 -0
  501. package/skills/frontend/shadcn-ui/assets/components/attachment.md +715 -0
  502. package/skills/frontend/shadcn-ui/assets/components/avatar.md +581 -0
  503. package/skills/frontend/shadcn-ui/assets/components/badge.md +276 -0
  504. package/skills/frontend/shadcn-ui/assets/components/breadcrumb.md +556 -0
  505. package/skills/frontend/shadcn-ui/assets/components/bubble.md +706 -0
  506. package/skills/frontend/shadcn-ui/assets/components/button-group.md +969 -0
  507. package/skills/frontend/shadcn-ui/assets/components/button.md +523 -0
  508. package/skills/frontend/shadcn-ui/assets/components/calendar.md +959 -0
  509. package/skills/frontend/shadcn-ui/assets/components/card.md +684 -0
  510. package/skills/frontend/shadcn-ui/assets/components/carousel.md +643 -0
  511. package/skills/frontend/shadcn-ui/assets/components/chart.md +1295 -0
  512. package/skills/frontend/shadcn-ui/assets/components/checkbox.md +553 -0
  513. package/skills/frontend/shadcn-ui/assets/components/code-block.md +2041 -0
  514. package/skills/frontend/shadcn-ui/assets/components/collapsible.md +504 -0
  515. package/skills/frontend/shadcn-ui/assets/components/combobox.md +1102 -0
  516. package/skills/frontend/shadcn-ui/assets/components/command.md +682 -0
  517. package/skills/frontend/shadcn-ui/assets/components/context-menu.md +949 -0
  518. package/skills/frontend/shadcn-ui/assets/components/data-table.md +1667 -0
  519. package/skills/frontend/shadcn-ui/assets/components/date-picker.md +698 -0
  520. package/skills/frontend/shadcn-ui/assets/components/dialog.md +454 -0
  521. package/skills/frontend/shadcn-ui/assets/components/direction.md +205 -0
  522. package/skills/frontend/shadcn-ui/assets/components/drawer.md +806 -0
  523. package/skills/frontend/shadcn-ui/assets/components/dropdown-menu.md +1315 -0
  524. package/skills/frontend/shadcn-ui/assets/components/empty.md +562 -0
  525. package/skills/frontend/shadcn-ui/assets/components/field.md +1321 -0
  526. package/skills/frontend/shadcn-ui/assets/components/hover-card.md +342 -0
  527. package/skills/frontend/shadcn-ui/assets/components/index.md +82 -0
  528. package/skills/frontend/shadcn-ui/assets/components/input-group.md +980 -0
  529. package/skills/frontend/shadcn-ui/assets/components/input-otp.md +551 -0
  530. package/skills/frontend/shadcn-ui/assets/components/input.md +555 -0
  531. package/skills/frontend/shadcn-ui/assets/components/item.md +937 -0
  532. package/skills/frontend/shadcn-ui/assets/components/kbd.md +290 -0
  533. package/skills/frontend/shadcn-ui/assets/components/label.md +327 -0
  534. package/skills/frontend/shadcn-ui/assets/components/marker.md +445 -0
  535. package/skills/frontend/shadcn-ui/assets/components/menubar.md +804 -0
  536. package/skills/frontend/shadcn-ui/assets/components/message-scroller.md +2770 -0
  537. package/skills/frontend/shadcn-ui/assets/components/message.md +618 -0
  538. package/skills/frontend/shadcn-ui/assets/components/native-select.md +321 -0
  539. package/skills/frontend/shadcn-ui/assets/components/navigation-menu.md +568 -0
  540. package/skills/frontend/shadcn-ui/assets/components/pagination.md +425 -0
  541. package/skills/frontend/shadcn-ui/assets/components/popover.md +402 -0
  542. package/skills/frontend/shadcn-ui/assets/components/progress.md +240 -0
  543. package/skills/frontend/shadcn-ui/assets/components/questionnaire.md +2055 -0
  544. package/skills/frontend/shadcn-ui/assets/components/radio-group.md +440 -0
  545. package/skills/frontend/shadcn-ui/assets/components/resizable.md +302 -0
  546. package/skills/frontend/shadcn-ui/assets/components/scroll-area.md +226 -0
  547. package/skills/frontend/shadcn-ui/assets/components/select.md +647 -0
  548. package/skills/frontend/shadcn-ui/assets/components/separator.md +235 -0
  549. package/skills/frontend/shadcn-ui/assets/components/sheet.md +354 -0
  550. package/skills/frontend/shadcn-ui/assets/components/sidebar.md +1156 -0
  551. package/skills/frontend/shadcn-ui/assets/components/skeleton.md +217 -0
  552. package/skills/frontend/shadcn-ui/assets/components/slider.md +253 -0
  553. package/skills/frontend/shadcn-ui/assets/components/spinner.md +352 -0
  554. package/skills/frontend/shadcn-ui/assets/components/switch.md +296 -0
  555. package/skills/frontend/shadcn-ui/assets/components/table.md +572 -0
  556. package/skills/frontend/shadcn-ui/assets/components/tabs.md +425 -0
  557. package/skills/frontend/shadcn-ui/assets/components/textarea.md +218 -0
  558. package/skills/frontend/shadcn-ui/assets/components/toast.md +260 -0
  559. package/skills/frontend/shadcn-ui/assets/components/toggle-group.md +419 -0
  560. package/skills/frontend/shadcn-ui/assets/components/toggle.md +220 -0
  561. package/skills/frontend/shadcn-ui/assets/components/tooltip.md +332 -0
  562. package/skills/frontend/shadcn-ui/assets/components/trace.md +1890 -0
  563. package/skills/frontend/shadcn-ui/assets/components/typography.md +561 -0
  564. package/skills/frontend/shadcn-ui/assets/dark-mode/next.md +108 -0
  565. package/skills/frontend/shadcn-ui/assets/dark-mode/overview.md +75 -0
  566. package/skills/frontend/shadcn-ui/assets/dark-mode/vite.md +144 -0
  567. package/skills/frontend/shadcn-ui/assets/forms/next.md +716 -0
  568. package/skills/frontend/shadcn-ui/assets/forms/overview.md +60 -0
  569. package/skills/frontend/shadcn-ui/assets/forms/react-hook-form.md +2055 -0
  570. package/skills/frontend/shadcn-ui/assets/forms/tanstack-form.md +2236 -0
  571. package/skills/frontend/shadcn-ui/assets/installation/astro.md +252 -0
  572. package/skills/frontend/shadcn-ui/assets/installation/manual.md +255 -0
  573. package/skills/frontend/shadcn-ui/assets/installation/next.md +256 -0
  574. package/skills/frontend/shadcn-ui/assets/installation/react-router.md +226 -0
  575. package/skills/frontend/shadcn-ui/assets/installation/remix.md +52 -0
  576. package/skills/frontend/shadcn-ui/assets/installation/vite.md +314 -0
  577. package/skills/frontend/shadcn-ui/assets/mcp/mcp.md +338 -0
  578. package/skills/frontend/shadcn-ui/assets/overview/changelog.md +6 -0
  579. package/skills/frontend/shadcn-ui/assets/overview/cli.md +738 -0
  580. package/skills/frontend/shadcn-ui/assets/overview/components-json.md +379 -0
  581. package/skills/frontend/shadcn-ui/assets/overview/directory.md +74 -0
  582. package/skills/frontend/shadcn-ui/assets/overview/introduction.md +77 -0
  583. package/skills/frontend/shadcn-ui/assets/overview/skills.md +71 -0
  584. package/skills/frontend/shadcn-ui/assets/overview/theming.md +304 -0
  585. package/skills/frontend/shadcn-ui/assets/overview/typeset.md +242 -0
  586. package/skills/frontend/shadcn-ui/assets/registry/getting-started.md +648 -0
  587. package/skills/frontend/shadcn-ui/assets/registry/overview.md +90 -0
  588. package/skills/frontend/shadcn-ui/assets/registry/registry-item-json.md +483 -0
  589. package/skills/frontend/shadcn-ui/assets/registry/registry-json.md +178 -0
  590. package/skills/frontend/shadcn-ui/evals/componentVerification.json +19 -0
  591. package/skills/frontend/shadcn-ui/references/aiComponentsCatalog.md +51 -0
  592. package/skills/frontend/shadcn-ui/references/apiReference.md +3 -0
  593. package/skills/frontend/shadcn-ui/references/blocksCatalog.md +32 -0
  594. package/skills/frontend/shadcn-ui/references/cliCommands.md +47 -0
  595. package/skills/frontend/shadcn-ui/references/componentMarkdownSources.md +48 -0
  596. package/skills/frontend/shadcn-ui/scripts/fetchComponentDocs.py +43 -0
  597. package/skills/frontend/tsxReactStandard/SKILL.md +150 -0
  598. package/skills/frontend/tsxReactStandard/evals/tsxVerification.json +14 -0
  599. package/skills/frontend/tsxReactStandard/references/apiReference.md +3 -0
  600. package/skills/frontend/tsxReactStandard/references/discriminatedUnions.md +31 -0
  601. package/skills/frontend/tsxReactStandard/references/tsconfigStrict.md +36 -0
  602. package/skills/frontend/tsxReactStandard/scripts/validateTsxTypes.py +44 -0
  603. package/skills/gitVersionControl/gitWorkflow/SKILL.md +128 -0
  604. package/skills/gitVersionControl/gitWorkflow/assets/README.md +23 -0
  605. package/skills/gitVersionControl/gitWorkflow/assets/cli/gh-environment.md +87 -0
  606. package/skills/gitVersionControl/gitWorkflow/assets/cli/gh-formatting.md +156 -0
  607. package/skills/gitVersionControl/gitWorkflow/assets/cli/gh-reference.md +2363 -0
  608. package/skills/gitVersionControl/gitWorkflow/assets/using-git/about-git.md +156 -0
  609. package/skills/gitVersionControl/gitWorkflow/assets/using-git/about-remote-repositories.md +65 -0
  610. package/skills/gitVersionControl/gitWorkflow/assets/using-git/associating-text-editors-with-git.md +93 -0
  611. package/skills/gitVersionControl/gitWorkflow/assets/using-git/caching-your-github-credentials.md +115 -0
  612. package/skills/gitVersionControl/gitWorkflow/assets/using-git/getting-changes-from-a-remote-repository.md +76 -0
  613. package/skills/gitVersionControl/gitWorkflow/assets/using-git/ignoring-files.md +51 -0
  614. package/skills/gitVersionControl/gitWorkflow/assets/using-git/managing-remote-repositories.md +231 -0
  615. package/skills/gitVersionControl/gitWorkflow/assets/using-git/pushing-commits-to-a-remote-repository.md +119 -0
  616. package/skills/gitVersionControl/gitWorkflow/evals/evalGitWorkflow.py +43 -0
  617. package/skills/gitVersionControl/gitWorkflow/references/apiReference.md +3 -0
  618. package/skills/gitVersionControl/gitWorkflow/references/branchingModels.md +32 -0
  619. package/skills/gitVersionControl/gitWorkflow/scripts/diagnoseGitGraph.py +68 -0
  620. package/skills/github/assets/README.md +39 -0
  621. package/skills/github/assets/cli/gh-environment.md +87 -0
  622. package/skills/github/assets/cli/gh-formatting.md +156 -0
  623. package/skills/github/assets/cli/gh-reference.md +2363 -0
  624. package/skills/github/assets/docs-api/github-docs-api.md +60 -0
  625. package/skills/github/assets/rest-api/actions-secrets.md +1272 -0
  626. package/skills/github/assets/rest-api/actions-variables.md +1247 -0
  627. package/skills/github/assets/rest-api/actions-workflow-runs.md +1697 -0
  628. package/skills/github/assets/rest-api/actions-workflows.md +348 -0
  629. package/skills/github/assets/rest-api/authenticating.md +174 -0
  630. package/skills/github/assets/rest-api/branches.md +727 -0
  631. package/skills/github/assets/rest-api/checks-runs.md +1013 -0
  632. package/skills/github/assets/rest-api/checks-suites.md +1142 -0
  633. package/skills/github/assets/rest-api/code-scanning.md +2957 -0
  634. package/skills/github/assets/rest-api/collaborators.md +547 -0
  635. package/skills/github/assets/rest-api/commits.md +957 -0
  636. package/skills/github/assets/rest-api/dependabot-alerts.md +895 -0
  637. package/skills/github/assets/rest-api/orgs.md +1172 -0
  638. package/skills/github/assets/rest-api/overview.md +875 -0
  639. package/skills/github/assets/rest-api/pull-reviews.md +722 -0
  640. package/skills/github/assets/rest-api/pulls.md +1605 -0
  641. package/skills/github/assets/rest-api/quickstart.md +344 -0
  642. package/skills/github/assets/rest-api/releases.md +650 -0
  643. package/skills/github/assets/rest-api/repos.md +2957 -0
  644. package/skills/github/assets/rest-api/rules.md +1507 -0
  645. package/skills/github/assets/rest-api/secret-scanning.md +947 -0
  646. package/skills/github/assets/rest-api/teams.md +1690 -0
  647. package/skills/github/githubAction/SKILL.md +159 -0
  648. package/skills/github/githubAction/assets/README.md +38 -0
  649. package/skills/github/githubAction/assets/reference/contexts.md +918 -0
  650. package/skills/github/githubAction/assets/reference/dependency-caching.md +393 -0
  651. package/skills/github/githubAction/assets/reference/events-that-trigger-workflows.md +1348 -0
  652. package/skills/github/githubAction/assets/reference/expressions.md +441 -0
  653. package/skills/github/githubAction/assets/reference/metadata-syntax.md +803 -0
  654. package/skills/github/githubAction/assets/reference/variables.md +149 -0
  655. package/skills/github/githubAction/assets/reference/workflow-cancellation.md +22 -0
  656. package/skills/github/githubAction/assets/reference/workflow-commands.md +1056 -0
  657. package/skills/github/githubAction/assets/reference/workflow-syntax.md +1721 -0
  658. package/skills/github/githubAction/assets/rest-api/secrets.md +1272 -0
  659. package/skills/github/githubAction/assets/rest-api/workflow-runs.md +1697 -0
  660. package/skills/github/githubAction/assets/rest-api/workflows.md +348 -0
  661. package/skills/github/githubAction/assets/starter-workflows/automation/stale.yml +27 -0
  662. package/skills/github/githubAction/assets/starter-workflows/ci/blank.yml +36 -0
  663. package/skills/github/githubAction/assets/starter-workflows/ci/docker-image.yml +18 -0
  664. package/skills/github/githubAction/assets/starter-workflows/ci/go.yml +28 -0
  665. package/skills/github/githubAction/assets/starter-workflows/ci/maven.yml +35 -0
  666. package/skills/github/githubAction/assets/starter-workflows/ci/node.js.yml +31 -0
  667. package/skills/github/githubAction/assets/starter-workflows/ci/python-app.yml +39 -0
  668. package/skills/github/githubAction/assets/starter-workflows/ci/rust.yml +22 -0
  669. package/skills/github/githubAction/assets/starter-workflows/code-scanning/codeql.yml +97 -0
  670. package/skills/github/githubAction/evals/actionVerification.json +14 -0
  671. package/skills/github/githubAction/references/apiReference.md +3 -0
  672. package/skills/github/githubAction/references/workflowPatterns.md +81 -0
  673. package/skills/github/githubAction/scripts/validateWorkflowYaml.py +53 -0
  674. package/skills/github/githubQuality/SKILL.md +136 -0
  675. package/skills/github/githubQuality/assets/README.md +24 -0
  676. package/skills/github/githubQuality/assets/pull-requests/about-code-owners.md +178 -0
  677. package/skills/github/githubQuality/assets/pull-requests/about-merge-methods.md +48 -0
  678. package/skills/github/githubQuality/assets/pull-requests/creating-a-pull-request.md +170 -0
  679. package/skills/github/githubQuality/assets/pull-requests/giving-reviews.md +48 -0
  680. package/skills/github/githubQuality/assets/pull-requests/managing-a-merge-queue.md +134 -0
  681. package/skills/github/githubQuality/assets/pull-requests/merging-a-pull-request.md +101 -0
  682. package/skills/github/githubQuality/assets/pull-requests/resolving-reviews.md +59 -0
  683. package/skills/github/githubQuality/assets/pull-requests/status-checks.md +135 -0
  684. package/skills/github/githubQuality/assets/rest-api/checks-runs.md +1013 -0
  685. package/skills/github/githubQuality/assets/rest-api/checks-suites.md +1142 -0
  686. package/skills/github/githubQuality/assets/rest-api/commits.md +957 -0
  687. package/skills/github/githubQuality/assets/rest-api/pulls.md +1605 -0
  688. package/skills/github/githubQuality/assets/rest-api/reviews.md +722 -0
  689. package/skills/github/githubQuality/evals/qualityVerification.json +14 -0
  690. package/skills/github/githubQuality/references/apiReference.md +3 -0
  691. package/skills/github/githubQuality/references/codeownersExample.md +26 -0
  692. package/skills/github/githubQuality/references/prTemplate.md +20 -0
  693. package/skills/github/githubQuality/scripts/auditPrQuality.py +52 -0
  694. package/skills/github/githubSecurity/SKILL.md +170 -0
  695. package/skills/github/githubSecurity/assets/README.md +32 -0
  696. package/skills/github/githubSecurity/assets/code-scanning/code-scanning-alerts.md +133 -0
  697. package/skills/github/githubSecurity/assets/code-scanning/code-scanning.md +67 -0
  698. package/skills/github/githubSecurity/assets/code-scanning/codeql-code-scanning.md +79 -0
  699. package/skills/github/githubSecurity/assets/code-scanning/configure-code-scanning.md +121 -0
  700. package/skills/github/githubSecurity/assets/dependabot/about-the-dependabot-yml-file.md +74 -0
  701. package/skills/github/githubSecurity/assets/dependabot/dependabot-alerts.md +133 -0
  702. package/skills/github/githubSecurity/assets/dependabot/dependabot-security-updates.md +95 -0
  703. package/skills/github/githubSecurity/assets/dependabot/dependabot-version-updates.md +80 -0
  704. package/skills/github/githubSecurity/assets/rest-api/code-scanning.md +2957 -0
  705. package/skills/github/githubSecurity/assets/rest-api/dependabot-alerts.md +895 -0
  706. package/skills/github/githubSecurity/assets/rest-api/secret-scanning.md +947 -0
  707. package/skills/github/githubSecurity/assets/secret-scanning/enable-secret-scanning.md +59 -0
  708. package/skills/github/githubSecurity/assets/secret-scanning/secret-scanning.md +105 -0
  709. package/skills/github/githubSecurity/assets/security-advisories/github-advisory-database.md +148 -0
  710. package/skills/github/githubSecurity/evals/securityVerification.json +14 -0
  711. package/skills/github/githubSecurity/references/apiReference.md +3 -0
  712. package/skills/github/githubSecurity/references/codeqlAnalysis.yml +42 -0
  713. package/skills/github/githubSecurity/references/dependabotConfig.yml +27 -0
  714. package/skills/github/githubSecurity/scripts/auditRepoSecurity.py +47 -0
  715. package/skills/github/githubSetup/SKILL.md +137 -0
  716. package/skills/github/githubSetup/assets/README.md +40 -0
  717. package/skills/github/githubSetup/assets/branches/about-protected-branches.md +198 -0
  718. package/skills/github/githubSetup/assets/branches/changing-the-default-branch.md +49 -0
  719. package/skills/github/githubSetup/assets/branches/deleting-and-restoring-branches.md +44 -0
  720. package/skills/github/githubSetup/assets/branches/managing-a-branch-protection-rule.md +115 -0
  721. package/skills/github/githubSetup/assets/branches/renaming-a-branch.md +74 -0
  722. package/skills/github/githubSetup/assets/branches/viewing-branches-in-your-repository.md +30 -0
  723. package/skills/github/githubSetup/assets/repositories/about-repositories.md +127 -0
  724. package/skills/github/githubSetup/assets/repositories/cloning-a-repository.md +114 -0
  725. package/skills/github/githubSetup/assets/repositories/creating-a-new-repository.md +82 -0
  726. package/skills/github/githubSetup/assets/repositories/creating-a-repository-from-a-template.md +51 -0
  727. package/skills/github/githubSetup/assets/repositories/deleting-a-repository.md +34 -0
  728. package/skills/github/githubSetup/assets/repositories/managing-teams-and-people-with-access.md +69 -0
  729. package/skills/github/githubSetup/assets/repositories/renaming-a-repository.md +47 -0
  730. package/skills/github/githubSetup/assets/repositories/restoring-a-deleted-repository.md +61 -0
  731. package/skills/github/githubSetup/assets/repositories/setting-repository-visibility.md +137 -0
  732. package/skills/github/githubSetup/assets/rest-api/branches.md +727 -0
  733. package/skills/github/githubSetup/assets/rest-api/quickstart.md +344 -0
  734. package/skills/github/githubSetup/assets/rest-api/repos.md +2957 -0
  735. package/skills/github/githubSetup/assets/rulesets/about-rulesets.md +72 -0
  736. package/skills/github/githubSetup/assets/rulesets/available-rules-for-rulesets.md +383 -0
  737. package/skills/github/githubSetup/assets/rulesets/converting-branch-protections-to-rulesets.md +92 -0
  738. package/skills/github/githubSetup/assets/rulesets/creating-rulesets-for-a-repository.md +108 -0
  739. package/skills/github/githubSetup/assets/rulesets/managing-rulesets-for-a-repository.md +149 -0
  740. package/skills/github/githubSetup/assets/rulesets/troubleshooting-rules.md +122 -0
  741. package/skills/github/githubSetup/evals/setupVerification.json +14 -0
  742. package/skills/github/githubSetup/references/apiReference.md +3 -0
  743. package/skills/github/githubSetup/references/repoSettingsBlueprint.md +13 -0
  744. package/skills/github/githubSetup/references/rulesetTemplates.json +42 -0
  745. package/skills/github/githubSetup/scripts/configureRepoBaseline.py +46 -0
  746. package/skills/github/githubTeam/SKILL.md +115 -0
  747. package/skills/github/githubTeam/assets/README.md +21 -0
  748. package/skills/github/githubTeam/assets/organizations/about-organizations.md +69 -0
  749. package/skills/github/githubTeam/assets/organizations/repository-roles-for-an-organization.md +94 -0
  750. package/skills/github/githubTeam/assets/rest-api/collaborators.md +547 -0
  751. package/skills/github/githubTeam/assets/rest-api/orgs.md +1172 -0
  752. package/skills/github/githubTeam/assets/rest-api/teams.md +1690 -0
  753. package/skills/github/githubTeam/assets/teams/about-teams.md +82 -0
  754. package/skills/github/githubTeam/assets/teams/adding-members-to-a-team.md +55 -0
  755. package/skills/github/githubTeam/evals/teamVerification.json +14 -0
  756. package/skills/github/githubTeam/references/apiReference.md +3 -0
  757. package/skills/github/githubTeam/references/permissionMatrix.md +17 -0
  758. package/skills/github/githubTeam/references/reviewAssignment.md +17 -0
  759. package/skills/github/githubTeam/scripts/manageTeamSync.py +31 -0
  760. package/skills/securityQa/llmSecurityRedteaming/SKILL.md +86 -0
  761. package/skills/securityQa/llmSecurityRedteaming/evals/securityRedteamVerification.json +14 -0
  762. package/skills/securityQa/llmSecurityRedteaming/references/apiReference.md +3 -0
  763. package/skills/securityQa/llmSecurityRedteaming/references/jailbreakTaxonomy.md +6 -0
  764. package/skills/securityQa/llmSecurityRedteaming/references/owaspLlmTopTen.md +12 -0
  765. package/skills/securityQa/llmSecurityRedteaming/scripts/testPromptInjection.py +34 -0
  766. package/skills/softwareDevelopment/requirementsEngineering/SKILL.md +110 -0
  767. package/skills/softwareDevelopment/requirementsEngineering/evals/evalRequirements.py +33 -0
  768. package/skills/softwareDevelopment/requirementsEngineering/references/apiReference.md +3 -0
  769. package/skills/softwareDevelopment/requirementsEngineering/references/requirementsAnalysisModels.md +34 -0
  770. package/skills/softwareDevelopment/requirementsEngineering/scripts/validateUserStories.py +49 -0
  771. package/skills/testing/testDrivenDevelopment/SKILL.md +122 -0
  772. package/skills/testing/testDrivenDevelopment/evals/evalTdd.py +25 -0
  773. package/skills/testing/testDrivenDevelopment/references/apiReference.md +3 -0
  774. package/skills/testing/testDrivenDevelopment/references/testPyramidDoubles.md +35 -0
  775. package/skills/testing/testDrivenDevelopment/scripts/auditTestPyramid.py +58 -0
@@ -0,0 +1,2055 @@
1
+ ---
2
+ title: React Hook Form
3
+ description: Build forms in React using React Hook Form and Zod.
4
+ links:
5
+ doc: https://react-hook-form.com
6
+ ---
7
+
8
+ import { InfoIcon } from "lucide-react"
9
+
10
+ In this guide, we will take a look at building forms with React Hook Form. We'll cover building forms with the `<Field />` component, adding schema validation using Zod, error handling, accessibility, and more.
11
+
12
+ ## Demo
13
+
14
+ We are going to build the following form. It has a simple text input and a textarea. On submit, we'll validate the form data and display any errors.
15
+
16
+ <Callout icon={<InfoIcon />}>
17
+ **Note:** For the purpose of this demo, we have intentionally disabled browser
18
+ validation to show how schema validation and form errors work in React Hook
19
+ Form. It is recommended to add basic browser validation in your production
20
+ code.
21
+ </Callout>
22
+
23
+ ```tsx
24
+ "use client"
25
+
26
+ import * as React from "react"
27
+ import { zodResolver } from "@hookform/resolvers/zod"
28
+ import { Controller, useForm } from "react-hook-form"
29
+ import { toast } from "sonner"
30
+ import * as z from "zod"
31
+
32
+ import { Button } from "@/components/ui/button"
33
+ import {
34
+ Card,
35
+ CardContent,
36
+ CardDescription,
37
+ CardFooter,
38
+ CardHeader,
39
+ CardTitle,
40
+ } from "@/components/ui/card"
41
+ import {
42
+ Field,
43
+ FieldDescription,
44
+ FieldError,
45
+ FieldGroup,
46
+ FieldLabel,
47
+ } from "@/components/ui/field"
48
+ import { Input } from "@/components/ui/input"
49
+ import {
50
+ InputGroup,
51
+ InputGroupAddon,
52
+ InputGroupText,
53
+ InputGroupTextarea,
54
+ } from "@/components/ui/input-group"
55
+
56
+ const formSchema = z.object({
57
+ title: z
58
+ .string()
59
+ .min(5, "Bug title must be at least 5 characters.")
60
+ .max(32, "Bug title must be at most 32 characters."),
61
+ description: z
62
+ .string()
63
+ .min(20, "Description must be at least 20 characters.")
64
+ .max(100, "Description must be at most 100 characters."),
65
+ })
66
+
67
+ export function BugReportForm() {
68
+ const form = useForm<z.infer<typeof formSchema>>({
69
+ resolver: zodResolver(formSchema),
70
+ defaultValues: {
71
+ title: "",
72
+ description: "",
73
+ },
74
+ })
75
+
76
+ function onSubmit(data: z.infer<typeof formSchema>) {
77
+ toast("You submitted the following values:", {
78
+ description: (
79
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
80
+ <code>{JSON.stringify(data, null, 2)}</code>
81
+ </pre>
82
+ ),
83
+ position: "bottom-right",
84
+ classNames: {
85
+ content: "flex flex-col gap-2",
86
+ },
87
+ style: {
88
+ "--border-radius": "calc(var(--radius) + 4px)",
89
+ } as React.CSSProperties,
90
+ })
91
+ }
92
+
93
+ return (
94
+ <Card className="w-full sm:max-w-md">
95
+ <CardHeader>
96
+ <CardTitle>Bug Report</CardTitle>
97
+ <CardDescription>
98
+ Help us improve by reporting bugs you encounter.
99
+ </CardDescription>
100
+ </CardHeader>
101
+ <CardContent>
102
+ <form id="form-rhf-demo" onSubmit={form.handleSubmit(onSubmit)}>
103
+ <FieldGroup>
104
+ <Controller
105
+ name="title"
106
+ control={form.control}
107
+ render={({ field, fieldState }) => (
108
+ <Field data-invalid={fieldState.invalid}>
109
+ <FieldLabel htmlFor="form-rhf-demo-title">
110
+ Bug Title
111
+ </FieldLabel>
112
+ <Input
113
+ {...field}
114
+ id="form-rhf-demo-title"
115
+ aria-invalid={fieldState.invalid}
116
+ placeholder="Login button not working on mobile"
117
+ autoComplete="off"
118
+ />
119
+ {fieldState.invalid && (
120
+ <FieldError errors={[fieldState.error]} />
121
+ )}
122
+ </Field>
123
+ )}
124
+ />
125
+ <Controller
126
+ name="description"
127
+ control={form.control}
128
+ render={({ field, fieldState }) => (
129
+ <Field data-invalid={fieldState.invalid}>
130
+ <FieldLabel htmlFor="form-rhf-demo-description">
131
+ Description
132
+ </FieldLabel>
133
+ <InputGroup>
134
+ <InputGroupTextarea
135
+ {...field}
136
+ id="form-rhf-demo-description"
137
+ placeholder="I'm having an issue with the login button on mobile."
138
+ rows={6}
139
+ className="min-h-24 resize-none"
140
+ aria-invalid={fieldState.invalid}
141
+ />
142
+ <InputGroupAddon align="block-end">
143
+ <InputGroupText className="tabular-nums">
144
+ {field.value.length}/100 characters
145
+ </InputGroupText>
146
+ </InputGroupAddon>
147
+ </InputGroup>
148
+ <FieldDescription>
149
+ Include steps to reproduce, expected behavior, and what
150
+ actually happened.
151
+ </FieldDescription>
152
+ {fieldState.invalid && (
153
+ <FieldError errors={[fieldState.error]} />
154
+ )}
155
+ </Field>
156
+ )}
157
+ />
158
+ </FieldGroup>
159
+ </form>
160
+ </CardContent>
161
+ <CardFooter>
162
+ <Field orientation="horizontal">
163
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
164
+ Reset
165
+ </Button>
166
+ <Button type="submit" form="form-rhf-demo">
167
+ Submit
168
+ </Button>
169
+ </Field>
170
+ </CardFooter>
171
+ </Card>
172
+ )
173
+ }
174
+
175
+ ```
176
+
177
+ ## Approach
178
+
179
+ This form leverages React Hook Form for performant, flexible form handling. We'll build our form using the `<Field />` component, which gives you **complete flexibility over the markup and styling**.
180
+
181
+ - Uses React Hook Form's `useForm` hook for form state management.
182
+ - `<Controller />` component for controlled inputs.
183
+ - `<Field />` components for building accessible forms.
184
+ - Client-side validation using Zod with `zodResolver`.
185
+
186
+ ## Anatomy
187
+
188
+ Here's a basic example of a form using the `<Controller />` component from React Hook Form and the `<Field />` component.
189
+
190
+ ```tsx showLineNumbers {5-18}
191
+ <Controller
192
+ name="title"
193
+ control={form.control}
194
+ render={({ field, fieldState }) => (
195
+ <Field data-invalid={fieldState.invalid}>
196
+ <FieldLabel htmlFor={field.name}>Bug Title</FieldLabel>
197
+ <Input
198
+ {...field}
199
+ id={field.name}
200
+ aria-invalid={fieldState.invalid}
201
+ placeholder="Login button not working on mobile"
202
+ autoComplete="off"
203
+ />
204
+ <FieldDescription>
205
+ Provide a concise title for your bug report.
206
+ </FieldDescription>
207
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
208
+ </Field>
209
+ )}
210
+ />
211
+ ```
212
+
213
+ ## Form
214
+
215
+ ### Create a form schema
216
+
217
+ We'll start by defining the shape of our form using a Zod schema.
218
+
219
+ <Callout icon={<InfoIcon />}>
220
+ **Note:** This example uses `zod v3` for schema validation, but you can
221
+ replace it with any other Standard Schema validation library supported by
222
+ React Hook Form.
223
+ </Callout>
224
+
225
+ ```tsx showLineNumbers title="form.tsx"
226
+ import * as z from "zod"
227
+
228
+ const formSchema = z.object({
229
+ title: z
230
+ .string()
231
+ .min(5, "Bug title must be at least 5 characters.")
232
+ .max(32, "Bug title must be at most 32 characters."),
233
+ description: z
234
+ .string()
235
+ .min(20, "Description must be at least 20 characters.")
236
+ .max(100, "Description must be at most 100 characters."),
237
+ })
238
+ ```
239
+
240
+ ### Set up the form
241
+
242
+ Next, we'll use the `useForm` hook from React Hook Form to create our form instance. We'll also add the Zod resolver to validate the form data.
243
+
244
+ ```tsx showLineNumbers title="form.tsx" {17-23}
245
+ import { zodResolver } from "@hookform/resolvers/zod"
246
+ import { useForm } from "react-hook-form"
247
+ import * as z from "zod"
248
+
249
+ const formSchema = z.object({
250
+ title: z
251
+ .string()
252
+ .min(5, "Bug title must be at least 5 characters.")
253
+ .max(32, "Bug title must be at most 32 characters."),
254
+ description: z
255
+ .string()
256
+ .min(20, "Description must be at least 20 characters.")
257
+ .max(100, "Description must be at most 100 characters."),
258
+ })
259
+
260
+ export function BugReportForm() {
261
+ const form = useForm<z.infer<typeof formSchema>>({
262
+ resolver: zodResolver(formSchema),
263
+ defaultValues: {
264
+ title: "",
265
+ description: "",
266
+ },
267
+ })
268
+
269
+ function onSubmit(data: z.infer<typeof formSchema>) {
270
+ // Do something with the form values.
271
+ console.log(data)
272
+ }
273
+
274
+ return (
275
+ <form onSubmit={form.handleSubmit(onSubmit)}>
276
+ {/* ... */}
277
+ {/* Build the form here */}
278
+ {/* ... */}
279
+ </form>
280
+ )
281
+ }
282
+ ```
283
+
284
+ ### Build the form
285
+
286
+ We can now build the form using the `<Controller />` component from React Hook Form and the `<Field />` component.
287
+
288
+ <ComponentSource
289
+ src="/registry/new-york-v4/examples/form-rhf-demo.tsx"
290
+ title="form.tsx"
291
+ />
292
+
293
+ ### Done
294
+
295
+ That's it. You now have a fully accessible form with client-side validation.
296
+
297
+ When you submit the form, the `onSubmit` function will be called with the validated form data. If the form data is invalid, React Hook Form will display the errors next to each field.
298
+
299
+ ## Validation
300
+
301
+ ### Client-side Validation
302
+
303
+ React Hook Form validates your form data using the Zod schema. Define a schema and pass it to the `resolver` option of the `useForm` hook.
304
+
305
+ ```tsx showLineNumbers title="example-form.tsx" {5-8,12}
306
+ import { zodResolver } from "@hookform/resolvers/zod"
307
+ import { useForm } from "react-hook-form"
308
+ import * as z from "zod"
309
+
310
+ const formSchema = z.object({
311
+ title: z.string(),
312
+ description: z.string().optional(),
313
+ })
314
+
315
+ export function ExampleForm() {
316
+ const form = useForm<z.infer<typeof formSchema>>({
317
+ resolver: zodResolver(formSchema),
318
+ defaultValues: {
319
+ title: "",
320
+ description: "",
321
+ },
322
+ })
323
+ }
324
+ ```
325
+
326
+ ### Validation Modes
327
+
328
+ React Hook Form supports different validation modes.
329
+
330
+ ```tsx showLineNumbers title="form.tsx" {3}
331
+ const form = useForm<z.infer<typeof formSchema>>({
332
+ resolver: zodResolver(formSchema),
333
+ mode: "onChange",
334
+ })
335
+ ```
336
+
337
+ | Mode | Description |
338
+ | ------------- | -------------------------------------------------------- |
339
+ | `"onChange"` | Validation triggers on every change. |
340
+ | `"onBlur"` | Validation triggers on blur. |
341
+ | `"onSubmit"` | Validation triggers on submit (default). |
342
+ | `"onTouched"` | Validation triggers on first blur, then on every change. |
343
+ | `"all"` | Validation triggers on blur and change. |
344
+
345
+ ## Displaying Errors
346
+
347
+ Display errors next to the field using `<FieldError />`. For styling and accessibility:
348
+
349
+ - Add the `data-invalid` prop to the `<Field />` component.
350
+ - Add the `aria-invalid` prop to the form control such as `<Input />`, `<SelectTrigger />`, `<Checkbox />`, etc.
351
+
352
+ ```tsx showLineNumbers title="form.tsx" {5,11,13}
353
+ <Controller
354
+ name="email"
355
+ control={form.control}
356
+ render={({ field, fieldState }) => (
357
+ <Field data-invalid={fieldState.invalid}>
358
+ <FieldLabel htmlFor={field.name}>Email</FieldLabel>
359
+ <Input
360
+ {...field}
361
+ id={field.name}
362
+ type="email"
363
+ aria-invalid={fieldState.invalid}
364
+ />
365
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
366
+ </Field>
367
+ )}
368
+ />
369
+ ```
370
+
371
+ ## Working with Different Field Types
372
+
373
+ ### Input
374
+
375
+ - For input fields, spread the `field` object onto the `<Input />` component.
376
+ - To show errors, add the `aria-invalid` prop to the `<Input />` component and the `data-invalid` prop to the `<Field />` component.
377
+
378
+ ```tsx
379
+ "use client"
380
+
381
+ import { zodResolver } from "@hookform/resolvers/zod"
382
+ import { Controller, useForm } from "react-hook-form"
383
+ import { toast } from "sonner"
384
+ import * as z from "zod"
385
+
386
+ import { Button } from "@/components/ui/button"
387
+ import {
388
+ Card,
389
+ CardContent,
390
+ CardDescription,
391
+ CardFooter,
392
+ CardHeader,
393
+ CardTitle,
394
+ } from "@/components/ui/card"
395
+ import {
396
+ Field,
397
+ FieldDescription,
398
+ FieldError,
399
+ FieldGroup,
400
+ FieldLabel,
401
+ } from "@/components/ui/field"
402
+ import { Input } from "@/components/ui/input"
403
+
404
+ const formSchema = z.object({
405
+ username: z
406
+ .string()
407
+ .min(3, "Username must be at least 3 characters.")
408
+ .max(10, "Username must be at most 10 characters.")
409
+ .regex(
410
+ /^[a-zA-Z0-9_]+$/,
411
+ "Username can only contain letters, numbers, and underscores."
412
+ ),
413
+ })
414
+
415
+ export function FormRhfInput() {
416
+ const form = useForm<z.infer<typeof formSchema>>({
417
+ resolver: zodResolver(formSchema),
418
+ defaultValues: {
419
+ username: "",
420
+ },
421
+ })
422
+
423
+ function onSubmit(data: z.infer<typeof formSchema>) {
424
+ toast("You submitted the following values:", {
425
+ description: (
426
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
427
+ <code>{JSON.stringify(data, null, 2)}</code>
428
+ </pre>
429
+ ),
430
+ position: "bottom-right",
431
+ classNames: {
432
+ content: "flex flex-col gap-2",
433
+ },
434
+ style: {
435
+ "--border-radius": "calc(var(--radius) + 4px)",
436
+ } as React.CSSProperties,
437
+ })
438
+ }
439
+
440
+ return (
441
+ <Card className="w-full sm:max-w-md">
442
+ <CardHeader>
443
+ <CardTitle>Profile Settings</CardTitle>
444
+ <CardDescription>
445
+ Update your profile information below.
446
+ </CardDescription>
447
+ </CardHeader>
448
+ <CardContent>
449
+ <form id="form-rhf-input" onSubmit={form.handleSubmit(onSubmit)}>
450
+ <FieldGroup>
451
+ <Controller
452
+ name="username"
453
+ control={form.control}
454
+ render={({ field, fieldState }) => (
455
+ <Field data-invalid={fieldState.invalid}>
456
+ <FieldLabel htmlFor="form-rhf-input-username">
457
+ Username
458
+ </FieldLabel>
459
+ <Input
460
+ {...field}
461
+ id="form-rhf-input-username"
462
+ aria-invalid={fieldState.invalid}
463
+ placeholder="shadcn"
464
+ autoComplete="username"
465
+ />
466
+ <FieldDescription>
467
+ This is your public display name. Must be between 3 and 10
468
+ characters. Must only contain letters, numbers, and
469
+ underscores.
470
+ </FieldDescription>
471
+ {fieldState.invalid && (
472
+ <FieldError errors={[fieldState.error]} />
473
+ )}
474
+ </Field>
475
+ )}
476
+ />
477
+ </FieldGroup>
478
+ </form>
479
+ </CardContent>
480
+ <CardFooter>
481
+ <Field orientation="horizontal">
482
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
483
+ Reset
484
+ </Button>
485
+ <Button type="submit" form="form-rhf-input">
486
+ Save
487
+ </Button>
488
+ </Field>
489
+ </CardFooter>
490
+ </Card>
491
+ )
492
+ }
493
+
494
+ ```
495
+
496
+ For simple text inputs, spread the `field` object onto the input.
497
+
498
+ ```tsx showLineNumbers title="form.tsx" {5,7,8}
499
+ <Controller
500
+ name="name"
501
+ control={form.control}
502
+ render={({ field, fieldState }) => (
503
+ <Field data-invalid={fieldState.invalid}>
504
+ <FieldLabel htmlFor={field.name}>Name</FieldLabel>
505
+ <Input {...field} id={field.name} aria-invalid={fieldState.invalid} />
506
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
507
+ </Field>
508
+ )}
509
+ />
510
+ ```
511
+
512
+ ### Textarea
513
+
514
+ - For textarea fields, spread the `field` object onto the `<Textarea />` component.
515
+ - To show errors, add the `aria-invalid` prop to the `<Textarea />` component and the `data-invalid` prop to the `<Field />` component.
516
+
517
+ ```tsx
518
+ "use client"
519
+
520
+ import * as React from "react"
521
+ import { zodResolver } from "@hookform/resolvers/zod"
522
+ import { Controller, useForm } from "react-hook-form"
523
+ import { toast } from "sonner"
524
+ import * as z from "zod"
525
+
526
+ import { Button } from "@/components/ui/button"
527
+ import {
528
+ Card,
529
+ CardContent,
530
+ CardDescription,
531
+ CardFooter,
532
+ CardHeader,
533
+ CardTitle,
534
+ } from "@/components/ui/card"
535
+ import {
536
+ Field,
537
+ FieldDescription,
538
+ FieldError,
539
+ FieldGroup,
540
+ FieldLabel,
541
+ } from "@/components/ui/field"
542
+ import { Textarea } from "@/components/ui/textarea"
543
+
544
+ const formSchema = z.object({
545
+ about: z
546
+ .string()
547
+ .min(10, "Please provide at least 10 characters.")
548
+ .max(200, "Please keep it under 200 characters."),
549
+ })
550
+
551
+ export function FormRhfTextarea() {
552
+ const form = useForm<z.infer<typeof formSchema>>({
553
+ resolver: zodResolver(formSchema),
554
+ defaultValues: {
555
+ about: "",
556
+ },
557
+ })
558
+
559
+ function onSubmit(data: z.infer<typeof formSchema>) {
560
+ toast("You submitted the following values:", {
561
+ description: (
562
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
563
+ <code>{JSON.stringify(data, null, 2)}</code>
564
+ </pre>
565
+ ),
566
+ position: "bottom-right",
567
+ classNames: {
568
+ content: "flex flex-col gap-2",
569
+ },
570
+ style: {
571
+ "--border-radius": "calc(var(--radius) + 4px)",
572
+ } as React.CSSProperties,
573
+ })
574
+ }
575
+
576
+ return (
577
+ <Card className="w-full sm:max-w-md">
578
+ <CardHeader>
579
+ <CardTitle>Personalization</CardTitle>
580
+ <CardDescription>
581
+ Customize your experience by telling us more about yourself.
582
+ </CardDescription>
583
+ </CardHeader>
584
+ <CardContent>
585
+ <form id="form-rhf-textarea" onSubmit={form.handleSubmit(onSubmit)}>
586
+ <FieldGroup>
587
+ <Controller
588
+ name="about"
589
+ control={form.control}
590
+ render={({ field, fieldState }) => (
591
+ <Field data-invalid={fieldState.invalid}>
592
+ <FieldLabel htmlFor="form-rhf-textarea-about">
593
+ More about you
594
+ </FieldLabel>
595
+ <Textarea
596
+ {...field}
597
+ id="form-rhf-textarea-about"
598
+ aria-invalid={fieldState.invalid}
599
+ placeholder="I'm a software engineer..."
600
+ className="min-h-[120px]"
601
+ />
602
+ <FieldDescription>
603
+ Tell us more about yourself. This will be used to help us
604
+ personalize your experience.
605
+ </FieldDescription>
606
+ {fieldState.invalid && (
607
+ <FieldError errors={[fieldState.error]} />
608
+ )}
609
+ </Field>
610
+ )}
611
+ />
612
+ </FieldGroup>
613
+ </form>
614
+ </CardContent>
615
+ <CardFooter>
616
+ <Field orientation="horizontal">
617
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
618
+ Reset
619
+ </Button>
620
+ <Button type="submit" form="form-rhf-textarea">
621
+ Save
622
+ </Button>
623
+ </Field>
624
+ </CardFooter>
625
+ </Card>
626
+ )
627
+ }
628
+
629
+ ```
630
+
631
+ For textarea fields, spread the `field` object onto the textarea.
632
+
633
+ ```tsx showLineNumbers title="form.tsx" {5,10,18}
634
+ <Controller
635
+ name="about"
636
+ control={form.control}
637
+ render={({ field, fieldState }) => (
638
+ <Field data-invalid={fieldState.invalid}>
639
+ <FieldLabel htmlFor="form-rhf-textarea-about">More about you</FieldLabel>
640
+ <Textarea
641
+ {...field}
642
+ id="form-rhf-textarea-about"
643
+ aria-invalid={fieldState.invalid}
644
+ placeholder="I'm a software engineer..."
645
+ className="min-h-[120px]"
646
+ />
647
+ <FieldDescription>
648
+ Tell us more about yourself. This will be used to help us personalize
649
+ your experience.
650
+ </FieldDescription>
651
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
652
+ </Field>
653
+ )}
654
+ />
655
+ ```
656
+
657
+ ### Select
658
+
659
+ - For select components, use `field.value` and `field.onChange` on the `<Select />` component.
660
+ - To show errors, add the `aria-invalid` prop to the `<SelectTrigger />` component and the `data-invalid` prop to the `<Field />` component.
661
+
662
+ ```tsx
663
+ "use client"
664
+
665
+ import * as React from "react"
666
+ import { zodResolver } from "@hookform/resolvers/zod"
667
+ import { Controller, useForm } from "react-hook-form"
668
+ import { toast } from "sonner"
669
+ import * as z from "zod"
670
+
671
+ import { Button } from "@/components/ui/button"
672
+ import {
673
+ Card,
674
+ CardContent,
675
+ CardDescription,
676
+ CardFooter,
677
+ CardHeader,
678
+ CardTitle,
679
+ } from "@/components/ui/card"
680
+ import {
681
+ Field,
682
+ FieldContent,
683
+ FieldDescription,
684
+ FieldError,
685
+ FieldGroup,
686
+ FieldLabel,
687
+ } from "@/components/ui/field"
688
+ import {
689
+ Select,
690
+ SelectContent,
691
+ SelectItem,
692
+ SelectSeparator,
693
+ SelectTrigger,
694
+ SelectValue,
695
+ } from "@/components/ui/select"
696
+
697
+ const spokenLanguages = [
698
+ { label: "English", value: "en" },
699
+ { label: "Spanish", value: "es" },
700
+ { label: "French", value: "fr" },
701
+ { label: "German", value: "de" },
702
+ { label: "Italian", value: "it" },
703
+ { label: "Chinese", value: "zh" },
704
+ { label: "Japanese", value: "ja" },
705
+ ] as const
706
+
707
+ const formSchema = z.object({
708
+ language: z
709
+ .string()
710
+ .min(1, "Please select your spoken language.")
711
+ .refine((val) => val !== "auto", {
712
+ message:
713
+ "Auto-detection is not allowed. Please select a specific language.",
714
+ }),
715
+ })
716
+
717
+ export function FormRhfSelect() {
718
+ const form = useForm<z.infer<typeof formSchema>>({
719
+ resolver: zodResolver(formSchema),
720
+ defaultValues: {
721
+ language: "",
722
+ },
723
+ })
724
+
725
+ function onSubmit(data: z.infer<typeof formSchema>) {
726
+ toast("You submitted the following values:", {
727
+ description: (
728
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
729
+ <code>{JSON.stringify(data, null, 2)}</code>
730
+ </pre>
731
+ ),
732
+ position: "bottom-right",
733
+ classNames: {
734
+ content: "flex flex-col gap-2",
735
+ },
736
+ style: {
737
+ "--border-radius": "calc(var(--radius) + 4px)",
738
+ } as React.CSSProperties,
739
+ })
740
+ }
741
+
742
+ return (
743
+ <Card className="w-full sm:max-w-lg">
744
+ <CardHeader>
745
+ <CardTitle>Language Preferences</CardTitle>
746
+ <CardDescription>
747
+ Select your preferred spoken language.
748
+ </CardDescription>
749
+ </CardHeader>
750
+ <CardContent>
751
+ <form id="form-rhf-select" onSubmit={form.handleSubmit(onSubmit)}>
752
+ <FieldGroup>
753
+ <Controller
754
+ name="language"
755
+ control={form.control}
756
+ render={({ field, fieldState }) => (
757
+ <Field
758
+ orientation="responsive"
759
+ data-invalid={fieldState.invalid}
760
+ >
761
+ <FieldContent>
762
+ <FieldLabel htmlFor="form-rhf-select-language">
763
+ Spoken Language
764
+ </FieldLabel>
765
+ <FieldDescription>
766
+ For best results, select the language you speak.
767
+ </FieldDescription>
768
+ {fieldState.invalid && (
769
+ <FieldError errors={[fieldState.error]} />
770
+ )}
771
+ </FieldContent>
772
+ <Select
773
+ name={field.name}
774
+ value={field.value}
775
+ onValueChange={field.onChange}
776
+ >
777
+ <SelectTrigger
778
+ id="form-rhf-select-language"
779
+ aria-invalid={fieldState.invalid}
780
+ className="min-w-[120px]"
781
+ >
782
+ <SelectValue placeholder="Select" />
783
+ </SelectTrigger>
784
+ <SelectContent position="item-aligned">
785
+ <SelectItem value="auto">Auto</SelectItem>
786
+ <SelectSeparator />
787
+ {spokenLanguages.map((language) => (
788
+ <SelectItem key={language.value} value={language.value}>
789
+ {language.label}
790
+ </SelectItem>
791
+ ))}
792
+ </SelectContent>
793
+ </Select>
794
+ </Field>
795
+ )}
796
+ />
797
+ </FieldGroup>
798
+ </form>
799
+ </CardContent>
800
+ <CardFooter>
801
+ <Field orientation="horizontal">
802
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
803
+ Reset
804
+ </Button>
805
+ <Button type="submit" form="form-rhf-select">
806
+ Save
807
+ </Button>
808
+ </Field>
809
+ </CardFooter>
810
+ </Card>
811
+ )
812
+ }
813
+
814
+ ```
815
+
816
+ ```tsx showLineNumbers title="form.tsx" {5,13,22}
817
+ <Controller
818
+ name="language"
819
+ control={form.control}
820
+ render={({ field, fieldState }) => (
821
+ <Field orientation="responsive" data-invalid={fieldState.invalid}>
822
+ <FieldContent>
823
+ <FieldLabel htmlFor="form-rhf-select-language">
824
+ Spoken Language
825
+ </FieldLabel>
826
+ <FieldDescription>
827
+ For best results, select the language you speak.
828
+ </FieldDescription>
829
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
830
+ </FieldContent>
831
+ <Select
832
+ name={field.name}
833
+ value={field.value}
834
+ onValueChange={field.onChange}
835
+ >
836
+ <SelectTrigger
837
+ id="form-rhf-select-language"
838
+ aria-invalid={fieldState.invalid}
839
+ className="min-w-[120px]"
840
+ >
841
+ <SelectValue placeholder="Select" />
842
+ </SelectTrigger>
843
+ <SelectContent position="item-aligned">
844
+ <SelectItem value="auto">Auto</SelectItem>
845
+ <SelectItem value="en">English</SelectItem>
846
+ </SelectContent>
847
+ </Select>
848
+ </Field>
849
+ )}
850
+ />
851
+ ```
852
+
853
+ ### Checkbox
854
+
855
+ - For checkbox arrays, use `field.value` and `field.onChange` with array manipulation.
856
+ - To show errors, add the `aria-invalid` prop to the `<Checkbox />` component and the `data-invalid` prop to the `<Field />` component.
857
+ - Remember to add `data-slot="checkbox-group"` to the `<FieldGroup />` component for proper styling and spacing.
858
+
859
+ ```tsx
860
+ "use client"
861
+
862
+ import * as React from "react"
863
+ import { zodResolver } from "@hookform/resolvers/zod"
864
+ import { Controller, useForm } from "react-hook-form"
865
+ import { toast } from "sonner"
866
+ import * as z from "zod"
867
+
868
+ import { Button } from "@/components/ui/button"
869
+ import {
870
+ Card,
871
+ CardContent,
872
+ CardDescription,
873
+ CardFooter,
874
+ CardHeader,
875
+ CardTitle,
876
+ } from "@/components/ui/card"
877
+ import { Checkbox } from "@/components/ui/checkbox"
878
+ import {
879
+ Field,
880
+ FieldDescription,
881
+ FieldError,
882
+ FieldGroup,
883
+ FieldLabel,
884
+ FieldLegend,
885
+ FieldSeparator,
886
+ FieldSet,
887
+ } from "@/components/ui/field"
888
+
889
+ const tasks = [
890
+ {
891
+ id: "push",
892
+ label: "Push notifications",
893
+ },
894
+ {
895
+ id: "email",
896
+ label: "Email notifications",
897
+ },
898
+ ] as const
899
+
900
+ const formSchema = z.object({
901
+ responses: z.boolean(),
902
+ tasks: z
903
+ .array(z.string())
904
+ .min(1, "Please select at least one notification type.")
905
+ .refine(
906
+ (value) => value.every((task) => tasks.some((t) => t.id === task)),
907
+ {
908
+ message: "Invalid notification type selected.",
909
+ }
910
+ ),
911
+ })
912
+
913
+ export function FormRhfCheckbox() {
914
+ const form = useForm<z.infer<typeof formSchema>>({
915
+ resolver: zodResolver(formSchema),
916
+ defaultValues: {
917
+ responses: true,
918
+ tasks: [],
919
+ },
920
+ })
921
+
922
+ function onSubmit(data: z.infer<typeof formSchema>) {
923
+ toast("You submitted the following values:", {
924
+ description: (
925
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
926
+ <code>{JSON.stringify(data, null, 2)}</code>
927
+ </pre>
928
+ ),
929
+ position: "bottom-right",
930
+ classNames: {
931
+ content: "flex flex-col gap-2",
932
+ },
933
+ style: {
934
+ "--border-radius": "calc(var(--radius) + 4px)",
935
+ } as React.CSSProperties,
936
+ })
937
+ }
938
+
939
+ return (
940
+ <Card className="w-full sm:max-w-md">
941
+ <CardHeader>
942
+ <CardTitle>Notifications</CardTitle>
943
+ <CardDescription>Manage your notification preferences.</CardDescription>
944
+ </CardHeader>
945
+ <CardContent>
946
+ <form id="form-rhf-checkbox" onSubmit={form.handleSubmit(onSubmit)}>
947
+ <FieldGroup>
948
+ <Controller
949
+ name="responses"
950
+ control={form.control}
951
+ render={({ field, fieldState }) => (
952
+ <div>
953
+ <FieldSet data-invalid={fieldState.invalid}>
954
+ <FieldLegend variant="label">Responses</FieldLegend>
955
+ <FieldDescription>
956
+ Get notified for requests that take time, like research or
957
+ image generation.
958
+ </FieldDescription>
959
+ <FieldGroup data-slot="checkbox-group">
960
+ <Field orientation="horizontal">
961
+ <Checkbox
962
+ id="form-rhf-checkbox-responses"
963
+ name={field.name}
964
+ checked={field.value}
965
+ onCheckedChange={field.onChange}
966
+ disabled
967
+ />
968
+ <FieldLabel
969
+ htmlFor="form-rhf-checkbox-responses"
970
+ className="font-normal"
971
+ >
972
+ Push notifications
973
+ </FieldLabel>
974
+ </Field>
975
+ </FieldGroup>
976
+ </FieldSet>
977
+ {fieldState.invalid && (
978
+ <FieldError errors={[fieldState.error]} />
979
+ )}
980
+ </div>
981
+ )}
982
+ />
983
+ <FieldSeparator />
984
+ <Controller
985
+ name="tasks"
986
+ control={form.control}
987
+ render={({ field, fieldState }) => (
988
+ <FieldGroup>
989
+ <FieldSet data-invalid={fieldState.invalid}>
990
+ <FieldLegend variant="label">Tasks</FieldLegend>
991
+ <FieldDescription>
992
+ Get notified when tasks you&apos;ve created have updates.
993
+ </FieldDescription>
994
+ <FieldGroup data-slot="checkbox-group">
995
+ {tasks.map((task) => (
996
+ <Field
997
+ key={task.id}
998
+ orientation="horizontal"
999
+ data-invalid={fieldState.invalid}
1000
+ >
1001
+ <Checkbox
1002
+ id={`form-rhf-checkbox-${task.id}`}
1003
+ name={field.name}
1004
+ aria-invalid={fieldState.invalid}
1005
+ checked={field.value.includes(task.id)}
1006
+ onCheckedChange={(checked) => {
1007
+ const newValue = checked
1008
+ ? [...field.value, task.id]
1009
+ : field.value.filter(
1010
+ (value) => value !== task.id
1011
+ )
1012
+ field.onChange(newValue)
1013
+ }}
1014
+ />
1015
+ <FieldLabel
1016
+ htmlFor={`form-rhf-checkbox-${task.id}`}
1017
+ className="font-normal"
1018
+ >
1019
+ {task.label}
1020
+ </FieldLabel>
1021
+ </Field>
1022
+ ))}
1023
+ </FieldGroup>
1024
+ </FieldSet>
1025
+ {fieldState.invalid && (
1026
+ <FieldError errors={[fieldState.error]} />
1027
+ )}
1028
+ </FieldGroup>
1029
+ )}
1030
+ />
1031
+ </FieldGroup>
1032
+ </form>
1033
+ </CardContent>
1034
+ <CardFooter>
1035
+ <Field orientation="horizontal">
1036
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
1037
+ Reset
1038
+ </Button>
1039
+ <Button type="submit" form="form-rhf-checkbox">
1040
+ Save
1041
+ </Button>
1042
+ </Field>
1043
+ </CardFooter>
1044
+ </Card>
1045
+ )
1046
+ }
1047
+
1048
+ ```
1049
+
1050
+ ```tsx showLineNumbers title="form.tsx" {10,15,20-22,38}
1051
+ <Controller
1052
+ name="tasks"
1053
+ control={form.control}
1054
+ render={({ field, fieldState }) => (
1055
+ <FieldSet>
1056
+ <FieldLegend variant="label">Tasks</FieldLegend>
1057
+ <FieldDescription>
1058
+ Get notified when tasks you&apos;ve created have updates.
1059
+ </FieldDescription>
1060
+ <FieldGroup data-slot="checkbox-group">
1061
+ {tasks.map((task) => (
1062
+ <Field
1063
+ key={task.id}
1064
+ orientation="horizontal"
1065
+ data-invalid={fieldState.invalid}
1066
+ >
1067
+ <Checkbox
1068
+ id={`form-rhf-checkbox-${task.id}`}
1069
+ name={field.name}
1070
+ aria-invalid={fieldState.invalid}
1071
+ checked={field.value.includes(task.id)}
1072
+ onCheckedChange={(checked) => {
1073
+ const newValue = checked
1074
+ ? [...field.value, task.id]
1075
+ : field.value.filter((value) => value !== task.id)
1076
+ field.onChange(newValue)
1077
+ }}
1078
+ />
1079
+ <FieldLabel
1080
+ htmlFor={`form-rhf-checkbox-${task.id}`}
1081
+ className="font-normal"
1082
+ >
1083
+ {task.label}
1084
+ </FieldLabel>
1085
+ </Field>
1086
+ ))}
1087
+ </FieldGroup>
1088
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
1089
+ </FieldSet>
1090
+ )}
1091
+ />
1092
+ ```
1093
+
1094
+ ### Radio Group
1095
+
1096
+ - For radio groups, use `field.value` and `field.onChange` on the `<RadioGroup />` component.
1097
+ - To show errors, add the `aria-invalid` prop to the `<RadioGroupItem />` component and the `data-invalid` prop to the `<Field />` component.
1098
+
1099
+ ```tsx
1100
+ "use client"
1101
+
1102
+ import * as React from "react"
1103
+ import { zodResolver } from "@hookform/resolvers/zod"
1104
+ import { Controller, useForm } from "react-hook-form"
1105
+ import { toast } from "sonner"
1106
+ import * as z from "zod"
1107
+
1108
+ import { Button } from "@/components/ui/button"
1109
+ import {
1110
+ Card,
1111
+ CardContent,
1112
+ CardDescription,
1113
+ CardFooter,
1114
+ CardHeader,
1115
+ CardTitle,
1116
+ } from "@/components/ui/card"
1117
+ import {
1118
+ Field,
1119
+ FieldContent,
1120
+ FieldDescription,
1121
+ FieldError,
1122
+ FieldGroup,
1123
+ FieldLabel,
1124
+ FieldLegend,
1125
+ FieldSet,
1126
+ FieldTitle,
1127
+ } from "@/components/ui/field"
1128
+ import {
1129
+ RadioGroup,
1130
+ RadioGroupItem,
1131
+ } from "@/components/ui/radio-group"
1132
+
1133
+ const plans = [
1134
+ {
1135
+ id: "starter",
1136
+ title: "Starter (100K tokens/month)",
1137
+ description: "For everyday use with basic features.",
1138
+ },
1139
+ {
1140
+ id: "pro",
1141
+ title: "Pro (1M tokens/month)",
1142
+ description: "For advanced AI usage with more features.",
1143
+ },
1144
+ {
1145
+ id: "enterprise",
1146
+ title: "Enterprise (Unlimited tokens)",
1147
+ description: "For large teams and heavy usage.",
1148
+ },
1149
+ ] as const
1150
+
1151
+ const formSchema = z.object({
1152
+ plan: z.string().min(1, "You must select a subscription plan to continue."),
1153
+ })
1154
+
1155
+ export function FormRhfRadioGroup() {
1156
+ const form = useForm<z.infer<typeof formSchema>>({
1157
+ resolver: zodResolver(formSchema),
1158
+ defaultValues: {
1159
+ plan: "",
1160
+ },
1161
+ })
1162
+
1163
+ function onSubmit(data: z.infer<typeof formSchema>) {
1164
+ toast("You submitted the following values:", {
1165
+ description: (
1166
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
1167
+ <code>{JSON.stringify(data, null, 2)}</code>
1168
+ </pre>
1169
+ ),
1170
+ position: "bottom-right",
1171
+ classNames: {
1172
+ content: "flex flex-col gap-2",
1173
+ },
1174
+ style: {
1175
+ "--border-radius": "calc(var(--radius) + 4px)",
1176
+ } as React.CSSProperties,
1177
+ })
1178
+ }
1179
+
1180
+ return (
1181
+ <Card className="w-full sm:max-w-md">
1182
+ <CardHeader>
1183
+ <CardTitle>Subscription Plan</CardTitle>
1184
+ <CardDescription>
1185
+ See pricing and features for each plan.
1186
+ </CardDescription>
1187
+ </CardHeader>
1188
+ <CardContent>
1189
+ <form id="form-rhf-radiogroup" onSubmit={form.handleSubmit(onSubmit)}>
1190
+ <FieldGroup>
1191
+ <Controller
1192
+ name="plan"
1193
+ control={form.control}
1194
+ render={({ field, fieldState }) => (
1195
+ <FieldSet data-invalid={fieldState.invalid}>
1196
+ <FieldLegend>Plan</FieldLegend>
1197
+ <FieldDescription>
1198
+ You can upgrade or downgrade your plan at any time.
1199
+ </FieldDescription>
1200
+ <RadioGroup
1201
+ name={field.name}
1202
+ value={field.value}
1203
+ onValueChange={field.onChange}
1204
+ aria-invalid={fieldState.invalid}
1205
+ >
1206
+ {plans.map((plan) => (
1207
+ <FieldLabel
1208
+ key={plan.id}
1209
+ htmlFor={`form-rhf-radiogroup-${plan.id}`}
1210
+ >
1211
+ <Field
1212
+ orientation="horizontal"
1213
+ data-invalid={fieldState.invalid}
1214
+ >
1215
+ <FieldContent>
1216
+ <FieldTitle>{plan.title}</FieldTitle>
1217
+ <FieldDescription>
1218
+ {plan.description}
1219
+ </FieldDescription>
1220
+ </FieldContent>
1221
+ <RadioGroupItem
1222
+ value={plan.id}
1223
+ id={`form-rhf-radiogroup-${plan.id}`}
1224
+ aria-invalid={fieldState.invalid}
1225
+ />
1226
+ </Field>
1227
+ </FieldLabel>
1228
+ ))}
1229
+ </RadioGroup>
1230
+ {fieldState.invalid && (
1231
+ <FieldError errors={[fieldState.error]} />
1232
+ )}
1233
+ </FieldSet>
1234
+ )}
1235
+ />
1236
+ </FieldGroup>
1237
+ </form>
1238
+ </CardContent>
1239
+ <CardFooter>
1240
+ <Field orientation="horizontal">
1241
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
1242
+ Reset
1243
+ </Button>
1244
+ <Button type="submit" form="form-rhf-radiogroup">
1245
+ Save
1246
+ </Button>
1247
+ </Field>
1248
+ </CardFooter>
1249
+ </Card>
1250
+ )
1251
+ }
1252
+
1253
+ ```
1254
+
1255
+ ```tsx showLineNumbers title="form.tsx" {12-13,17,25,31}
1256
+ <Controller
1257
+ name="plan"
1258
+ control={form.control}
1259
+ render={({ field, fieldState }) => (
1260
+ <FieldSet>
1261
+ <FieldLegend>Plan</FieldLegend>
1262
+ <FieldDescription>
1263
+ You can upgrade or downgrade your plan at any time.
1264
+ </FieldDescription>
1265
+ <RadioGroup
1266
+ name={field.name}
1267
+ value={field.value}
1268
+ onValueChange={field.onChange}
1269
+ >
1270
+ {plans.map((plan) => (
1271
+ <FieldLabel key={plan.id} htmlFor={`form-rhf-radiogroup-${plan.id}`}>
1272
+ <Field orientation="horizontal" data-invalid={fieldState.invalid}>
1273
+ <FieldContent>
1274
+ <FieldTitle>{plan.title}</FieldTitle>
1275
+ <FieldDescription>{plan.description}</FieldDescription>
1276
+ </FieldContent>
1277
+ <RadioGroupItem
1278
+ value={plan.id}
1279
+ id={`form-rhf-radiogroup-${plan.id}`}
1280
+ aria-invalid={fieldState.invalid}
1281
+ />
1282
+ </Field>
1283
+ </FieldLabel>
1284
+ ))}
1285
+ </RadioGroup>
1286
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
1287
+ </FieldSet>
1288
+ )}
1289
+ />
1290
+ ```
1291
+
1292
+ ### Switch
1293
+
1294
+ - For switches, use `field.value` and `field.onChange` on the `<Switch />` component.
1295
+ - To show errors, add the `aria-invalid` prop to the `<Switch />` component and the `data-invalid` prop to the `<Field />` component.
1296
+
1297
+ ```tsx
1298
+ "use client"
1299
+
1300
+ import * as React from "react"
1301
+ import { zodResolver } from "@hookform/resolvers/zod"
1302
+ import { Controller, useForm } from "react-hook-form"
1303
+ import { toast } from "sonner"
1304
+ import * as z from "zod"
1305
+
1306
+ import { Button } from "@/components/ui/button"
1307
+ import {
1308
+ Card,
1309
+ CardContent,
1310
+ CardDescription,
1311
+ CardFooter,
1312
+ CardHeader,
1313
+ CardTitle,
1314
+ } from "@/components/ui/card"
1315
+ import {
1316
+ Field,
1317
+ FieldContent,
1318
+ FieldDescription,
1319
+ FieldError,
1320
+ FieldGroup,
1321
+ FieldLabel,
1322
+ } from "@/components/ui/field"
1323
+ import { Switch } from "@/components/ui/switch"
1324
+
1325
+ const formSchema = z.object({
1326
+ twoFactor: z.boolean().refine((val) => val === true, {
1327
+ message: "It is highly recommended to enable two-factor authentication.",
1328
+ }),
1329
+ })
1330
+
1331
+ export function FormRhfSwitch() {
1332
+ const form = useForm<z.infer<typeof formSchema>>({
1333
+ resolver: zodResolver(formSchema),
1334
+ defaultValues: {
1335
+ twoFactor: false,
1336
+ },
1337
+ })
1338
+
1339
+ function onSubmit(data: z.infer<typeof formSchema>) {
1340
+ toast("You submitted the following values:", {
1341
+ description: (
1342
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
1343
+ <code>{JSON.stringify(data, null, 2)}</code>
1344
+ </pre>
1345
+ ),
1346
+ position: "bottom-right",
1347
+ classNames: {
1348
+ content: "flex flex-col gap-2",
1349
+ },
1350
+ style: {
1351
+ "--border-radius": "calc(var(--radius) + 4px)",
1352
+ } as React.CSSProperties,
1353
+ })
1354
+ }
1355
+
1356
+ return (
1357
+ <Card className="w-full sm:max-w-md">
1358
+ <CardHeader>
1359
+ <CardTitle>Security Settings</CardTitle>
1360
+ <CardDescription>
1361
+ Manage your account security preferences.
1362
+ </CardDescription>
1363
+ </CardHeader>
1364
+ <CardContent>
1365
+ <form id="form-rhf-switch" onSubmit={form.handleSubmit(onSubmit)}>
1366
+ <FieldGroup>
1367
+ <Controller
1368
+ name="twoFactor"
1369
+ control={form.control}
1370
+ render={({ field, fieldState }) => (
1371
+ <Field
1372
+ orientation="horizontal"
1373
+ data-invalid={fieldState.invalid}
1374
+ >
1375
+ <FieldContent>
1376
+ <FieldLabel htmlFor="form-rhf-switch-twoFactor">
1377
+ Multi-factor authentication
1378
+ </FieldLabel>
1379
+ <FieldDescription>
1380
+ Enable multi-factor authentication to secure your account.
1381
+ </FieldDescription>
1382
+ {fieldState.invalid && (
1383
+ <FieldError errors={[fieldState.error]} />
1384
+ )}
1385
+ </FieldContent>
1386
+ <Switch
1387
+ id="form-rhf-switch-twoFactor"
1388
+ name={field.name}
1389
+ checked={field.value}
1390
+ onCheckedChange={field.onChange}
1391
+ aria-invalid={fieldState.invalid}
1392
+ />
1393
+ </Field>
1394
+ )}
1395
+ />
1396
+ </FieldGroup>
1397
+ </form>
1398
+ </CardContent>
1399
+ <CardFooter>
1400
+ <Field orientation="horizontal">
1401
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
1402
+ Reset
1403
+ </Button>
1404
+ <Button type="submit" form="form-rhf-switch">
1405
+ Save
1406
+ </Button>
1407
+ </Field>
1408
+ </CardFooter>
1409
+ </Card>
1410
+ )
1411
+ }
1412
+
1413
+ ```
1414
+
1415
+ ```tsx showLineNumbers title="form.tsx" {5,13,18-19}
1416
+ <Controller
1417
+ name="twoFactor"
1418
+ control={form.control}
1419
+ render={({ field, fieldState }) => (
1420
+ <Field orientation="horizontal" data-invalid={fieldState.invalid}>
1421
+ <FieldContent>
1422
+ <FieldLabel htmlFor="form-rhf-switch-twoFactor">
1423
+ Multi-factor authentication
1424
+ </FieldLabel>
1425
+ <FieldDescription>
1426
+ Enable multi-factor authentication to secure your account.
1427
+ </FieldDescription>
1428
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
1429
+ </FieldContent>
1430
+ <Switch
1431
+ id="form-rhf-switch-twoFactor"
1432
+ name={field.name}
1433
+ checked={field.value}
1434
+ onCheckedChange={field.onChange}
1435
+ aria-invalid={fieldState.invalid}
1436
+ />
1437
+ </Field>
1438
+ )}
1439
+ />
1440
+ ```
1441
+
1442
+ ### Complex Forms
1443
+
1444
+ Here is an example of a more complex form with multiple fields and validation.
1445
+
1446
+ ```tsx
1447
+ "use client"
1448
+
1449
+ import * as React from "react"
1450
+ import { zodResolver } from "@hookform/resolvers/zod"
1451
+ import { Controller, useForm } from "react-hook-form"
1452
+ import { toast } from "sonner"
1453
+ import * as z from "zod"
1454
+
1455
+ import { Button } from "@/components/ui/button"
1456
+ import {
1457
+ Card,
1458
+ CardContent,
1459
+ CardDescription,
1460
+ CardFooter,
1461
+ CardHeader,
1462
+ CardTitle,
1463
+ } from "@/components/ui/card"
1464
+ import { Checkbox } from "@/components/ui/checkbox"
1465
+ import {
1466
+ Field,
1467
+ FieldContent,
1468
+ FieldDescription,
1469
+ FieldError,
1470
+ FieldGroup,
1471
+ FieldLabel,
1472
+ FieldLegend,
1473
+ FieldSeparator,
1474
+ FieldSet,
1475
+ FieldTitle,
1476
+ } from "@/components/ui/field"
1477
+ import {
1478
+ RadioGroup,
1479
+ RadioGroupItem,
1480
+ } from "@/components/ui/radio-group"
1481
+ import {
1482
+ Select,
1483
+ SelectContent,
1484
+ SelectItem,
1485
+ SelectTrigger,
1486
+ SelectValue,
1487
+ } from "@/components/ui/select"
1488
+ import { Switch } from "@/components/ui/switch"
1489
+
1490
+ const addons = [
1491
+ {
1492
+ id: "analytics",
1493
+ title: "Analytics",
1494
+ description: "Advanced analytics and reporting",
1495
+ },
1496
+ {
1497
+ id: "backup",
1498
+ title: "Backup",
1499
+ description: "Automated daily backups",
1500
+ },
1501
+ {
1502
+ id: "support",
1503
+ title: "Priority Support",
1504
+ description: "24/7 premium customer support",
1505
+ },
1506
+ ] as const
1507
+
1508
+ const formSchema = z.object({
1509
+ plan: z
1510
+ .string({
1511
+ required_error: "Please select a subscription plan",
1512
+ })
1513
+ .min(1, "Please select a subscription plan")
1514
+ .refine((value) => value === "basic" || value === "pro", {
1515
+ message: "Invalid plan selection. Please choose Basic or Pro",
1516
+ }),
1517
+ billingPeriod: z
1518
+ .string({
1519
+ required_error: "Please select a billing period",
1520
+ })
1521
+ .min(1, "Please select a billing period"),
1522
+ addons: z
1523
+ .array(z.string())
1524
+ .min(1, "Please select at least one add-on")
1525
+ .max(3, "You can select up to 3 add-ons")
1526
+ .refine(
1527
+ (value) => value.every((addon) => addons.some((a) => a.id === addon)),
1528
+ {
1529
+ message: "You selected an invalid add-on",
1530
+ }
1531
+ ),
1532
+ emailNotifications: z.boolean(),
1533
+ })
1534
+
1535
+ export function FormRhfComplex() {
1536
+ const form = useForm<z.infer<typeof formSchema>>({
1537
+ resolver: zodResolver(formSchema),
1538
+ defaultValues: {
1539
+ plan: "basic",
1540
+ billingPeriod: "",
1541
+ addons: [],
1542
+ emailNotifications: false,
1543
+ },
1544
+ })
1545
+
1546
+ function onSubmit(data: z.infer<typeof formSchema>) {
1547
+ toast("You submitted the following values:", {
1548
+ description: (
1549
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
1550
+ <code>{JSON.stringify(data, null, 2)}</code>
1551
+ </pre>
1552
+ ),
1553
+ position: "bottom-right",
1554
+ classNames: {
1555
+ content: "flex flex-col gap-2",
1556
+ },
1557
+ style: {
1558
+ "--border-radius": "calc(var(--radius) + 4px)",
1559
+ } as React.CSSProperties,
1560
+ })
1561
+ }
1562
+
1563
+ return (
1564
+ <Card className="w-full max-w-sm">
1565
+ <CardHeader className="border-b">
1566
+ <CardTitle>You&apos;re almost there!</CardTitle>
1567
+ <CardDescription>
1568
+ Choose your subscription plan and billing period.
1569
+ </CardDescription>
1570
+ </CardHeader>
1571
+ <CardContent>
1572
+ <form id="form-rhf-complex" onSubmit={form.handleSubmit(onSubmit)}>
1573
+ <FieldGroup>
1574
+ <Controller
1575
+ name="plan"
1576
+ control={form.control}
1577
+ render={({ field, fieldState }) => {
1578
+ const isInvalid = fieldState.invalid
1579
+ return (
1580
+ <FieldSet data-invalid={isInvalid}>
1581
+ <FieldLegend variant="label">Subscription Plan</FieldLegend>
1582
+ <FieldDescription>
1583
+ Choose your subscription plan.
1584
+ </FieldDescription>
1585
+ <RadioGroup
1586
+ name={field.name}
1587
+ value={field.value}
1588
+ onValueChange={field.onChange}
1589
+ aria-invalid={isInvalid}
1590
+ >
1591
+ <FieldLabel htmlFor="form-rhf-complex-basic">
1592
+ <Field orientation="horizontal">
1593
+ <FieldContent>
1594
+ <FieldTitle>Basic</FieldTitle>
1595
+ <FieldDescription>
1596
+ For individuals and small teams
1597
+ </FieldDescription>
1598
+ </FieldContent>
1599
+ <RadioGroupItem
1600
+ value="basic"
1601
+ id="form-rhf-complex-basic"
1602
+ />
1603
+ </Field>
1604
+ </FieldLabel>
1605
+ <FieldLabel htmlFor="form-rhf-complex-pro">
1606
+ <Field orientation="horizontal">
1607
+ <FieldContent>
1608
+ <FieldTitle>Pro</FieldTitle>
1609
+ <FieldDescription>
1610
+ For businesses with higher demands
1611
+ </FieldDescription>
1612
+ </FieldContent>
1613
+ <RadioGroupItem
1614
+ value="pro"
1615
+ id="form-rhf-complex-pro"
1616
+ />
1617
+ </Field>
1618
+ </FieldLabel>
1619
+ </RadioGroup>
1620
+ {isInvalid && <FieldError errors={[fieldState.error]} />}
1621
+ </FieldSet>
1622
+ )
1623
+ }}
1624
+ />
1625
+ <FieldSeparator />
1626
+ <Controller
1627
+ name="billingPeriod"
1628
+ control={form.control}
1629
+ render={({ field, fieldState }) => (
1630
+ <Field data-invalid={fieldState.invalid}>
1631
+ <FieldLabel htmlFor="form-rhf-complex-billingPeriod">
1632
+ Billing Period
1633
+ </FieldLabel>
1634
+ <Select
1635
+ name={field.name}
1636
+ value={field.value}
1637
+ onValueChange={field.onChange}
1638
+ >
1639
+ <SelectTrigger
1640
+ id="form-rhf-complex-billingPeriod"
1641
+ aria-invalid={fieldState.invalid}
1642
+ >
1643
+ <SelectValue placeholder="Select" />
1644
+ </SelectTrigger>
1645
+ <SelectContent>
1646
+ <SelectItem value="monthly">Monthly</SelectItem>
1647
+ <SelectItem value="yearly">Yearly</SelectItem>
1648
+ </SelectContent>
1649
+ </Select>
1650
+ <FieldDescription>
1651
+ Choose how often you want to be billed.
1652
+ </FieldDescription>
1653
+ {fieldState.invalid && (
1654
+ <FieldError errors={[fieldState.error]} />
1655
+ )}
1656
+ </Field>
1657
+ )}
1658
+ />
1659
+ <FieldSeparator />
1660
+ <Controller
1661
+ name="addons"
1662
+ control={form.control}
1663
+ render={({ field, fieldState }) => (
1664
+ <FieldSet>
1665
+ <FieldLegend>Add-ons</FieldLegend>
1666
+ <FieldDescription>
1667
+ Select additional features you&apos;d like to include.
1668
+ </FieldDescription>
1669
+ <FieldGroup data-slot="checkbox-group">
1670
+ {addons.map((addon) => (
1671
+ <Field
1672
+ key={addon.id}
1673
+ orientation="horizontal"
1674
+ data-invalid={fieldState.invalid}
1675
+ >
1676
+ <Checkbox
1677
+ id={`form-rhf-complex-${addon.id}`}
1678
+ name={field.name}
1679
+ aria-invalid={fieldState.invalid}
1680
+ checked={field.value.includes(addon.id)}
1681
+ onCheckedChange={(checked) => {
1682
+ const newValue = checked
1683
+ ? [...field.value, addon.id]
1684
+ : field.value.filter(
1685
+ (value) => value !== addon.id
1686
+ )
1687
+ field.onChange(newValue)
1688
+ field.onBlur()
1689
+ }}
1690
+ />
1691
+ <FieldContent>
1692
+ <FieldLabel htmlFor={`form-rhf-complex-${addon.id}`}>
1693
+ {addon.title}
1694
+ </FieldLabel>
1695
+ <FieldDescription>
1696
+ {addon.description}
1697
+ </FieldDescription>
1698
+ </FieldContent>
1699
+ </Field>
1700
+ ))}
1701
+ </FieldGroup>
1702
+ {fieldState.invalid && (
1703
+ <FieldError errors={[fieldState.error]} />
1704
+ )}
1705
+ </FieldSet>
1706
+ )}
1707
+ />
1708
+ <FieldSeparator />
1709
+ <Controller
1710
+ name="emailNotifications"
1711
+ control={form.control}
1712
+ render={({ field, fieldState }) => (
1713
+ <Field
1714
+ orientation="horizontal"
1715
+ data-invalid={fieldState.invalid}
1716
+ >
1717
+ <FieldContent>
1718
+ <FieldLabel htmlFor="form-rhf-complex-emailNotifications">
1719
+ Email Notifications
1720
+ </FieldLabel>
1721
+ <FieldDescription>
1722
+ Receive email updates about your subscription
1723
+ </FieldDescription>
1724
+ </FieldContent>
1725
+ <Switch
1726
+ id="form-rhf-complex-emailNotifications"
1727
+ name={field.name}
1728
+ checked={field.value}
1729
+ onCheckedChange={field.onChange}
1730
+ aria-invalid={fieldState.invalid}
1731
+ />
1732
+ {fieldState.invalid && (
1733
+ <FieldError errors={[fieldState.error]} />
1734
+ )}
1735
+ </Field>
1736
+ )}
1737
+ />
1738
+ </FieldGroup>
1739
+ </form>
1740
+ </CardContent>
1741
+ <CardFooter className="border-t">
1742
+ <Field>
1743
+ <Button type="submit" form="form-rhf-complex">
1744
+ Save Preferences
1745
+ </Button>
1746
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
1747
+ Reset
1748
+ </Button>
1749
+ </Field>
1750
+ </CardFooter>
1751
+ </Card>
1752
+ )
1753
+ }
1754
+
1755
+ ```
1756
+
1757
+ ## Resetting the Form
1758
+
1759
+ Use `form.reset()` to reset the form to its default values.
1760
+
1761
+ ```tsx showLineNumbers
1762
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
1763
+ Reset
1764
+ </Button>
1765
+ ```
1766
+
1767
+ ## Array Fields
1768
+
1769
+ React Hook Form provides a `useFieldArray` hook for managing dynamic array fields. This is useful when you need to add or remove fields dynamically.
1770
+
1771
+ ```tsx
1772
+ "use client"
1773
+
1774
+ import * as React from "react"
1775
+ import { zodResolver } from "@hookform/resolvers/zod"
1776
+ import { XIcon } from "lucide-react"
1777
+ import { Controller, useFieldArray, useForm } from "react-hook-form"
1778
+ import { toast } from "sonner"
1779
+ import * as z from "zod"
1780
+
1781
+ import { Button } from "@/components/ui/button"
1782
+ import {
1783
+ Card,
1784
+ CardContent,
1785
+ CardDescription,
1786
+ CardFooter,
1787
+ CardHeader,
1788
+ CardTitle,
1789
+ } from "@/components/ui/card"
1790
+ import {
1791
+ Field,
1792
+ FieldContent,
1793
+ FieldDescription,
1794
+ FieldError,
1795
+ FieldGroup,
1796
+ FieldLegend,
1797
+ FieldSet,
1798
+ } from "@/components/ui/field"
1799
+ import {
1800
+ InputGroup,
1801
+ InputGroupAddon,
1802
+ InputGroupButton,
1803
+ InputGroupInput,
1804
+ } from "@/components/ui/input-group"
1805
+
1806
+ const formSchema = z.object({
1807
+ emails: z
1808
+ .array(
1809
+ z.object({
1810
+ address: z.string().email("Enter a valid email address."),
1811
+ })
1812
+ )
1813
+ .min(1, "Add at least one email address.")
1814
+ .max(5, "You can add up to 5 email addresses."),
1815
+ })
1816
+
1817
+ export function FormRhfArray() {
1818
+ const form = useForm<z.infer<typeof formSchema>>({
1819
+ resolver: zodResolver(formSchema),
1820
+ defaultValues: {
1821
+ emails: [{ address: "" }, { address: "" }],
1822
+ },
1823
+ })
1824
+
1825
+ const { fields, append, remove } = useFieldArray({
1826
+ control: form.control,
1827
+ name: "emails",
1828
+ })
1829
+
1830
+ function onSubmit(data: z.infer<typeof formSchema>) {
1831
+ toast("You submitted the following values:", {
1832
+ description: (
1833
+ <pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
1834
+ <code>{JSON.stringify(data, null, 2)}</code>
1835
+ </pre>
1836
+ ),
1837
+ position: "bottom-right",
1838
+ classNames: {
1839
+ content: "flex flex-col gap-2",
1840
+ },
1841
+ style: {
1842
+ "--border-radius": "calc(var(--radius) + 4px)",
1843
+ } as React.CSSProperties,
1844
+ })
1845
+ }
1846
+
1847
+ return (
1848
+ <Card className="w-full sm:max-w-md">
1849
+ <CardHeader className="border-b">
1850
+ <CardTitle>Contact Emails</CardTitle>
1851
+ <CardDescription>Manage your contact email addresses.</CardDescription>
1852
+ </CardHeader>
1853
+ <CardContent>
1854
+ <form id="form-rhf-array" onSubmit={form.handleSubmit(onSubmit)}>
1855
+ <FieldSet className="gap-4">
1856
+ <FieldLegend variant="label">Email Addresses</FieldLegend>
1857
+ <FieldDescription>
1858
+ Add up to 5 email addresses where we can contact you.
1859
+ </FieldDescription>
1860
+ <FieldGroup className="gap-4">
1861
+ {fields.map((field, index) => (
1862
+ <Controller
1863
+ key={field.id}
1864
+ name={`emails.${index}.address`}
1865
+ control={form.control}
1866
+ render={({ field: controllerField, fieldState }) => (
1867
+ <Field
1868
+ orientation="horizontal"
1869
+ data-invalid={fieldState.invalid}
1870
+ >
1871
+ <FieldContent>
1872
+ <InputGroup>
1873
+ <InputGroupInput
1874
+ {...controllerField}
1875
+ id={`form-rhf-array-email-${index}`}
1876
+ aria-invalid={fieldState.invalid}
1877
+ placeholder="name@example.com"
1878
+ type="email"
1879
+ autoComplete="email"
1880
+ />
1881
+ {fields.length > 1 && (
1882
+ <InputGroupAddon align="inline-end">
1883
+ <InputGroupButton
1884
+ type="button"
1885
+ variant="ghost"
1886
+ size="icon-xs"
1887
+ onClick={() => remove(index)}
1888
+ aria-label={`Remove email ${index + 1}`}
1889
+ >
1890
+ <XIcon />
1891
+ </InputGroupButton>
1892
+ </InputGroupAddon>
1893
+ )}
1894
+ </InputGroup>
1895
+ {fieldState.invalid && (
1896
+ <FieldError errors={[fieldState.error]} />
1897
+ )}
1898
+ </FieldContent>
1899
+ </Field>
1900
+ )}
1901
+ />
1902
+ ))}
1903
+ <Button
1904
+ type="button"
1905
+ variant="outline"
1906
+ size="sm"
1907
+ onClick={() => append({ address: "" })}
1908
+ disabled={fields.length >= 5}
1909
+ >
1910
+ Add Email Address
1911
+ </Button>
1912
+ </FieldGroup>
1913
+ {form.formState.errors.emails?.root && (
1914
+ <FieldError errors={[form.formState.errors.emails.root]} />
1915
+ )}
1916
+ </FieldSet>
1917
+ </form>
1918
+ </CardContent>
1919
+ <CardFooter className="border-t">
1920
+ <Field orientation="horizontal">
1921
+ <Button type="button" variant="outline" onClick={() => form.reset()}>
1922
+ Reset
1923
+ </Button>
1924
+ <Button type="submit" form="form-rhf-array">
1925
+ Save
1926
+ </Button>
1927
+ </Field>
1928
+ </CardFooter>
1929
+ </Card>
1930
+ )
1931
+ }
1932
+
1933
+ ```
1934
+
1935
+ ### Using useFieldArray
1936
+
1937
+ Use the `useFieldArray` hook to manage array fields. It provides `fields`, `append`, and `remove` methods.
1938
+
1939
+ ```tsx showLineNumbers title="form.tsx" {8-11}
1940
+ import { useFieldArray, useForm } from "react-hook-form"
1941
+
1942
+ export function ExampleForm() {
1943
+ const form = useForm({
1944
+ // ... form config
1945
+ })
1946
+
1947
+ const { fields, append, remove } = useFieldArray({
1948
+ control: form.control,
1949
+ name: "emails",
1950
+ })
1951
+ }
1952
+ ```
1953
+
1954
+ ### Array Field Structure
1955
+
1956
+ Wrap your array fields in a `<FieldSet />` with a `<FieldLegend />` and `<FieldDescription />`.
1957
+
1958
+ ```tsx showLineNumbers title="form.tsx"
1959
+ <FieldSet className="gap-4">
1960
+ <FieldLegend variant="label">Email Addresses</FieldLegend>
1961
+ <FieldDescription>
1962
+ Add up to 5 email addresses where we can contact you.
1963
+ </FieldDescription>
1964
+ <FieldGroup className="gap-4">{/* Array items go here */}</FieldGroup>
1965
+ </FieldSet>
1966
+ ```
1967
+
1968
+ ### Controller Pattern for Array Items
1969
+
1970
+ Map over the `fields` array and use `<Controller />` for each item. **Make sure to use `field.id` as the key**.
1971
+
1972
+ ```tsx showLineNumbers title="form.tsx"
1973
+ {
1974
+ fields.map((field, index) => (
1975
+ <Controller
1976
+ key={field.id}
1977
+ name={`emails.${index}.address`}
1978
+ control={form.control}
1979
+ render={({ field: controllerField, fieldState }) => (
1980
+ <Field orientation="horizontal" data-invalid={fieldState.invalid}>
1981
+ <FieldContent>
1982
+ <InputGroup>
1983
+ <InputGroupInput
1984
+ {...controllerField}
1985
+ id={`form-rhf-array-email-${index}`}
1986
+ aria-invalid={fieldState.invalid}
1987
+ placeholder="name@example.com"
1988
+ type="email"
1989
+ autoComplete="email"
1990
+ />
1991
+ {/* Remove button */}
1992
+ </InputGroup>
1993
+ {fieldState.invalid && <FieldError errors={[fieldState.error]} />}
1994
+ </FieldContent>
1995
+ </Field>
1996
+ )}
1997
+ />
1998
+ ))
1999
+ }
2000
+ ```
2001
+
2002
+ ### Adding Items
2003
+
2004
+ Use the `append` method to add new items to the array.
2005
+
2006
+ ```tsx showLineNumbers title="form.tsx"
2007
+ <Button
2008
+ type="button"
2009
+ variant="outline"
2010
+ size="sm"
2011
+ onClick={() => append({ address: "" })}
2012
+ disabled={fields.length >= 5}
2013
+ >
2014
+ Add Email Address
2015
+ </Button>
2016
+ ```
2017
+
2018
+ ### Removing Items
2019
+
2020
+ Use the `remove` method to remove items from the array. Add the remove button conditionally.
2021
+
2022
+ ```tsx showLineNumbers title="form.tsx"
2023
+ {
2024
+ fields.length > 1 && (
2025
+ <InputGroupAddon align="inline-end">
2026
+ <InputGroupButton
2027
+ type="button"
2028
+ variant="ghost"
2029
+ size="icon-xs"
2030
+ onClick={() => remove(index)}
2031
+ aria-label={`Remove email ${index + 1}`}
2032
+ >
2033
+ <XIcon />
2034
+ </InputGroupButton>
2035
+ </InputGroupAddon>
2036
+ )
2037
+ }
2038
+ ```
2039
+
2040
+ ### Array Validation
2041
+
2042
+ Use Zod's `array` method to validate array fields.
2043
+
2044
+ ```tsx showLineNumbers title="form.tsx"
2045
+ const formSchema = z.object({
2046
+ emails: z
2047
+ .array(
2048
+ z.object({
2049
+ address: z.string().email("Enter a valid email address."),
2050
+ })
2051
+ )
2052
+ .min(1, "Add at least one email address.")
2053
+ .max(5, "You can add up to 5 email addresses."),
2054
+ })
2055
+ ```