moi-computer 0.11.0 → 0.11.1-dev.be1ed10

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 (362) hide show
  1. package/README.md +2 -2
  2. package/client/AGENTS.md +2 -2
  3. package/client/app/AppRouter.tsx +2 -2
  4. package/client/app/routes/WorkspaceRoute.tsx +7 -9
  5. package/client/app/shell/SidebarLayout.tsx +18 -15
  6. package/client/components/shared/BottomPanel.tsx +26 -14
  7. package/client/components/shared/PanelHeader.tsx +1 -1
  8. package/client/components/shared/ReorderableList.tsx +7 -2
  9. package/client/components/shared/WorkspaceIcon.tsx +92 -0
  10. package/client/components/ui/alert-dialog.tsx +1 -0
  11. package/client/components/ui/button.tsx +1 -53
  12. package/client/components/ui/checkbox.tsx +1 -0
  13. package/client/components/ui/collapsible.tsx +1 -15
  14. package/client/components/ui/dialog.tsx +1 -58
  15. package/client/components/ui/dropdown-menu.tsx +1 -254
  16. package/client/components/ui/hover-card.tsx +1 -44
  17. package/client/components/ui/inline-input.tsx +84 -0
  18. package/client/components/ui/input.tsx +1 -21
  19. package/client/components/ui/popover.tsx +1 -88
  20. package/client/components/ui/resizable.tsx +1 -40
  21. package/client/components/ui/skeleton.tsx +1 -13
  22. package/client/components/ui/slider.tsx +1 -70
  23. package/client/components/ui/spinner.tsx +1 -18
  24. package/client/components/ui/switch.tsx +1 -23
  25. package/client/components/ui/tabs.tsx +1 -0
  26. package/client/components/ui/textarea.tsx +1 -18
  27. package/client/components/ui/toast.tsx +2 -2
  28. package/client/components/ui/tooltip.tsx +1 -51
  29. package/client/features/applets/AppletMount.tsx +1 -1
  30. package/client/features/applets/applet-cache.ts +3 -3
  31. package/client/features/applets/applet-runtime.ts +147 -108
  32. package/client/features/applets/applet-styles.ts +2 -2
  33. package/client/features/applets/applet-thumbnail.ts +6 -8
  34. package/client/features/applets/useApplet.ts +10 -9
  35. package/client/features/chat/ChatPanel.tsx +24 -15
  36. package/client/features/chat/ChatPopup.tsx +9 -5
  37. package/client/features/chat/applet-chat-intents.ts +170 -0
  38. package/client/features/chat/chat-send.ts +116 -64
  39. package/client/features/chat/chat-store.ts +51 -62
  40. package/client/features/chat/composer/ChatComposer.tsx +43 -128
  41. package/client/features/chat/composer/ModelPicker.tsx +47 -60
  42. package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
  43. package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
  44. package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
  45. package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
  46. package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
  47. package/client/features/chat/composer/attachments/types.ts +25 -0
  48. package/client/features/chat/composer/attachments/uploads.ts +26 -0
  49. package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
  50. package/client/features/chat/composer/model-order.ts +15 -0
  51. package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
  52. package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
  53. package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
  54. package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
  55. package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
  56. package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
  57. package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
  58. package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
  59. package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
  60. package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
  61. package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
  62. package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
  63. package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
  64. package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
  65. package/client/features/chat/sessions/session-view.ts +53 -0
  66. package/client/features/chat/useChat.ts +42 -24
  67. package/client/features/dev/ChatStatesPage.tsx +8 -7
  68. package/client/features/dev/DevIndexPage.tsx +5 -0
  69. package/client/features/dev/DevRoutes.tsx +2 -0
  70. package/client/features/dev/HarnessDebugPage.tsx +11 -8
  71. package/client/features/dev/ToolCallsPage.tsx +1 -1
  72. package/client/features/dev/UiComponentPreviews.tsx +855 -0
  73. package/client/features/dev/UiComponentsPage.tsx +60 -0
  74. package/client/features/dev/chat-states-fixtures.ts +13 -2
  75. package/client/features/drawings/useChatAnnotation.ts +17 -17
  76. package/client/features/drawings/useDrawingLayer.ts +7 -9
  77. package/client/features/drawings/useViewBuilderSketch.ts +18 -15
  78. package/client/features/home/HomePage.tsx +8 -7
  79. package/client/features/home/WorkspacePreview.tsx +2 -2
  80. package/client/features/home/workspace-presentation.tsx +1 -11
  81. package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
  82. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
  83. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
  84. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
  85. package/client/features/overview/HiddenPanel.tsx +109 -0
  86. package/client/features/overview/Overview.tsx +302 -0
  87. package/client/features/overview/WidgetCanvas.tsx +164 -0
  88. package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
  89. package/client/features/overview/WorkspaceName.tsx +60 -0
  90. package/client/features/overview/api.ts +30 -0
  91. package/client/features/overview/default/ViewsWidget.tsx +252 -0
  92. package/client/features/overview/default/registry.tsx +36 -0
  93. package/client/features/{widgets → overview}/grid.ts +36 -0
  94. package/client/features/overview/useGridReconcile.ts +94 -0
  95. package/client/features/scratchpad/Scratchpad.tsx +7 -8
  96. package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
  97. package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
  98. package/client/features/settings/GeneralSettings.tsx +55 -58
  99. package/client/features/settings/SettingsLayout.tsx +2 -2
  100. package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
  101. package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
  102. package/client/features/settings/api.ts +48 -24
  103. package/client/features/views/ViewBuilder.tsx +5 -4
  104. package/client/features/views/ViewManager.tsx +25 -22
  105. package/client/features/views/api.ts +36 -2
  106. package/client/features/views/useViewBuilderActions.ts +8 -5
  107. package/client/features/views/useViewBuilderDrafts.ts +23 -21
  108. package/client/features/views/view-presentation.ts +13 -0
  109. package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
  110. package/client/features/workspace/UnavailablePage.tsx +21 -0
  111. package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
  112. package/client/features/workspace/WorkspaceScreen.tsx +210 -162
  113. package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
  114. package/client/features/workspace/WorkspaceTabs.tsx +2 -0
  115. package/client/features/workspace/api.ts +2 -30
  116. package/client/features/workspace/moi-context.ts +8 -9
  117. package/client/features/workspace/tab-resolution.ts +10 -33
  118. package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
  119. package/client/index.css +23 -30
  120. package/client/lib/app-icon-registry.ts +2 -0
  121. package/client/lib/use-latest-ref.ts +11 -0
  122. package/client/main.tsx +1 -1
  123. package/client/runtime/useWorkspaceEvents.ts +59 -14
  124. package/client/theme.css +5 -5
  125. package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
  126. package/dist/chunk-691pqsj6.js +2 -0
  127. package/dist/chunk-7a5nm4k9.css +1 -0
  128. package/dist/chunk-amb8y04y.js +1 -0
  129. package/dist/chunk-cf3pgy7j.js +546 -0
  130. package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
  131. package/dist/chunk-mzrgr577.js +5 -0
  132. package/dist/chunk-nf2wkvf9.js +14 -0
  133. package/dist/chunk-q6a0g26x.js +1 -0
  134. package/dist/chunk-twgdemkc.js +74 -0
  135. package/dist/chunk-x90k0f5c.js +2 -0
  136. package/dist/chunk-yq00csvd.js +2 -0
  137. package/dist/index.html +1 -1
  138. package/lib/app-icons.ts +1 -0
  139. package/lib/applet-selector.ts +24 -0
  140. package/lib/chat-title.ts +6 -1
  141. package/lib/default-widgets.ts +32 -0
  142. package/lib/format.ts +67 -7
  143. package/lib/message-attachments.ts +40 -0
  144. package/lib/moi-attachments.ts +204 -0
  145. package/lib/moi-context.ts +20 -35
  146. package/lib/navigation.ts +84 -0
  147. package/lib/themes.ts +6 -6
  148. package/lib/types.ts +91 -34
  149. package/lib/workspace-icon.ts +20 -0
  150. package/lib/workspace-layout.ts +22 -2
  151. package/lib/workspace-tabs.ts +9 -33
  152. package/package.json +42 -32
  153. package/registry.json +656 -0
  154. package/server/AGENTS.md +2 -0
  155. package/server/agent.ts +1 -1
  156. package/server/api.ts +139 -66
  157. package/server/applet-typecheck.ts +95 -0
  158. package/server/applets/applet-css.ts +55 -0
  159. package/server/{bundler → applets}/build-applet.ts +13 -242
  160. package/server/applets/build-worker.ts +178 -0
  161. package/server/applets/config.ts +226 -0
  162. package/server/applets/dependencies.ts +206 -0
  163. package/server/{applets.ts → applets/index.ts} +44 -189
  164. package/server/applets/runtime/base.ts +4 -0
  165. package/server/applets/runtime/moi.ts +42 -0
  166. package/server/applets/runtime/rpc.ts +17 -0
  167. package/server/applets/view-source.ts +67 -0
  168. package/server/attachment-message.ts +95 -0
  169. package/server/cli-ui-components.ts +28 -33
  170. package/server/cli.ts +169 -108
  171. package/server/control.ts +63 -42
  172. package/server/data-dir.ts +1 -1
  173. package/server/harness/README.md +45 -50
  174. package/server/harness/acp/NOTES.md +426 -0
  175. package/server/harness/acp/adapter.ts +7 -21
  176. package/server/harness/acp/discovery.ts +27 -30
  177. package/server/harness/acp/model-state.ts +57 -0
  178. package/server/harness/acp/session.ts +49 -56
  179. package/server/harness/claude-code/NOTES.md +54 -13
  180. package/server/harness/claude-code/adapter.ts +8 -25
  181. package/server/harness/claude-code/cli.ts +40 -0
  182. package/server/harness/claude-code/index.ts +13 -5
  183. package/server/harness/claude-code/models.ts +72 -19
  184. package/server/harness/claude-code/session.ts +447 -343
  185. package/server/harness/claude-code/sessions.ts +9 -4
  186. package/server/harness/codex/NOTES.md +222 -350
  187. package/server/harness/codex/adapter.ts +102 -52
  188. package/server/harness/codex/auth.ts +1 -3
  189. package/server/harness/codex/client.ts +169 -249
  190. package/server/harness/codex/discovery.ts +9 -17
  191. package/server/harness/codex/index.ts +3 -1
  192. package/server/harness/codex/pagination.ts +24 -0
  193. package/server/harness/codex/permissions.ts +32 -8
  194. package/server/harness/codex/probe.ts +10 -13
  195. package/server/harness/codex/session.ts +567 -181
  196. package/server/harness/codex/transport.ts +184 -0
  197. package/server/harness/debug.ts +1 -1
  198. package/server/harness/hermes/NOTES.md +19 -1
  199. package/server/harness/hermes/discovery.ts +20 -0
  200. package/server/harness/hermes/index.ts +13 -0
  201. package/server/harness/hermes/models.ts +28 -8
  202. package/server/harness/openclaw/NOTES.md +1 -1
  203. package/server/harness/openclaw/adapter.ts +22 -4
  204. package/server/harness/openclaw/gateway.ts +5 -3
  205. package/server/harness/openclaw/session.ts +27 -27
  206. package/server/harness/types.ts +9 -5
  207. package/server/layout.ts +9 -14
  208. package/server/moi-scaffold.ts +22 -14
  209. package/server/navigation-relay.ts +110 -0
  210. package/server/preview.ts +3 -1
  211. package/server/registry.ts +71 -41
  212. package/server/scratchpad-executor.ts +79 -56
  213. package/server/scratchpad-shape-defaults.ts +82 -0
  214. package/server/selected-session.ts +24 -4
  215. package/server/skill-update.ts +5 -3
  216. package/server/skill-version.ts +4 -7
  217. package/server/skills-template.ts +48 -9
  218. package/server/tabs.ts +19 -33
  219. package/server/tldraw-package.d.ts +4 -0
  220. package/server/ui-components.ts +101 -434
  221. package/server/uploads.ts +0 -0
  222. package/server/view-builders.ts +20 -2
  223. package/server/views.ts +126 -6
  224. package/server/web.ts +46 -13
  225. package/server/widgets.ts +12 -5
  226. package/server/workspace-config.ts +13 -9
  227. package/server/workspace-env.ts +3 -2
  228. package/tsconfig.json +0 -1
  229. package/ui-components/accordion.tsx +71 -0
  230. package/ui-components/alert-dialog.tsx +165 -0
  231. package/ui-components/alert.tsx +68 -0
  232. package/ui-components/attachment.tsx +195 -0
  233. package/ui-components/avatar.tsx +90 -0
  234. package/ui-components/badge.tsx +49 -0
  235. package/ui-components/button-group.tsx +78 -0
  236. package/ui-components/button.tsx +55 -0
  237. package/ui-components/calendar.tsx +180 -0
  238. package/ui-components/card.tsx +84 -0
  239. package/ui-components/carousel.tsx +235 -0
  240. package/ui-components/chart.tsx +338 -0
  241. package/ui-components/checkbox.tsx +28 -0
  242. package/ui-components/collapsible.tsx +15 -0
  243. package/ui-components/combobox.tsx +267 -0
  244. package/ui-components/context-menu.tsx +244 -0
  245. package/ui-components/dialog.tsx +138 -0
  246. package/ui-components/docs/accordion.md +463 -0
  247. package/ui-components/docs/alert-dialog.md +481 -0
  248. package/ui-components/docs/alert.md +301 -0
  249. package/ui-components/docs/attachment.md +689 -0
  250. package/ui-components/docs/avatar.md +495 -0
  251. package/ui-components/docs/badge.md +258 -0
  252. package/ui-components/docs/button-group.md +879 -0
  253. package/ui-components/docs/button.md +26 -0
  254. package/ui-components/docs/calendar.md +862 -0
  255. package/ui-components/docs/card.md +265 -0
  256. package/ui-components/docs/carousel.md +627 -0
  257. package/ui-components/docs/chart.md +1256 -0
  258. package/ui-components/docs/checkbox.md +477 -0
  259. package/ui-components/docs/collapsible.md +446 -0
  260. package/ui-components/docs/combobox.md +1003 -0
  261. package/ui-components/docs/context-menu.md +860 -0
  262. package/ui-components/docs/data-table.md +1580 -0
  263. package/ui-components/docs/date-picker.md +614 -0
  264. package/ui-components/docs/dialog.md +414 -0
  265. package/ui-components/docs/drawer.md +51 -0
  266. package/ui-components/docs/dropdown-menu.md +1000 -0
  267. package/ui-components/docs/field.md +1192 -0
  268. package/ui-components/docs/hover-card.md +275 -0
  269. package/ui-components/docs/input-group.md +866 -0
  270. package/ui-components/docs/input.md +456 -0
  271. package/ui-components/docs/kbd.md +191 -0
  272. package/ui-components/docs/label.md +295 -0
  273. package/ui-components/docs/pagination.md +416 -0
  274. package/ui-components/docs/popover.md +348 -0
  275. package/ui-components/docs/progress.md +214 -0
  276. package/ui-components/docs/radio-group.md +389 -0
  277. package/ui-components/docs/resizable.md +265 -0
  278. package/ui-components/docs/select.md +616 -0
  279. package/ui-components/docs/separator.md +216 -0
  280. package/ui-components/docs/skeleton.md +205 -0
  281. package/ui-components/docs/slider.md +226 -0
  282. package/ui-components/docs/spinner.md +332 -0
  283. package/ui-components/docs/switch.md +236 -0
  284. package/ui-components/docs/table.md +551 -0
  285. package/ui-components/docs/tabs.md +379 -0
  286. package/ui-components/docs/textarea.md +187 -0
  287. package/ui-components/docs/toggle-group.md +370 -0
  288. package/ui-components/docs/toggle.md +91 -0
  289. package/ui-components/docs/tooltip.md +290 -0
  290. package/ui-components/drawer.tsx +213 -0
  291. package/ui-components/dropdown-menu.tsx +263 -0
  292. package/ui-components/field.tsx +224 -0
  293. package/ui-components/hover-card.tsx +46 -0
  294. package/ui-components/input-group.tsx +146 -0
  295. package/ui-components/input.tsx +20 -0
  296. package/ui-components/kbd.tsx +32 -0
  297. package/ui-components/label.tsx +17 -0
  298. package/ui-components/pagination.tsx +124 -0
  299. package/ui-components/popover.tsx +81 -0
  300. package/ui-components/progress.tsx +63 -0
  301. package/ui-components/radio-group.tsx +38 -0
  302. package/ui-components/resizable.tsx +40 -0
  303. package/ui-components/scoped-portal.tsx +31 -0
  304. package/ui-components/select.tsx +195 -0
  305. package/ui-components/separator.tsx +18 -0
  306. package/ui-components/skeleton.tsx +15 -0
  307. package/ui-components/slider.tsx +75 -0
  308. package/ui-components/spinner.tsx +20 -0
  309. package/ui-components/switch.tsx +27 -0
  310. package/ui-components/table.tsx +86 -0
  311. package/ui-components/tabs.tsx +75 -0
  312. package/ui-components/textarea.tsx +17 -0
  313. package/ui-components/toggle-group.tsx +85 -0
  314. package/ui-components/toggle.tsx +42 -0
  315. package/ui-components/tooltip.tsx +61 -0
  316. package/ui-components/utils.ts +8 -0
  317. package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
  318. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
  319. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
  320. package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
  321. package/client/features/chat/attachment-staging.ts +0 -153
  322. package/client/features/chat/uploads.ts +0 -18
  323. package/client/features/chat/useAppletChatMessage.ts +0 -68
  324. package/client/features/settings/IconPicker.tsx +0 -442
  325. package/client/features/settings/WorkspaceSettings.tsx +0 -92
  326. package/client/features/settings/render-icon.ts +0 -173
  327. package/client/features/widgets/HiddenPanel.tsx +0 -80
  328. package/client/features/widgets/WidgetGrid.tsx +0 -123
  329. package/client/features/widgets/Widgets.tsx +0 -264
  330. package/client/features/widgets/useGridReconcile.ts +0 -73
  331. package/dist/chunk-104m57qw.js +0 -2
  332. package/dist/chunk-59zf0m6n.js +0 -1
  333. package/dist/chunk-bj3akjs2.js +0 -1
  334. package/dist/chunk-c9pjqx9m.js +0 -14
  335. package/dist/chunk-j2w2vak4.js +0 -546
  336. package/dist/chunk-k2r9c95m.js +0 -10
  337. package/dist/chunk-kmbxhgwv.js +0 -1
  338. package/dist/chunk-p1yqa71k.js +0 -83
  339. package/dist/chunk-pcnahct1.js +0 -5
  340. package/dist/chunk-r5xrenjy.css +0 -1
  341. package/dist/chunk-tny85yt2.js +0 -2
  342. package/dist/chunk-v7wr1df4.js +0 -2
  343. package/server/bundler/applet-css.ts +0 -155
  344. /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
  345. /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
  346. /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
  347. /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
  348. /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
  349. /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
  350. /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
  351. /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
  352. /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
  353. /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
  354. /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
  355. /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
  356. /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
  357. /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
  358. /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
  359. /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
  360. /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
  361. /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
  362. /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
@@ -0,0 +1,1192 @@
1
+ ---
2
+ title: Field
3
+ description: Combine labels, controls, and help text to compose accessible form fields and grouped inputs.
4
+ base: base
5
+ component: true
6
+ ---
7
+
8
+ ```tsx
9
+ import { Button } from '@/components/ui/button'
10
+ import { Checkbox } from '@/components/ui/checkbox'
11
+ import {
12
+ Field,
13
+ FieldDescription,
14
+ FieldGroup,
15
+ FieldLabel,
16
+ FieldLegend,
17
+ FieldSeparator,
18
+ FieldSet
19
+ } from '@/components/ui/field'
20
+ import { Input } from '@/components/ui/input'
21
+ import {
22
+ Select,
23
+ SelectContent,
24
+ SelectGroup,
25
+ SelectItem,
26
+ SelectTrigger,
27
+ SelectValue
28
+ } from '@/components/ui/select'
29
+ import { Textarea } from '@/components/ui/textarea'
30
+
31
+ const months = [
32
+ { label: 'MM', value: null },
33
+ { label: '01', value: '01' },
34
+ { label: '02', value: '02' },
35
+ { label: '03', value: '03' },
36
+ { label: '04', value: '04' },
37
+ { label: '05', value: '05' },
38
+ { label: '06', value: '06' },
39
+ { label: '07', value: '07' },
40
+ { label: '08', value: '08' },
41
+ { label: '09', value: '09' },
42
+ { label: '10', value: '10' },
43
+ { label: '11', value: '11' },
44
+ { label: '12', value: '12' }
45
+ ]
46
+
47
+ const years = [
48
+ { label: 'YYYY', value: null },
49
+ { label: '2024', value: '2024' },
50
+ { label: '2025', value: '2025' },
51
+ { label: '2026', value: '2026' },
52
+ { label: '2027', value: '2027' },
53
+ { label: '2028', value: '2028' },
54
+ { label: '2029', value: '2029' }
55
+ ]
56
+
57
+ export function FieldDemo() {
58
+ return (
59
+ <div className="w-full max-w-md">
60
+ <form>
61
+ <FieldGroup>
62
+ <FieldSet>
63
+ <FieldLegend>Payment Method</FieldLegend>
64
+ <FieldDescription>All transactions are secure and encrypted</FieldDescription>
65
+ <FieldGroup>
66
+ <Field>
67
+ <FieldLabel htmlFor="checkout-7j9-card-name-43j">Name on Card</FieldLabel>
68
+ <Input id="checkout-7j9-card-name-43j" placeholder="Evil Rabbit" required />
69
+ </Field>
70
+ <Field>
71
+ <FieldLabel htmlFor="checkout-7j9-card-number-uw1">Card Number</FieldLabel>
72
+ <Input
73
+ id="checkout-7j9-card-number-uw1"
74
+ placeholder="1234 5678 9012 3456"
75
+ required
76
+ />
77
+ <FieldDescription>Enter your 16-digit card number</FieldDescription>
78
+ </Field>
79
+ <div className="grid grid-cols-3 gap-4">
80
+ <Field>
81
+ <FieldLabel htmlFor="checkout-exp-month-ts6">Month</FieldLabel>
82
+ <Select items={months}>
83
+ <SelectTrigger id="checkout-exp-month-ts6">
84
+ <SelectValue />
85
+ </SelectTrigger>
86
+ <SelectContent>
87
+ <SelectGroup>
88
+ {months.map(item => (
89
+ <SelectItem key={item.value} value={item.value}>
90
+ {item.label}
91
+ </SelectItem>
92
+ ))}
93
+ </SelectGroup>
94
+ </SelectContent>
95
+ </Select>
96
+ </Field>
97
+ <Field>
98
+ <FieldLabel htmlFor="checkout-7j9-exp-year-f59">Year</FieldLabel>
99
+ <Select items={years}>
100
+ <SelectTrigger id="checkout-7j9-exp-year-f59">
101
+ <SelectValue />
102
+ </SelectTrigger>
103
+ <SelectContent>
104
+ <SelectGroup>
105
+ {years.map(item => (
106
+ <SelectItem key={item.value} value={item.value}>
107
+ {item.label}
108
+ </SelectItem>
109
+ ))}
110
+ </SelectGroup>
111
+ </SelectContent>
112
+ </Select>
113
+ </Field>
114
+ <Field>
115
+ <FieldLabel htmlFor="checkout-7j9-cvv">CVV</FieldLabel>
116
+ <Input id="checkout-7j9-cvv" placeholder="123" required />
117
+ </Field>
118
+ </div>
119
+ </FieldGroup>
120
+ </FieldSet>
121
+ <FieldSeparator />
122
+ <FieldSet>
123
+ <FieldLegend>Billing Address</FieldLegend>
124
+ <FieldDescription>
125
+ The billing address associated with your payment method
126
+ </FieldDescription>
127
+ <FieldGroup>
128
+ <Field orientation="horizontal">
129
+ <Checkbox id="checkout-7j9-same-as-shipping-wgm" defaultChecked />
130
+ <FieldLabel htmlFor="checkout-7j9-same-as-shipping-wgm" className="font-normal">
131
+ Same as shipping address
132
+ </FieldLabel>
133
+ </Field>
134
+ </FieldGroup>
135
+ </FieldSet>
136
+ <FieldSet>
137
+ <FieldGroup>
138
+ <Field>
139
+ <FieldLabel htmlFor="checkout-7j9-optional-comments">Comments</FieldLabel>
140
+ <Textarea
141
+ id="checkout-7j9-optional-comments"
142
+ placeholder="Add any additional comments"
143
+ className="resize-none"
144
+ />
145
+ </Field>
146
+ </FieldGroup>
147
+ </FieldSet>
148
+ <Field orientation="horizontal">
149
+ <Button type="submit">Submit</Button>
150
+ <Button variant="outline" type="button">
151
+ Cancel
152
+ </Button>
153
+ </Field>
154
+ </FieldGroup>
155
+ </form>
156
+ </div>
157
+ )
158
+ }
159
+ ```
160
+
161
+ ## Installation
162
+
163
+ <CodeTabs>
164
+
165
+ <TabsList>
166
+ <TabsTrigger value="cli">Command</TabsTrigger>
167
+ <TabsTrigger value="manual">Manual</TabsTrigger>
168
+ </TabsList>
169
+ <TabsContent value="cli">
170
+
171
+ ```bash
172
+ moi ui-components add field
173
+ ```
174
+
175
+ </TabsContent>
176
+
177
+ <TabsContent value="manual">
178
+
179
+ <Steps className="mb-0 pt-2">
180
+
181
+ <Step>Copy and paste the following code into your project.</Step>
182
+
183
+ <ComponentSource
184
+ name="field"
185
+ title="components/ui/field.tsx"
186
+ styleName="base-nova"
187
+ />
188
+
189
+ <Step>Update the import paths to match your project setup.</Step>
190
+
191
+ </Steps>
192
+
193
+ </TabsContent>
194
+
195
+ </CodeTabs>
196
+
197
+ ## Usage
198
+
199
+ ```tsx showLineNumbers
200
+ import {
201
+ Field,
202
+ FieldContent,
203
+ FieldDescription,
204
+ FieldError,
205
+ FieldGroup,
206
+ FieldLabel,
207
+ FieldLegend,
208
+ FieldSeparator,
209
+ FieldSet,
210
+ FieldTitle
211
+ } from '@/components/ui/field'
212
+ ```
213
+
214
+ ```tsx showLineNumbers
215
+ <FieldSet>
216
+ <FieldLegend>Profile</FieldLegend>
217
+ <FieldDescription>This appears on invoices and emails.</FieldDescription>
218
+ <FieldGroup>
219
+ <Field>
220
+ <FieldLabel htmlFor="name">Full name</FieldLabel>
221
+ <Input id="name" autoComplete="off" placeholder="Evil Rabbit" />
222
+ <FieldDescription>This appears on invoices and emails.</FieldDescription>
223
+ </Field>
224
+ <Field>
225
+ <FieldLabel htmlFor="username">Username</FieldLabel>
226
+ <Input id="username" autoComplete="off" aria-invalid />
227
+ <FieldError>Choose another username.</FieldError>
228
+ </Field>
229
+ <Field orientation="horizontal">
230
+ <Switch id="newsletter" />
231
+ <FieldLabel htmlFor="newsletter">Subscribe to the newsletter</FieldLabel>
232
+ </Field>
233
+ </FieldGroup>
234
+ </FieldSet>
235
+ ```
236
+
237
+ ## Composition
238
+
239
+ ### Field
240
+
241
+ A single control with label, helper text, and validation.
242
+
243
+ ```text
244
+ Field
245
+ ├── FieldLabel
246
+ ├── Input / Textarea / Switch / Select
247
+ ├── FieldDescription
248
+ └── FieldError
249
+ ```
250
+
251
+ ### FieldGroup
252
+
253
+ Related fields in one group. Use `FieldSeparator` between sections when needed.
254
+
255
+ ```text
256
+ FieldGroup
257
+ ├── Field
258
+ │ ├── FieldLabel
259
+ │ ├── Input / Textarea / Switch / Select
260
+ │ ├── FieldDescription
261
+ │ └── FieldError
262
+ ├── FieldSeparator
263
+ └── Field
264
+ ├── FieldLabel
265
+ └── Input / Textarea / Switch / Select
266
+ ```
267
+
268
+ ### FieldSet
269
+
270
+ Semantic grouping with a legend and description, usually containing a `FieldGroup`.
271
+
272
+ ```text
273
+ FieldSet
274
+ ├── FieldLegend
275
+ ├── FieldDescription
276
+ └── FieldGroup
277
+ ├── Field
278
+ │ ├── FieldLabel
279
+ │ ├── Input / Textarea / Switch / Select
280
+ │ ├── FieldDescription
281
+ │ └── FieldError
282
+ └── Field
283
+ ├── FieldLabel
284
+ └── Input / Textarea / Switch / Select
285
+ ```
286
+
287
+ ## Anatomy
288
+
289
+ The `Field` family is designed for composing accessible forms. A typical field is structured as follows:
290
+
291
+ ```tsx showLineNumbers
292
+ <Field>
293
+ <FieldLabel htmlFor="input-id">Label</FieldLabel>
294
+ {/* Input, Select, Switch, etc. */}
295
+ <FieldDescription>Optional helper text.</FieldDescription>
296
+ <FieldError>Validation message.</FieldError>
297
+ </Field>
298
+ ```
299
+
300
+ - `Field` is the core wrapper for a single field.
301
+ - `FieldContent` is a flex column that groups label and description. Not required if you have no description.
302
+ - Wrap related fields with `FieldGroup`, and use `FieldSet` with `FieldLegend` for semantic grouping.
303
+
304
+ ## Form
305
+
306
+ See the [Form](/docs/forms) documentation for building forms with the `Field` component and [React Hook Form](/docs/forms/react-hook-form), [Tanstack Form](/docs/forms/tanstack-form), or [Formisch](/docs/forms/formisch).
307
+
308
+ ## Input
309
+
310
+ ```tsx
311
+ import { Field, FieldDescription, FieldGroup, FieldLabel, FieldSet } from '@/components/ui/field'
312
+ import { Input } from '@/components/ui/input'
313
+
314
+ export function FieldInput() {
315
+ return (
316
+ <FieldSet className="w-full max-w-xs">
317
+ <FieldGroup>
318
+ <Field>
319
+ <FieldLabel htmlFor="username">Username</FieldLabel>
320
+ <Input id="username" type="text" placeholder="Max Leiter" />
321
+ <FieldDescription>Choose a unique username for your account.</FieldDescription>
322
+ </Field>
323
+ <Field>
324
+ <FieldLabel htmlFor="password">Password</FieldLabel>
325
+ <FieldDescription>Must be at least 8 characters long.</FieldDescription>
326
+ <Input id="password" type="password" placeholder="••••••••" />
327
+ </Field>
328
+ </FieldGroup>
329
+ </FieldSet>
330
+ )
331
+ }
332
+ ```
333
+
334
+ ## Textarea
335
+
336
+ ```tsx
337
+ import { Field, FieldDescription, FieldGroup, FieldLabel, FieldSet } from '@/components/ui/field'
338
+ import { Textarea } from '@/components/ui/textarea'
339
+
340
+ export function FieldTextarea() {
341
+ return (
342
+ <FieldSet className="w-full max-w-xs">
343
+ <FieldGroup>
344
+ <Field>
345
+ <FieldLabel htmlFor="feedback">Feedback</FieldLabel>
346
+ <Textarea id="feedback" placeholder="Your feedback helps us improve..." rows={4} />
347
+ <FieldDescription>Share your thoughts about our service.</FieldDescription>
348
+ </Field>
349
+ </FieldGroup>
350
+ </FieldSet>
351
+ )
352
+ }
353
+ ```
354
+
355
+ ## Select
356
+
357
+ ```tsx
358
+ import { Field, FieldDescription, FieldLabel } from '@/components/ui/field'
359
+ import {
360
+ Select,
361
+ SelectContent,
362
+ SelectGroup,
363
+ SelectItem,
364
+ SelectTrigger,
365
+ SelectValue
366
+ } from '@/components/ui/select'
367
+
368
+ const items = [
369
+ { label: 'Choose department', value: null },
370
+ { label: 'Engineering', value: 'engineering' },
371
+ { label: 'Design', value: 'design' },
372
+ { label: 'Marketing', value: 'marketing' },
373
+ { label: 'Sales', value: 'sales' },
374
+ { label: 'Customer Support', value: 'support' },
375
+ { label: 'Human Resources', value: 'hr' },
376
+ { label: 'Finance', value: 'finance' },
377
+ { label: 'Operations', value: 'operations' }
378
+ ]
379
+
380
+ export function FieldSelect() {
381
+ return (
382
+ <Field className="w-full max-w-xs">
383
+ <FieldLabel>Department</FieldLabel>
384
+ <Select items={items}>
385
+ <SelectTrigger>
386
+ <SelectValue />
387
+ </SelectTrigger>
388
+ <SelectContent>
389
+ <SelectGroup>
390
+ {items.map(item => (
391
+ <SelectItem key={item.value} value={item.value}>
392
+ {item.label}
393
+ </SelectItem>
394
+ ))}
395
+ </SelectGroup>
396
+ </SelectContent>
397
+ </Select>
398
+ <FieldDescription>Select your department or area of work.</FieldDescription>
399
+ </Field>
400
+ )
401
+ }
402
+ ```
403
+
404
+ ## Slider
405
+
406
+ ```tsx
407
+ 'use client'
408
+
409
+ import * as React from 'react'
410
+
411
+ import { Field, FieldDescription, FieldTitle } from '@/components/ui/field'
412
+ import { Slider } from '@/components/ui/slider'
413
+
414
+ export function FieldSlider() {
415
+ const [value, setValue] = React.useState([200, 800])
416
+
417
+ return (
418
+ <Field className="w-full max-w-xs">
419
+ <FieldTitle>Price Range</FieldTitle>
420
+ <FieldDescription>
421
+ Set your budget range ($
422
+ <span className="font-medium tabular-nums">{value[0]}</span> -{' '}
423
+ <span className="font-medium tabular-nums">{value[1]}</span>).
424
+ </FieldDescription>
425
+ <Slider
426
+ value={value}
427
+ onValueChange={value => setValue(value as [number, number])}
428
+ max={1000}
429
+ min={0}
430
+ step={10}
431
+ className="mt-2 w-full"
432
+ aria-label="Price Range"
433
+ />
434
+ </Field>
435
+ )
436
+ }
437
+ ```
438
+
439
+ ## Fieldset
440
+
441
+ ```tsx
442
+ import {
443
+ Field,
444
+ FieldDescription,
445
+ FieldGroup,
446
+ FieldLabel,
447
+ FieldLegend,
448
+ FieldSet
449
+ } from '@/components/ui/field'
450
+ import { Input } from '@/components/ui/input'
451
+
452
+ export function FieldFieldset() {
453
+ return (
454
+ <FieldSet className="w-full max-w-sm">
455
+ <FieldLegend>Address Information</FieldLegend>
456
+ <FieldDescription>We need your address to deliver your order.</FieldDescription>
457
+ <FieldGroup>
458
+ <Field>
459
+ <FieldLabel htmlFor="street">Street Address</FieldLabel>
460
+ <Input id="street" type="text" placeholder="123 Main St" />
461
+ </Field>
462
+ <div className="grid grid-cols-2 gap-4">
463
+ <Field>
464
+ <FieldLabel htmlFor="city">City</FieldLabel>
465
+ <Input id="city" type="text" placeholder="New York" />
466
+ </Field>
467
+ <Field>
468
+ <FieldLabel htmlFor="zip">Postal Code</FieldLabel>
469
+ <Input id="zip" type="text" placeholder="90502" />
470
+ </Field>
471
+ </div>
472
+ </FieldGroup>
473
+ </FieldSet>
474
+ )
475
+ }
476
+ ```
477
+
478
+ ## Checkbox
479
+
480
+ ```tsx
481
+ import { Checkbox } from '@/components/ui/checkbox'
482
+ import {
483
+ Field,
484
+ FieldContent,
485
+ FieldDescription,
486
+ FieldGroup,
487
+ FieldLabel,
488
+ FieldLegend,
489
+ FieldSeparator,
490
+ FieldSet
491
+ } from '@/components/ui/field'
492
+
493
+ export function FieldCheckbox() {
494
+ return (
495
+ <FieldGroup className="w-full max-w-xs">
496
+ <FieldSet>
497
+ <FieldLegend variant="label">Show these items on the desktop</FieldLegend>
498
+ <FieldDescription>Select the items you want to show on the desktop.</FieldDescription>
499
+ <FieldGroup className="gap-3">
500
+ <Field orientation="horizontal">
501
+ <Checkbox id="finder-pref-9k2-hard-disks-ljj" />
502
+ <FieldLabel
503
+ htmlFor="finder-pref-9k2-hard-disks-ljj"
504
+ className="font-normal"
505
+ defaultChecked
506
+ >
507
+ Hard disks
508
+ </FieldLabel>
509
+ </Field>
510
+ <Field orientation="horizontal">
511
+ <Checkbox id="finder-pref-9k2-external-disks-1yg" />
512
+ <FieldLabel htmlFor="finder-pref-9k2-external-disks-1yg" className="font-normal">
513
+ External disks
514
+ </FieldLabel>
515
+ </Field>
516
+ <Field orientation="horizontal">
517
+ <Checkbox id="finder-pref-9k2-cds-dvds-fzt" />
518
+ <FieldLabel htmlFor="finder-pref-9k2-cds-dvds-fzt" className="font-normal">
519
+ CDs, DVDs, and iPods
520
+ </FieldLabel>
521
+ </Field>
522
+ <Field orientation="horizontal">
523
+ <Checkbox id="finder-pref-9k2-connected-servers-6l2" />
524
+ <FieldLabel htmlFor="finder-pref-9k2-connected-servers-6l2" className="font-normal">
525
+ Connected servers
526
+ </FieldLabel>
527
+ </Field>
528
+ </FieldGroup>
529
+ </FieldSet>
530
+ <FieldSeparator />
531
+ <Field orientation="horizontal">
532
+ <Checkbox id="finder-pref-9k2-sync-folders-nep" defaultChecked />
533
+ <FieldContent>
534
+ <FieldLabel htmlFor="finder-pref-9k2-sync-folders-nep">
535
+ Sync Desktop & Documents folders
536
+ </FieldLabel>
537
+ <FieldDescription>
538
+ Your Desktop & Documents folders are being synced with iCloud Drive. You can access them
539
+ from other devices.
540
+ </FieldDescription>
541
+ </FieldContent>
542
+ </Field>
543
+ </FieldGroup>
544
+ )
545
+ }
546
+ ```
547
+
548
+ ## Radio
549
+
550
+ ```tsx
551
+ import { Field, FieldDescription, FieldLabel, FieldLegend, FieldSet } from '@/components/ui/field'
552
+ import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
553
+
554
+ export function FieldRadio() {
555
+ return (
556
+ <FieldSet className="w-full max-w-xs">
557
+ <FieldLegend variant="label">Subscription Plan</FieldLegend>
558
+ <FieldDescription>Yearly and lifetime plans offer significant savings.</FieldDescription>
559
+ <RadioGroup defaultValue="monthly">
560
+ <Field orientation="horizontal">
561
+ <RadioGroupItem value="monthly" id="plan-monthly" />
562
+ <FieldLabel htmlFor="plan-monthly" className="font-normal">
563
+ Monthly ($9.99/month)
564
+ </FieldLabel>
565
+ </Field>
566
+ <Field orientation="horizontal">
567
+ <RadioGroupItem value="yearly" id="plan-yearly" />
568
+ <FieldLabel htmlFor="plan-yearly" className="font-normal">
569
+ Yearly ($99.99/year)
570
+ </FieldLabel>
571
+ </Field>
572
+ <Field orientation="horizontal">
573
+ <RadioGroupItem value="lifetime" id="plan-lifetime" />
574
+ <FieldLabel htmlFor="plan-lifetime" className="font-normal">
575
+ Lifetime ($299.99)
576
+ </FieldLabel>
577
+ </Field>
578
+ </RadioGroup>
579
+ </FieldSet>
580
+ )
581
+ }
582
+ ```
583
+
584
+ ## Switch
585
+
586
+ ```tsx
587
+ import { Field, FieldLabel } from '@/components/ui/field'
588
+ import { Switch } from '@/components/ui/switch'
589
+
590
+ export function FieldSwitch() {
591
+ return (
592
+ <Field orientation="horizontal" className="w-fit">
593
+ <FieldLabel htmlFor="2fa">Multi-factor authentication</FieldLabel>
594
+ <Switch id="2fa" />
595
+ </Field>
596
+ )
597
+ }
598
+ ```
599
+
600
+ ## Choice Card
601
+
602
+ Wrap `Field` components inside `FieldLabel` to create selectable field groups. This works with `RadioItem`, `Checkbox` and `Switch` components.
603
+
604
+ ```tsx
605
+ import {
606
+ Field,
607
+ FieldContent,
608
+ FieldDescription,
609
+ FieldGroup,
610
+ FieldLabel,
611
+ FieldLegend,
612
+ FieldSet,
613
+ FieldTitle
614
+ } from '@/components/ui/field'
615
+ import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
616
+
617
+ export function FieldChoiceCard() {
618
+ return (
619
+ <FieldGroup className="w-full max-w-xs">
620
+ <FieldSet>
621
+ <FieldLegend variant="label">Compute Environment</FieldLegend>
622
+ <FieldDescription>Select the compute environment for your cluster.</FieldDescription>
623
+ <RadioGroup defaultValue="kubernetes">
624
+ <FieldLabel htmlFor="kubernetes-r2h">
625
+ <Field orientation="horizontal">
626
+ <FieldContent>
627
+ <FieldTitle>Kubernetes</FieldTitle>
628
+ <FieldDescription>Run GPU workloads on a K8s cluster.</FieldDescription>
629
+ </FieldContent>
630
+ <RadioGroupItem value="kubernetes" id="kubernetes-r2h" />
631
+ </Field>
632
+ </FieldLabel>
633
+ <FieldLabel htmlFor="vm-z4k">
634
+ <Field orientation="horizontal">
635
+ <FieldContent>
636
+ <FieldTitle>Virtual Machine</FieldTitle>
637
+ <FieldDescription>Access a cluster to run GPU workloads.</FieldDescription>
638
+ </FieldContent>
639
+ <RadioGroupItem value="vm" id="vm-z4k" />
640
+ </Field>
641
+ </FieldLabel>
642
+ </RadioGroup>
643
+ </FieldSet>
644
+ </FieldGroup>
645
+ )
646
+ }
647
+ ```
648
+
649
+ ## Field Group
650
+
651
+ Stack `Field` components with `FieldGroup`. Add `FieldSeparator` to divide them.
652
+
653
+ ```tsx
654
+ import { Checkbox } from '@/components/ui/checkbox'
655
+ import {
656
+ Field,
657
+ FieldDescription,
658
+ FieldGroup,
659
+ FieldLabel,
660
+ FieldSeparator,
661
+ FieldSet
662
+ } from '@/components/ui/field'
663
+
664
+ export function FieldGroupExample() {
665
+ return (
666
+ <FieldGroup className="w-full max-w-xs">
667
+ <FieldSet>
668
+ <FieldLabel>Responses</FieldLabel>
669
+ <FieldDescription>
670
+ Get notified when ChatGPT responds to requests that take time, like research or image
671
+ generation.
672
+ </FieldDescription>
673
+ <FieldGroup data-slot="checkbox-group">
674
+ <Field orientation="horizontal">
675
+ <Checkbox id="push" defaultChecked disabled />
676
+ <FieldLabel htmlFor="push" className="font-normal">
677
+ Push notifications
678
+ </FieldLabel>
679
+ </Field>
680
+ </FieldGroup>
681
+ </FieldSet>
682
+ <FieldSeparator />
683
+ <FieldSet>
684
+ <FieldLabel>Tasks</FieldLabel>
685
+ <FieldDescription>
686
+ Get notified when tasks you&apos;ve created have updates. <a href="#">Manage tasks</a>
687
+ </FieldDescription>
688
+ <FieldGroup data-slot="checkbox-group">
689
+ <Field orientation="horizontal">
690
+ <Checkbox id="push-tasks" />
691
+ <FieldLabel htmlFor="push-tasks" className="font-normal">
692
+ Push notifications
693
+ </FieldLabel>
694
+ </Field>
695
+ <Field orientation="horizontal">
696
+ <Checkbox id="email-tasks" />
697
+ <FieldLabel htmlFor="email-tasks" className="font-normal">
698
+ Email notifications
699
+ </FieldLabel>
700
+ </Field>
701
+ </FieldGroup>
702
+ </FieldSet>
703
+ </FieldGroup>
704
+ )
705
+ }
706
+ ```
707
+
708
+ ## RTL
709
+
710
+ ```tsx
711
+ 'use client'
712
+
713
+ import * as React from 'react'
714
+
715
+ import { useTranslation, type Translations } from '@/components/language-selector'
716
+ import { Button } from '@/components/ui/button'
717
+ import { Checkbox } from '@/components/ui/checkbox'
718
+ import {
719
+ Field,
720
+ FieldDescription,
721
+ FieldGroup,
722
+ FieldLabel,
723
+ FieldLegend,
724
+ FieldSeparator,
725
+ FieldSet
726
+ } from '@/components/ui/field'
727
+ import { Input } from '@/components/ui/input'
728
+ import {
729
+ Select,
730
+ SelectContent,
731
+ SelectGroup,
732
+ SelectItem,
733
+ SelectTrigger,
734
+ SelectValue
735
+ } from '@/components/ui/select'
736
+ import { Textarea } from '@/components/ui/textarea'
737
+
738
+ const months = [
739
+ { label: 'MM', value: null },
740
+ { label: '01', value: '01' },
741
+ { label: '02', value: '02' },
742
+ { label: '03', value: '03' },
743
+ { label: '04', value: '04' },
744
+ { label: '05', value: '05' },
745
+ { label: '06', value: '06' },
746
+ { label: '07', value: '07' },
747
+ { label: '08', value: '08' },
748
+ { label: '09', value: '09' },
749
+ { label: '10', value: '10' },
750
+ { label: '11', value: '11' },
751
+ { label: '12', value: '12' }
752
+ ]
753
+
754
+ const years = [
755
+ { label: 'YYYY', value: null },
756
+ { label: '2024', value: '2024' },
757
+ { label: '2025', value: '2025' },
758
+ { label: '2026', value: '2026' },
759
+ { label: '2027', value: '2027' },
760
+ { label: '2028', value: '2028' },
761
+ { label: '2029', value: '2029' }
762
+ ]
763
+
764
+ const translations: Translations = {
765
+ en: {
766
+ dir: 'ltr',
767
+ values: {
768
+ paymentMethod: 'Payment Method',
769
+ secureTransactions: 'All transactions are secure and encrypted',
770
+ nameOnCard: 'Name on Card',
771
+ cardNumber: 'Card Number',
772
+ cardNumberDescription: 'Enter your 16-digit card number',
773
+ month: 'Month',
774
+ year: 'Year',
775
+ cvv: 'CVV',
776
+ monthPlaceholder: 'MM',
777
+ month01: '01',
778
+ month02: '02',
779
+ month03: '03',
780
+ month04: '04',
781
+ month05: '05',
782
+ month06: '06',
783
+ month07: '07',
784
+ month08: '08',
785
+ month09: '09',
786
+ month10: '10',
787
+ month11: '11',
788
+ month12: '12',
789
+ billingAddress: 'Billing Address',
790
+ billingAddressDescription: 'The billing address associated with your payment method',
791
+ sameAsShipping: 'Same as shipping address',
792
+ comments: 'Comments',
793
+ commentsPlaceholder: 'Add any additional comments',
794
+ submit: 'Submit',
795
+ cancel: 'Cancel'
796
+ }
797
+ },
798
+ ar: {
799
+ dir: 'rtl',
800
+ values: {
801
+ paymentMethod: 'طريقة الدفع',
802
+ secureTransactions: 'جميع المعاملات آمنة ومشفرة',
803
+ nameOnCard: 'الاسم على البطاقة',
804
+ cardNumber: 'رقم البطاقة',
805
+ cardNumberDescription: 'أدخل رقم البطاقة المكون من 16 رقمًا',
806
+ month: 'الشهر',
807
+ year: 'السنة',
808
+ cvv: 'CVV',
809
+ monthPlaceholder: 'ش.ش',
810
+ month01: '٠١',
811
+ month02: '٠٢',
812
+ month03: '٠٣',
813
+ month04: '٠٤',
814
+ month05: '٠٥',
815
+ month06: '٠٦',
816
+ month07: '٠٧',
817
+ month08: '٠٨',
818
+ month09: '٠٩',
819
+ month10: '١٠',
820
+ month11: '١١',
821
+ month12: '١٢',
822
+ billingAddress: 'عنوان الفوترة',
823
+ billingAddressDescription: 'عنوان الفوترة المرتبط بطريقة الدفع الخاصة بك',
824
+ sameAsShipping: 'نفس عنوان الشحن',
825
+ comments: 'تعليقات',
826
+ commentsPlaceholder: 'أضف أي تعليقات إضافية',
827
+ submit: 'إرسال',
828
+ cancel: 'إلغاء'
829
+ }
830
+ },
831
+ he: {
832
+ dir: 'rtl',
833
+ values: {
834
+ paymentMethod: 'אמצעי תשלום',
835
+ secureTransactions: 'כל העסקאות מאובטחות ומוצפנות',
836
+ nameOnCard: 'שם על הכרטיס',
837
+ cardNumber: 'מספר כרטיס',
838
+ cardNumberDescription: 'הזן את מספר הכרטיס בן 16 הספרות שלך',
839
+ month: 'חודש',
840
+ year: 'שנה',
841
+ cvv: 'CVV',
842
+ monthPlaceholder: 'MM',
843
+ month01: '01',
844
+ month02: '02',
845
+ month03: '03',
846
+ month04: '04',
847
+ month05: '05',
848
+ month06: '06',
849
+ month07: '07',
850
+ month08: '08',
851
+ month09: '09',
852
+ month10: '10',
853
+ month11: '11',
854
+ month12: '12',
855
+ billingAddress: 'כתובת חיוב',
856
+ billingAddressDescription: 'כתובת החיוב המשויכת לאמצעי התשלום שלך',
857
+ sameAsShipping: 'זהה לכתובת המשלוח',
858
+ comments: 'הערות',
859
+ commentsPlaceholder: 'הוסף הערות נוספות',
860
+ submit: 'שלח',
861
+ cancel: 'בטל'
862
+ }
863
+ }
864
+ }
865
+
866
+ export function FieldRtl() {
867
+ const { dir, t } = useTranslation(translations, 'ar')
868
+
869
+ const getMonthLabel = (value: string | null): string => {
870
+ if (value === null) return t.monthPlaceholder
871
+ const monthKey = `month${value}` as keyof typeof t
872
+ return t[monthKey] || value
873
+ }
874
+
875
+ return (
876
+ <div className="w-full max-w-md py-6" dir={dir}>
877
+ <form>
878
+ <FieldGroup>
879
+ <FieldSet>
880
+ <FieldLegend>{t.paymentMethod}</FieldLegend>
881
+ <FieldDescription>{t.secureTransactions}</FieldDescription>
882
+ <FieldGroup>
883
+ <Field>
884
+ <FieldLabel htmlFor="checkout-7j9-card-name-43j-rtl">{t.nameOnCard}</FieldLabel>
885
+ <Input id="checkout-7j9-card-name-43j-rtl" placeholder="Evil Rabbit" required />
886
+ </Field>
887
+ <Field>
888
+ <FieldLabel htmlFor="checkout-7j9-card-number-uw1-rtl">{t.cardNumber}</FieldLabel>
889
+ <Input
890
+ id="checkout-7j9-card-number-uw1-rtl"
891
+ placeholder="1234 5678 9012 3456"
892
+ required
893
+ />
894
+ <FieldDescription>{t.cardNumberDescription}</FieldDescription>
895
+ </Field>
896
+ <div className="grid grid-cols-3 gap-4">
897
+ <Field>
898
+ <FieldLabel htmlFor="checkout-exp-month-ts6-rtl">{t.month}</FieldLabel>
899
+ <Select items={months}>
900
+ <SelectTrigger id="checkout-exp-month-ts6-rtl">
901
+ <SelectValue />
902
+ </SelectTrigger>
903
+ <SelectContent dir={dir}>
904
+ <SelectGroup>
905
+ {months.map(item => (
906
+ <SelectItem key={item.value} value={item.value}>
907
+ {getMonthLabel(item.value)}
908
+ </SelectItem>
909
+ ))}
910
+ </SelectGroup>
911
+ </SelectContent>
912
+ </Select>
913
+ </Field>
914
+ <Field>
915
+ <FieldLabel htmlFor="checkout-7j9-exp-year-f59-rtl">{t.year}</FieldLabel>
916
+ <Select items={years}>
917
+ <SelectTrigger id="checkout-7j9-exp-year-f59-rtl">
918
+ <SelectValue />
919
+ </SelectTrigger>
920
+ <SelectContent dir={dir}>
921
+ <SelectGroup>
922
+ {years.map(item => (
923
+ <SelectItem key={item.value} value={item.value}>
924
+ {item.label}
925
+ </SelectItem>
926
+ ))}
927
+ </SelectGroup>
928
+ </SelectContent>
929
+ </Select>
930
+ </Field>
931
+ <Field>
932
+ <FieldLabel htmlFor="checkout-7j9-cvv-rtl">{t.cvv}</FieldLabel>
933
+ <Input id="checkout-7j9-cvv-rtl" placeholder="123" required />
934
+ </Field>
935
+ </div>
936
+ </FieldGroup>
937
+ </FieldSet>
938
+ <FieldSeparator />
939
+ <FieldSet>
940
+ <FieldLegend>{t.billingAddress}</FieldLegend>
941
+ <FieldDescription>{t.billingAddressDescription}</FieldDescription>
942
+ <FieldGroup>
943
+ <Field orientation="horizontal">
944
+ <Checkbox id="checkout-7j9-same-as-shipping-wgm-rtl" defaultChecked />
945
+ <FieldLabel htmlFor="checkout-7j9-same-as-shipping-wgm-rtl" className="font-normal">
946
+ {t.sameAsShipping}
947
+ </FieldLabel>
948
+ </Field>
949
+ </FieldGroup>
950
+ </FieldSet>
951
+ <FieldSet>
952
+ <FieldGroup>
953
+ <Field>
954
+ <FieldLabel htmlFor="checkout-7j9-optional-comments-rtl">{t.comments}</FieldLabel>
955
+ <Textarea
956
+ id="checkout-7j9-optional-comments-rtl"
957
+ placeholder={t.commentsPlaceholder}
958
+ className="resize-none"
959
+ />
960
+ </Field>
961
+ </FieldGroup>
962
+ </FieldSet>
963
+ <Field orientation="horizontal">
964
+ <Button type="submit">{t.submit}</Button>
965
+ <Button variant="outline" type="button">
966
+ {t.cancel}
967
+ </Button>
968
+ </Field>
969
+ </FieldGroup>
970
+ </form>
971
+ </div>
972
+ )
973
+ }
974
+ ```
975
+
976
+ ## Responsive Layout
977
+
978
+ - **Vertical fields:** Default orientation stacks label, control, and helper text—ideal for mobile-first layouts.
979
+ - **Horizontal fields:** Set `orientation="horizontal"` on `Field` to align the label and control side-by-side. Pair with `FieldContent` to keep descriptions aligned.
980
+ - **Responsive fields:** Set `orientation="responsive"` for automatic column layouts inside container-aware parents. Apply `@container/field-group` classes on `FieldGroup` to switch orientations at specific breakpoints.
981
+
982
+ ```tsx
983
+ import { Button } from '@/components/ui/button'
984
+ import {
985
+ Field,
986
+ FieldContent,
987
+ FieldDescription,
988
+ FieldGroup,
989
+ FieldLabel,
990
+ FieldLegend,
991
+ FieldSet
992
+ } from '@/components/ui/field'
993
+ import { Input } from '@/components/ui/input'
994
+
995
+ export function FieldResponsive() {
996
+ return (
997
+ <div className="w-full max-w-lg">
998
+ <form>
999
+ <FieldSet>
1000
+ <FieldLegend>Profile</FieldLegend>
1001
+ <FieldDescription>Fill in your profile information.</FieldDescription>
1002
+ <FieldGroup>
1003
+ <Field orientation="responsive">
1004
+ <FieldContent>
1005
+ <FieldLabel htmlFor="name">Name</FieldLabel>
1006
+ <FieldDescription>Provide your full name for identification</FieldDescription>
1007
+ </FieldContent>
1008
+ <Input id="name" placeholder="Evil Rabbit" required />
1009
+ </Field>
1010
+ <Field orientation="responsive">
1011
+ <Button type="submit">Submit</Button>
1012
+ <Button type="button" variant="outline">
1013
+ Cancel
1014
+ </Button>
1015
+ </Field>
1016
+ </FieldGroup>
1017
+ </FieldSet>
1018
+ </form>
1019
+ </div>
1020
+ )
1021
+ }
1022
+ ```
1023
+
1024
+ ## Validation and Errors
1025
+
1026
+ - Add `data-invalid` to `Field` to switch the entire block into an error state.
1027
+ - Add `aria-invalid` on the input itself for assistive technologies.
1028
+ - Render `FieldError` immediately after the control or inside `FieldContent` to keep error messages aligned with the field.
1029
+
1030
+ ```tsx showLineNumbers /data-invalid/ /aria-invalid/
1031
+ <Field data-invalid>
1032
+ <FieldLabel htmlFor="email">Email</FieldLabel>
1033
+ <Input id="email" type="email" aria-invalid />
1034
+ <FieldError>Enter a valid email address.</FieldError>
1035
+ </Field>
1036
+ ```
1037
+
1038
+ ## Accessibility
1039
+
1040
+ - `FieldSet` and `FieldLegend` keep related controls grouped for keyboard and assistive tech users.
1041
+ - `Field` outputs `role="group"` so nested controls inherit labeling from `FieldLabel` and `FieldLegend` when combined.
1042
+ - Apply `FieldSeparator` sparingly to ensure screen readers encounter clear section boundaries.
1043
+
1044
+ ## API Reference
1045
+
1046
+ ### FieldSet
1047
+
1048
+ Container that renders a semantic `fieldset` with spacing presets.
1049
+
1050
+ | Prop | Type | Default |
1051
+ | ----------- | -------- | ------- |
1052
+ | `className` | `string` | |
1053
+
1054
+ ```tsx
1055
+ <FieldSet>
1056
+ <FieldLegend>Delivery</FieldLegend>
1057
+ <FieldGroup>{/* Fields */}</FieldGroup>
1058
+ </FieldSet>
1059
+ ```
1060
+
1061
+ ### FieldLegend
1062
+
1063
+ Legend element for a `FieldSet`. Switch to the `label` variant to align with label sizing.
1064
+
1065
+ | Prop | Type | Default |
1066
+ | ----------- | --------------------- | ---------- |
1067
+ | `variant` | `"legend" \| "label"` | `"legend"` |
1068
+ | `className` | `string` | |
1069
+
1070
+ ```tsx
1071
+ <FieldLegend variant="label">Notification Preferences</FieldLegend>
1072
+ ```
1073
+
1074
+ The `FieldLegend` has two variants: `legend` and `label`. The `label` variant applies label sizing and alignment. Handy if you have nested `FieldSet`.
1075
+
1076
+ ### FieldGroup
1077
+
1078
+ Layout wrapper that stacks `Field` components and enables container queries for responsive orientations.
1079
+
1080
+ | Prop | Type | Default |
1081
+ | ----------- | -------- | ------- |
1082
+ | `className` | `string` | |
1083
+
1084
+ ```tsx
1085
+ <FieldGroup className="@container/field-group flex flex-col gap-6">
1086
+ <Field>{/* ... */}</Field>
1087
+ <Field>{/* ... */}</Field>
1088
+ </FieldGroup>
1089
+ ```
1090
+
1091
+ ### Field
1092
+
1093
+ The core wrapper for a single field. Provides orientation control, invalid state styling, and spacing.
1094
+
1095
+ | Prop | Type | Default |
1096
+ | -------------- | -------------------------------------------- | ------------ |
1097
+ | `orientation` | `"vertical" \| "horizontal" \| "responsive"` | `"vertical"` |
1098
+ | `className` | `string` | |
1099
+ | `data-invalid` | `boolean` | |
1100
+
1101
+ ```tsx
1102
+ <Field orientation="horizontal">
1103
+ <FieldLabel htmlFor="remember">Remember me</FieldLabel>
1104
+ <Switch id="remember" />
1105
+ </Field>
1106
+ ```
1107
+
1108
+ ### FieldContent
1109
+
1110
+ Flex column that groups control and descriptions when the label sits beside the control. Not required if you have no description.
1111
+
1112
+ | Prop | Type | Default |
1113
+ | ----------- | -------- | ------- |
1114
+ | `className` | `string` | |
1115
+
1116
+ ```tsx
1117
+ <Field>
1118
+ <Checkbox id="notifications" />
1119
+ <FieldContent>
1120
+ <FieldLabel htmlFor="notifications">Notifications</FieldLabel>
1121
+ <FieldDescription>Email, SMS, and push options.</FieldDescription>
1122
+ </FieldContent>
1123
+ </Field>
1124
+ ```
1125
+
1126
+ ### FieldLabel
1127
+
1128
+ Label styled for both direct inputs and nested `Field` children.
1129
+
1130
+ | Prop | Type | Default |
1131
+ | ----------- | -------- | ------- |
1132
+ | `className` | `string` | |
1133
+
1134
+ ```tsx
1135
+ <FieldLabel htmlFor="email">Email</FieldLabel>
1136
+ ```
1137
+
1138
+ ### FieldTitle
1139
+
1140
+ Renders a title with label styling inside `FieldContent`.
1141
+
1142
+ | Prop | Type | Default |
1143
+ | ----------- | -------- | ------- |
1144
+ | `className` | `string` | |
1145
+
1146
+ ```tsx
1147
+ <FieldContent>
1148
+ <FieldTitle>Enable Touch ID</FieldTitle>
1149
+ <FieldDescription>Unlock your device faster.</FieldDescription>
1150
+ </FieldContent>
1151
+ ```
1152
+
1153
+ ### FieldDescription
1154
+
1155
+ Helper text slot that automatically balances long lines in horizontal layouts.
1156
+
1157
+ | Prop | Type | Default |
1158
+ | ----------- | -------- | ------- |
1159
+ | `className` | `string` | |
1160
+
1161
+ ```tsx
1162
+ <FieldDescription>We never share your email with anyone.</FieldDescription>
1163
+ ```
1164
+
1165
+ ### FieldSeparator
1166
+
1167
+ Visual divider to separate sections inside a `FieldGroup`. Accepts optional inline content.
1168
+
1169
+ | Prop | Type | Default |
1170
+ | ----------- | -------- | ------- |
1171
+ | `className` | `string` | |
1172
+
1173
+ ```tsx
1174
+ <FieldSeparator>Or continue with</FieldSeparator>
1175
+ ```
1176
+
1177
+ ### FieldError
1178
+
1179
+ Accessible error container that accepts children or an `errors` array (e.g., from `react-hook-form`).
1180
+
1181
+ | Prop | Type | Default |
1182
+ | ----------- | ------------------------------------------ | ------- |
1183
+ | `errors` | `Array<{ message?: string } \| undefined>` | |
1184
+ | `className` | `string` | |
1185
+
1186
+ ```tsx
1187
+ <FieldError errors={errors.username} />
1188
+ ```
1189
+
1190
+ When the `errors` array contains multiple messages, the component renders a list automatically.
1191
+
1192
+ `FieldError` also accepts issues produced by any validator that implements [Standard Schema](https://standardschema.dev/), including Zod, Valibot, and ArkType. Pass the `issues` array from the schema result directly to render a unified error list across libraries.