@appdirect/design-system 0.0.19 → 0.0.20

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 (29) hide show
  1. package/README.md +21 -0
  2. package/bin/ad-sync-agents.mjs +542 -0
  3. package/dist/DESIGN.md +49 -7
  4. package/dist/agent-kit/README.md +11 -0
  5. package/dist/agent-kit/manifest.json +81 -0
  6. package/dist/agent-kit/micro-ui/CLAUDE.md +1 -0
  7. package/dist/agent-kit/micro-ui/micro-ui.AGENTS.md +62 -0
  8. package/dist/agent-kit/rules/accessibility.mdc +46 -0
  9. package/dist/agent-kit/rules/module-federation.mdc +30 -0
  10. package/dist/agent-kit/rules/react-stack.mdc +73 -0
  11. package/dist/agent-kit/rules/testing.mdc +44 -0
  12. package/dist/agent-kit/skills/design-feature/SKILL.md +205 -0
  13. package/dist/agent-kit/skills/developer-handoff/SKILL.md +192 -0
  14. package/dist/agent-kit/skills/figma-mcp-integration/SKILL.md +134 -0
  15. package/dist/agent-kit/skills/figma-to-page/SKILL.md +24 -0
  16. package/dist/agent-kit/skills/mantine-combobox/SKILL.md +73 -0
  17. package/dist/agent-kit/skills/mantine-combobox/references/api.md +199 -0
  18. package/dist/agent-kit/skills/mantine-combobox/references/patterns.md +279 -0
  19. package/dist/agent-kit/skills/mantine-custom-components/SKILL.md +112 -0
  20. package/dist/agent-kit/skills/mantine-custom-components/references/api.md +407 -0
  21. package/dist/agent-kit/skills/mantine-custom-components/references/patterns.md +431 -0
  22. package/dist/agent-kit/skills/mantine-form/SKILL.md +103 -0
  23. package/dist/agent-kit/skills/mantine-form/references/api.md +313 -0
  24. package/dist/agent-kit/skills/mantine-form/references/patterns.md +310 -0
  25. package/dist/agent-kit/skills/prototype-page/SKILL.md +82 -0
  26. package/dist/contracts/index.json +1 -1
  27. package/dist/skills/design-feature/SKILL.md +205 -0
  28. package/dist/stories/index.json +1 -1
  29. package/package.json +8 -4
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: developer-handoff
3
+ description: Use when handing a prototype or newly set-up micro UI to engineering and its team repository, micro-container route, navigation item, Jira pull requests, appconfigr flag, or integration smoke tests must be prepared.
4
+ ---
5
+
6
+ # Developer handoff
7
+
8
+ Create or reuse three focused pull requests: the team micro UI, micro-container, and navigation. Use one Jira story for all three. Never hide missing appconfigr or smoke-test setup behind a “done” report.
9
+
10
+ ## Required workspace
11
+
12
+ Work only from a Cursor workspace that already contains:
13
+
14
+ - The prototype platform or the copied micro UI.
15
+ - The empty or existing team micro UI repository.
16
+ - `micro-container`.
17
+ - `navigation`.
18
+
19
+ Treat all four repositories as workspace dependencies. Do not create or clone a missing repository. Name each missing workspace folder and stop. The team repository must have a default branch with an initial commit so the skill can open a feature pull request; if it is completely empty, tell the developer to initialize it in Teams and add it back to the workspace.
20
+
21
+ Before changing a repository, stop if it has unrelated uncommitted changes. Never overwrite another branch’s work.
22
+
23
+ ## Ask
24
+
25
+ Ask one question at a time and skip answers already provided:
26
+
27
+ 1. Prototype `owner/slug`, or confirm the current copied micro UI.
28
+ 2. Jira story key. This is required for every branch and pull request.
29
+ 3. Which workspace folder is the existing team repository, and its GitHub organization and owning team.
30
+ 4. Marketplace path.
31
+ 5. CI/CD Slack channel, default branch, and team email.
32
+ 6. Navigation namespace, collection/section, label, translation key, stable item name, and insertion position.
33
+ 7. Feature-flag key.
34
+ 8. Authorized roles and existing permission, if any. Never invent either.
35
+ 9. Page-title translation key and any nonstandard header, footer, width, or legacy-layout behavior.
36
+
37
+ Read `prototype.json`, `standalone/standalone.config.ts`, and `src/navigation/router.tsx` before asking for values those files already provide. If the name, page, or navigation metadata disagree, show the conflict and ask which production contract is correct.
38
+
39
+ ## Discover before creating
40
+
41
+ For each repository, inspect local files and GitHub before editing:
42
+
43
+ - Existing repository and default branch.
44
+ - Branches and open or merged pull requests for the Jira story.
45
+ - Existing marketplace path, Module Federation remote, menu item, and flag.
46
+ - Existing setup result and smoke-test configuration.
47
+
48
+ Reuse and update matching work. Do not create duplicate repositories, routes, menu items, branches, or pull requests. If an existing change is complete, record its link and continue.
49
+
50
+ An existing item is a duplicate only when it targets the same production page or stable item identity. A reused label such as “Invoices” with another URL or collection is not automatically a duplicate. Show the overlap and confirm placement when it could confuse users.
51
+
52
+ ## Pull request 1: existing team micro UI
53
+
54
+ ### Use the workspace dependency
55
+
56
+ Do not create or clone the repository. Confirm the named workspace folder points to the expected GitHub team repository and inspect its actual default branch. If it is completely empty, stop and ask the developer to initialize it in Teams with an initial commit.
57
+
58
+ Create a Jira-named feature branch from that default branch. Do not commit on the default branch.
59
+
60
+ Copy the full prototype folder into the repository:
61
+
62
+ ```bash
63
+ rsync -a --exclude node_modules --exclude .git prototypes/<owner>/<slug>/ <team-repo>/
64
+ ```
65
+
66
+ Keep dotfiles, `.deployments`, `.github`, `Jenkinsfile`, `Dockerfile`, and `__e2e__`.
67
+
68
+ ### Run setup once
69
+
70
+ Never run setup inside `prototypes/`. From the copied repository, run:
71
+
72
+ ```bash
73
+ npm run setup
74
+ ```
75
+
76
+ Answer with the confirmed repository name, marketplace path, Slack channel, actual default branch, and team email. Setup installs with npm for a prototype copy and requires the VPN. If it reports that setup already ran, inspect the generated project name, route, deployment files, and remote name; do not run it again.
77
+
78
+ Verify no prototype-only path or package remains. Run the repository’s lint, tests, and build.
79
+
80
+ ### Smoke tests block integration
81
+
82
+ Smoke tests are required to release on integration. Setup disables them because the template’s sealed values are not valid for the renamed secret.
83
+
84
+ The developer or deployment owner must provide newly sealed values for:
85
+
86
+ - `cypress_username`
87
+ - `cypress_password`
88
+
89
+ Update every integration deployment variables file that carries those values. The resulting Kubernetes secret is `<project>-smoke-secrets`. Do not copy plaintext credentials into git or chat, and do not claim the copied encrypted values are reusable after the secret is renamed.
90
+
91
+ The skill does not generate, request, reveal, or copy credentials. Report the exact files and secret name to the developer. After the developer installs valid sealed values, set `enableSmokeTest: true` and run the integration smoke gate. The repository command is `cd __e2e__ && npm run test:smoke` when its required environment is available. Keep the micro UI pull request in draft and report it as blocked while secrets are missing. It cannot pass the required smoke gate or release to integration until this is done. Treat `enablePostSyncTest` as a separate team decision; do not silently enable it.
92
+
93
+ Open or update the team micro UI pull request.
94
+
95
+ ## Pull request 2: micro-container route
96
+
97
+ Find the namespace file in `micro-container/src/routes/navigation/`. Reject a duplicate `pathPattern`.
98
+
99
+ Fetch the remote default branch, then create or reuse the Jira branch from that default branch. Do not build on the repository’s currently checked-out feature branch.
100
+
101
+ Add one route using setup output and the confirmed navigation contract:
102
+
103
+ ```js
104
+ route_key: {
105
+ pathPattern: '/confirmed/path',
106
+ isSecondaryNavEnabled: true,
107
+ isTertiaryNavEnabled: true,
108
+ collectionName: 'confirmed-collection',
109
+ secondaryNavItemSelected: 'confirmed-section',
110
+ verticalNavigationItemSelected: 'confirmed-item',
111
+ namespace: 'confirmed-namespace',
112
+ RemoteMicroUIurl: '/micro-ui/project-name/remoteEntry.js',
113
+ RemoteMicroUIName: 'project_name',
114
+ isVersioned: true,
115
+ reactVersion: 19,
116
+ requiredFeatureFlag: 'confirmed_flag'
117
+ }
118
+ ```
119
+
120
+ Omit tertiary fields only when the confirmed menu is not tertiary. Add `authorizedRoles` only from confirmed prototype or product requirements. Follow neighboring routes for title and layout fields; do not invent them.
121
+
122
+ Add the confirmed page path to `.deployments/micro-container/values.yaml` `defaultPaths`, using the neighboring regex style and including descendants only when the route supports them.
123
+
124
+ Run the route tests, including `src/routes/__tests__/navigation.test.js`. They enforce supported properties, unique paths and route keys, and required namespace/collection fields.
125
+
126
+ Open or update the micro-container pull request.
127
+
128
+ ## Pull request 3: navigation item
129
+
130
+ Find the exact source from the namespace and collection:
131
+
132
+ - `navigationMenus/global/<namespace>/secondaryNav.ts`, or
133
+ - `navigationMenus/global/<namespace>/tertiary/<section>.ts`.
134
+
135
+ Fetch the remote default branch, then create or reuse the Jira branch from that default branch. Do not build on the repository’s currently checked-out feature branch.
136
+
137
+ Add one item to the confirmed `menuItems` array:
138
+
139
+ ```ts
140
+ {
141
+ label: l('confirmed.translation.key'),
142
+ name: 'confirmedItem',
143
+ url: '/confirmed/path',
144
+ permission: 'confirmed-existing.permission',
145
+ flag: { key: 'confirmed_flag' }
146
+ }
147
+ ```
148
+
149
+ Omit `permission` when no existing permission was confirmed. Use the collection’s established flag shape if it differs. Keep the item in the requested position.
150
+
151
+ Update that namespace’s appconfigr mocks and repository tests. Prove the item is absent when the flag is off and present, correctly labeled, and correctly linked when it is on. Run the targeted tests and `npm run validator`; the validator checks menu and `flags.keys` shapes.
152
+
153
+ Open or update the navigation pull request.
154
+
155
+ ## Jira and pull request contract
156
+
157
+ Use the same story key everywhere.
158
+
159
+ Title:
160
+
161
+ ```text
162
+ PFM-1234: Short repository-specific summary
163
+ ```
164
+
165
+ Body, near the top:
166
+
167
+ ```markdown
168
+ ## Jira
169
+ - [PFM-1234](https://appdirect.jira.com/browse/PFM-1234)
170
+ ```
171
+
172
+ Each body explains its repository’s part of the handoff and links the other two pull requests when available. Never add a Cursor co-author.
173
+
174
+ ## Appconfigr
175
+
176
+ Do not create or pretend to create the feature flag. Tell the developer to create the exact confirmed key in appconfigr. Both the micro-container route and navigation item reference it, so the page remains unavailable until the flag exists and is enabled.
177
+
178
+ ## Final report
179
+
180
+ List every pull request, including one found rather than created:
181
+
182
+ 1. **Team micro UI** — repository, PR link, what setup produced, tests run, and smoke-secret status.
183
+ 2. **micro-container** — PR link, path, remote name/URL, navigation selection, and route flag.
184
+ 3. **navigation** — PR link, namespace/collection, item position, permission, flag, and hidden/visible tests.
185
+
186
+ Then list:
187
+
188
+ - **Jira:** linked story shared by all three PRs.
189
+ - **Appconfigr action:** exact flag key the developer must create.
190
+ - **Smoke-test action:** exact deployment files/secrets still required; state that smoke tests are required for integration release.
191
+ - **Existing work reused:** repository, routes, menu items, branches, or PRs that were found.
192
+ - **Order and blockers:** what can merge now, what depends on another PR, and why any PR remains draft or failing.
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: figma-mcp-integration
3
+ description: Use when the user shares a figma.com URL or node id, or before calling any Figma MCP tool, to build micro-ui-ts UI that follows the AppDirect design system.
4
+ ---
5
+
6
+ # Figma MCP integration
7
+
8
+ Build the screen from the Figma node using the design system in the root `AGENTS.md`. Token names are in `docs/DESIGN.md`. Copy the token name into code. Leave the hex values in that doc.
9
+
10
+ `get_design_context` output is a layout reference. It often contains Tailwind, hex, `rgb()`, palette props, extra fonts, and absolute positioning. Do not paste those. Snap every measurement onto the scales below.
11
+
12
+ ## Read the node
13
+
14
+ 1. From `https://figma.com/design/:fileKey/:fileName?node-id=1-2`, the node id is `1:2`.
15
+ 2. Follow `figma-design-to-code` before `get_design_context`. Request a screenshot in that call. If none comes back, call `get_screenshot`.
16
+ 3. When the response is sparse, fetch the visible child nodes before writing UI.
17
+ 4. Use `get_variable_defs` for type, spacing, radius, and color roles. Map each role to a component prop or an `--ad-*` token.
18
+
19
+ ## Colour
20
+
21
+ Never write a color as a hex, `rgb()` / `rgba()`, a palette prop (`color="blue"`, `c="gray.6"`, `c="dimmed"`, `bg="gray.0"`, `bg="white"`, `c="black"`), `var(--mantine-color-*)`, or a `style` / `styles` color. The only hex in the product is `#011B58`, and only in app chrome.
22
+
23
+ Color comes from a component variant, or from a CSS module on the component root:
24
+
25
+ ```css
26
+ .subtle {
27
+ background: var(--ad-color-bg-subtle);
28
+ color: var(--ad-color-text-dimmed);
29
+ border: 1px solid var(--ad-color-border-default);
30
+ }
31
+ ```
32
+
33
+ Map the Figma fill by role:
34
+
35
+ | Role in the frame | Use |
36
+ | --- | --- |
37
+ | Page or card surface | Leave the default, or `--ad-color-bg-default` |
38
+ | Secondary surface | `--ad-color-bg-subtle` |
39
+ | Recessed surface | `--ad-color-bg-muted` |
40
+ | Segmented control track | `--ad-color-bg-tinted` |
41
+ | Body text | Leave the default (`--ad-color-text-default`) |
42
+ | Secondary text | `--ad-color-text-dimmed` |
43
+ | Placeholder | `--ad-color-text-placeholder` |
44
+ | Text on a dark surface | `--ad-color-text-inverse` |
45
+ | Link | `--ad-color-text-link` |
46
+ | Border, hairline, strong border | `--ad-color-border-default`, `--ad-color-border-subtle`, `--ad-color-border-strong` |
47
+ | Focus or active input | `--ad-color-border-primary` |
48
+ | Tinted brand surface | `--ad-color-brand-light` |
49
+ | Solid brand-blue button | `Button` `variant="primary"`. One per view |
50
+ | Solid cyan button | `Button` `variant="secondary"` |
51
+ | White button, neutral border | `Button` `variant="default"` |
52
+ | Transparent, brand text and border | `Button` `variant="outline"` |
53
+ | Red destructive button | `Button` `variant="danger"` |
54
+ | Text-only button | `variant="link"` or `secret` |
55
+ | Green, red, yellow status | `color` `info`, `success`, `danger`, `pending`, or `default` on Alert, Badge, Chip, Indicator, Progress, or ThemeIcon |
56
+
57
+ `Alert` stays `variant="light"`. `warning` is a Badge variant, not an Alert color. Status needs an icon and text. Do not paint body text or a decorative shape with a status color. Do not rebuild a button, badge, or alert in CSS with `--ad-action-*` or `--ad-color-status-*`. Pass `disabled` for a disabled control. Do not invent a disabled color.
58
+
59
+ Allowed non-colour Mantine variables are `--mantine-{spacing,radius,font-size,line-height,shadow,z-index}-*`.
60
+
61
+ ## Components
62
+
63
+ Import from `@mantine/core` and `@mantine/dates`. Reach for these first.
64
+
65
+ - Buttons: `Button`, `ActionIcon`, `CloseButton`.
66
+ - Inputs: `TextInput`, `Textarea`, `NumberInput`, `ColorInput`, `Slider`, `Switch`, `SegmentedControl`, `Checkbox`, `Radio`, `RadioGroup`, `FileInput`, `Dropzone`, `DatePickerInput`.
67
+ - Combobox: `Select`, `Autocomplete`, `MultiSelect`, `Combobox`.
68
+ - Navigation: `Tabs`, `Breadcrumbs`, `NavLink`, `Stepper`, `Anchor`.
69
+ - Overlays: `Modal`, `Drawer`, `Menu`, `Popover`, `Tooltip`.
70
+ - Data: `Alert`, `Avatar`, `Badge`, `Card`, `Card.Section`, `Chip`, `Pill`, `Indicator`, `Progress`, `ThemeIcon`, `List`, `Skeleton`. Data grids are `src/components/Table`.
71
+ - Type: `Title`, `Text`, `Code`, `Kbd`. Misc: `Divider`, `Paper`.
72
+ - Layout: `Stack`, `Group`, `Box`, `SimpleGrid`, `Grid`, `Flex`, `Container`, `Center`.
73
+
74
+ `@appdirect/design-tokens` decides which Mantine imports are outside the system. When `ds/no-unadopted-mantine` warns, keep the import if this component is required, prefer the replacement named in the warning, and tell the user it is outside the UX-approved list. `MantineProvider`, `createTheme`, and `DatesProvider` live only in `src/providers/` and `__setup__/`.
75
+
76
+ Buttons and inputs default to `size="sm"` and `radius="sm"`. Button variants are `primary`, `secondary`, `default`, `outline`, `danger`, `link`, and `secret`. Never `filled`, `light`, `subtle`, `transparent`, `white`, or `gradient`. ActionIcon variants are `default`, `outline`, and `link`. Badge and Alert radius stay `sm`. Avatar stays circular.
77
+
78
+ In-app navigation is `component={Link}` on `Anchor`, `Card`, or `Button`. A clickable card is that component, not a `Box` with an `onClick`.
79
+
80
+ ## Type
81
+
82
+ Two families only. Inter is already the UI font. `Code` is Roboto Mono for ids, timestamps, and other data. Do not add a font face.
83
+
84
+ | Figma text | Use |
85
+ | --- | --- |
86
+ | Page title | `Title` `order={1}`. One per page |
87
+ | Section or card title | the next `order`. Never skip a level |
88
+ | Body | `Text` `size="md"` |
89
+ | Metadata, captions | `Text` `size="sm"` |
90
+ | Button, tab, and field labels | `Text` `size="sm"` `fw={600}` |
91
+ | Ids and timestamps | `Code` |
92
+
93
+ Do not set `size="16px"` or a CSS `font-size` in pixels. Headings are weight 700, body 400, labels 600. A smaller heading keeps its `order` and sets `size` (`order={2}` `size="h4"`). The heading scale in `docs/DESIGN.md` is h1–h6.
94
+
95
+ ## Layout, spacing, radius, shadow
96
+
97
+ Map Figma auto-layout to layout components. Column → `Stack`. Row → `Group`. Grid → `SimpleGrid` or `Grid`. Padding-only frame → `Box`. Do not use a `div` with flex or grid styles.
98
+
99
+ Spacing props are `none` and `xxs` through `xxl`, or `var(--ad-spacing-*)` in a CSS module. Snap Figma pixels to that scale: `xxs` 4, `xs` 10, `sm` 12, `md` 16, `lg` 20, `xl` 32. Card padding is `md`, section gaps `lg`, page padding `xl`, label-to-input gap `xs`.
100
+
101
+ Radius defaults to `sm` (4px) on buttons, inputs, cards, badges, modals, and drawers. `xs` 2, `md` 8, `lg` 16, `xl` 32 only when the frame clearly uses that step. `full` is Avatar only.
102
+
103
+ A Figma drop shadow becomes `shadow="xs"|"sm"|"md"|"lg"|"xl"` on an interactive layer (hover card, menu, modal), or `var(--ad-shadows-*)`. Flat sections use a border or a surface token. No raw `box-shadow`.
104
+
105
+ Styling order:
106
+
107
+ 1. Design-system props (`variant`, `size`, `radius` where that component owns them).
108
+ 2. Mantine style props that are not colors (`w`, `h`, `p`, `m`, `gap`, `align`, `justify`, `fw`).
109
+ 3. A CSS module using `--ad-*`, attached with `className` on the component root.
110
+
111
+ Never `style`, `styles`, `vars`, or `classNames` on design-system components. Never Tailwind. Do not add screen CSS to `src/providers/MantineProviderWrapper/global.css`.
112
+
113
+ ## Icons
114
+
115
+ Product icons are Remix (`@remixicon/react`, or `remixicon/icons/**.svg` via SVGR). Tabler stays inside Mantine internals. `@appdirect/ad-svg-icons` is legacy, only when Remix has no suitable icon. Size with the `size` number prop: 12, 14, 16, 18, or 20. Do not resize an icon in CSS.
116
+
117
+ ```tsx
118
+ <Stack gap="md">
119
+ <Group justify="space-between">
120
+ <Title order={3}>Invoices</Title>
121
+ <Button variant="primary">Create invoice</Button>
122
+ </Group>
123
+ <Paper withBorder p="md" radius="sm" className={classes.panel}>
124
+ <Text size="sm" className={classes.meta}>Due today</Text>
125
+ </Paper>
126
+ </Stack>
127
+ ```
128
+
129
+ ```tsx
130
+ /* Never: palette, hex, pixel type, or a style color */
131
+ <Button variant="filled" color="blue">Create invoice</Button>
132
+ <Box bg="gray.1" c="gray.6" />
133
+ <Text size="16px" style={{ color: "#868e96" }}>Due today</Text>
134
+ ```
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: figma-to-page
3
+ description: Ask which prototype and which Figma node, then copy that frame onto one page. Use when a designer wants to turn a Figma frame into a prototype page.
4
+ ---
5
+
6
+ # Figma node to a page
7
+
8
+ Ask, then copy. Ask one question at a time and wait. If they already answered in the same message, use that answer and skip the question.
9
+
10
+ One node becomes one page. If they pasted several node URLs, copy the first, then stop and tell them to paste the next.
11
+
12
+ ## Ask
13
+
14
+ 1. **Which prototype.** If this workspace is already one prototype — `prototype.json` or `standalone/standalone.config.ts` is at the root, and this is not the platform repo — use that folder and do not ask. If this workspace is ad-design-prototype, run `npm run proto -- list` and ask which `owner/slug`. Work only in `prototypes/<owner>/<slug>/`. If the list is empty, stop and tell them to run `/create-prototype` first.
15
+ 2. **Figma URL.** A `figma.com/design/` or `figma.com/file/` link with a `node-id`. The file key is the segment after `/design/` or `/file/`. The node id is the `node-id` query (`1-2` becomes `1:2`). If the link has no node id, ask which frame to copy.
16
+ 3. **Which page.** Read `standalone/standalone.config.ts` `pages` and `routePaths` in `src/navigation/router.tsx`. Ask whether this frame replaces one of those pages or is a new page. If there is one page other than `/hello-ts`, offer that path as the default.
17
+ 4. **New page only.** Ask the path (it must start with `/`) and the nav label. Keep the menu and section already in `standalone.config.ts`. Ask for a different section only if they say this page belongs somewhere else. Then list each `collectionName` from `standalone/mocks/navigation/<file>.json`.
18
+
19
+ ## Copy
20
+
21
+ 1. Follow `figma-mcp-integration` for that node, and follow `figma-design-to-code` before calling `get_design_context`. Build the screen with the design system in `AGENTS.md`.
22
+ 2. Put the screen in `src/pages/<Name>/`. Add or update its route in `src/navigation/router.tsx` and `routePaths`.
23
+ 3. Register or update it in `standalone/standalone.config.ts` `pages`: `path`, `label`, `iconType`, `namespace`, `collection`. `collection` is a `collectionName` from the menu file that namespace loads.
24
+ 4. Stop. Tell them the prototype and the path. If the prototype is already running, include `http://localhost:<port><path>`. Do not add another frame in the same turn.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: mantine-combobox
3
+ description: >
4
+ Build custom dropdown/select/autocomplete/multiselect components using Mantine's Combobox
5
+ primitives. Use this skill when: (1) creating a new custom select-like component with
6
+ Combobox primitives, (2) building a searchable dropdown, (3) implementing a multi-select
7
+ or tags input variant, (4) customizing option rendering, (5) adding custom filtering logic,
8
+ or (6) any task involving useCombobox, Combobox.Target, Combobox.Option, or Combobox.Dropdown.
9
+ ---
10
+
11
+ # Mantine Combobox Skill
12
+
13
+ ## Overview
14
+
15
+ `Combobox` provides low-level primitives for building any select-like UI. The built-in
16
+ `Select`, `Autocomplete`, and `TagsInput` components are all built on top of it.
17
+
18
+ ## Core Workflow
19
+
20
+ ### 1. Create the store
21
+
22
+ ```tsx
23
+ const combobox = useCombobox({
24
+ onDropdownClose: () => combobox.resetSelectedOption(),
25
+ onDropdownOpen: () => combobox.selectFirstOption(),
26
+ });
27
+ ```
28
+
29
+ ### 2. Render structure
30
+
31
+ ```tsx
32
+ <Combobox store={combobox} onOptionSubmit={handleSubmit}>
33
+ <Combobox.Target>
34
+ <InputBase
35
+ component="button"
36
+ pointer
37
+ rightSection={<Combobox.Chevron />}
38
+ onClick={() => combobox.toggleDropdown()}
39
+ >
40
+ {value || <Input.Placeholder>Pick value</Input.Placeholder>}
41
+ </InputBase>
42
+ </Combobox.Target>
43
+ <Combobox.Dropdown>
44
+ <Combobox.Options>
45
+ {options.map((item) => (
46
+ <Combobox.Option value={item} key={item}>{item}</Combobox.Option>
47
+ ))}
48
+ </Combobox.Options>
49
+ </Combobox.Dropdown>
50
+ </Combobox>
51
+ ```
52
+
53
+ ### 3. Handle submit
54
+
55
+ ```tsx
56
+ const handleSubmit = (val: string) => {
57
+ setValue(val);
58
+ combobox.closeDropdown();
59
+ };
60
+ ```
61
+
62
+ ## Target Types
63
+
64
+ | Scenario | Use |
65
+ |---|---|
66
+ | Button trigger (no text input) | `<Combobox.Target targetType="button">` |
67
+ | Input trigger | `<Combobox.Target>` (default) |
68
+ | Pills + separate input (multi-select) | `<Combobox.DropdownTarget>` + `<Combobox.EventsTarget>` |
69
+
70
+ ## References
71
+
72
+ - **[`references/api.md`](references/api.md)** — Full API: `useCombobox` options and store, all sub-component props, CSS variables, Styles API selectors
73
+ - **[`references/patterns.md`](references/patterns.md)** — Code examples: searchable select, multi-select with pills, groups, custom rendering, clear button, form integration
@@ -0,0 +1,199 @@
1
+ # Combobox API Reference
2
+
3
+ ## Table of Contents
4
+ - [useCombobox hook](#usecombobox-hook)
5
+ - [Combobox (root)](#combobox-root)
6
+ - [Sub-components](#sub-components)
7
+ - [CSS variables & Styles API](#css-variables--styles-api)
8
+
9
+ ---
10
+
11
+ ## useCombobox hook
12
+
13
+ ```tsx
14
+ const combobox = useCombobox(options?: UseComboboxOptions);
15
+ ```
16
+
17
+ **Options:**
18
+ ```ts
19
+ interface UseComboboxOptions {
20
+ defaultOpened?: boolean;
21
+ opened?: boolean;
22
+ onOpenedChange?: (opened: boolean) => void;
23
+ onDropdownClose?: (eventSource: 'keyboard' | 'mouse' | 'unknown') => void;
24
+ onDropdownOpen?: (eventSource: 'keyboard' | 'mouse' | 'unknown') => void;
25
+ loop?: boolean; // Default: true — keyboard nav wraps at boundaries
26
+ scrollBehavior?: ScrollBehavior; // Default: 'instant'
27
+ }
28
+ ```
29
+
30
+ **Returned store:**
31
+ ```ts
32
+ interface ComboboxStore {
33
+ // Dropdown state
34
+ dropdownOpened: boolean;
35
+ openDropdown(eventSource?: 'keyboard' | 'mouse' | 'unknown'): void;
36
+ closeDropdown(eventSource?: 'keyboard' | 'mouse' | 'unknown'): void;
37
+ toggleDropdown(eventSource?: 'keyboard' | 'mouse' | 'unknown'): void;
38
+
39
+ // Option keyboard navigation
40
+ selectActiveOption(): string | null;
41
+ selectFirstOption(): string | null;
42
+ selectNextOption(): string | null;
43
+ selectPreviousOption(): string | null;
44
+ resetSelectedOption(): void;
45
+ clickSelectedOption(): void;
46
+ updateSelectedOptionIndex(
47
+ target?: 'active' | 'selected' | number,
48
+ options?: { scrollIntoView?: boolean }
49
+ ): void;
50
+
51
+ // Programmatic focus
52
+ focusSearchInput(): void;
53
+ focusTarget(): void;
54
+ }
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Combobox (root)
60
+
61
+ ```tsx
62
+ <Combobox
63
+ store={combobox} // required — ComboboxStore from useCombobox()
64
+ onOptionSubmit={fn} // (value: string, optionProps) => void
65
+ size="sm" // MantineSize | string, default: 'sm'
66
+ dropdownPadding={4} // number, default: 4
67
+ resetSelectionOnOptionHover // boolean
68
+ readOnly // boolean — disables all interactions
69
+ // + all Popover props (position, offset, width, withinPortal, etc.)
70
+ />
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Sub-components
76
+
77
+ ### Combobox.Target
78
+ ```tsx
79
+ <Combobox.Target
80
+ targetType="input" // 'button' | 'input', default: 'input'
81
+ withKeyboardNavigation // boolean, default: true
82
+ withAriaAttributes // boolean, default: true
83
+ withExpandedAttribute // boolean, default: false
84
+ autoComplete="off" // string
85
+ >
86
+ {/* single child — the trigger element */}
87
+ </Combobox.Target>
88
+ ```
89
+
90
+ Use `targetType="button"` when the trigger is a button (Space key toggles dropdown).
91
+
92
+ ### Combobox.DropdownTarget
93
+ Marks the element used for dropdown positioning when separate from the keyboard events target. Used together with `Combobox.EventsTarget` in multi-select/pills patterns.
94
+
95
+ ### Combobox.EventsTarget
96
+ Receives keyboard events for dropdown navigation. Used alongside `Combobox.DropdownTarget` when the typing input is nested inside the trigger (e.g. inside `PillsInput`).
97
+
98
+ ### Combobox.Dropdown
99
+ ```tsx
100
+ <Combobox.Dropdown hidden={false}>
101
+ {/* dropdown content */}
102
+ </Combobox.Dropdown>
103
+ ```
104
+
105
+ Use `hidden` to hide without unmounting (preserves scroll position).
106
+
107
+ ### Combobox.Options
108
+ ```tsx
109
+ <Combobox.Options labelledBy="some-label-id">
110
+ {/* Combobox.Option or Combobox.Group elements */}
111
+ </Combobox.Options>
112
+ ```
113
+
114
+ ### Combobox.Option
115
+ ```tsx
116
+ <Combobox.Option
117
+ value="react" // string | number, required
118
+ active={false} // visually marks as selected; used by selectActiveOption()
119
+ disabled={false}
120
+ >
121
+ React
122
+ </Combobox.Option>
123
+ ```
124
+
125
+ ### Combobox.Search
126
+ Built-in search input, wired to keyboard navigation. Renders sticky at top of dropdown.
127
+
128
+ ```tsx
129
+ <Combobox.Search
130
+ value={search}
131
+ onChange={(e) => setSearch(e.currentTarget.value)}
132
+ placeholder="Search..."
133
+ withAriaAttributes // boolean, default: true
134
+ withKeyboardNavigation // boolean, default: true
135
+ // + all Input props
136
+ />
137
+ ```
138
+
139
+ ### Combobox.Empty
140
+ ```tsx
141
+ <Combobox.Empty>Nothing found</Combobox.Empty>
142
+ ```
143
+
144
+ ### Combobox.Group
145
+ ```tsx
146
+ <Combobox.Group label="Frontend">
147
+ <Combobox.Option value="react">React</Combobox.Option>
148
+ </Combobox.Group>
149
+ ```
150
+
151
+ ### Combobox.Header / Combobox.Footer
152
+ ```tsx
153
+ <Combobox.Header>Custom header</Combobox.Header>
154
+ <Combobox.Footer>Custom footer</Combobox.Footer>
155
+ ```
156
+
157
+ ### Combobox.Chevron
158
+ ```tsx
159
+ <Combobox.Chevron size="sm" error={error} color="blue" />
160
+ ```
161
+
162
+ ### Combobox.ClearButton
163
+ ```tsx
164
+ <Combobox.ClearButton onClear={() => setValue(null)} />
165
+ ```
166
+
167
+ ### Combobox.HiddenInput
168
+ ```tsx
169
+ <Combobox.HiddenInput
170
+ value={value} // string | number | (string | number)[] | null
171
+ valuesDivider="," // string, default: ','
172
+ name="myField"
173
+ form="myForm"
174
+ />
175
+ ```
176
+
177
+ ---
178
+
179
+ ## CSS variables & Styles API
180
+
181
+ ### CSS variables (set on root element)
182
+ | Variable | Description |
183
+ |---|---|
184
+ | `--combobox-option-fz` | Option font size (driven by `size` prop) |
185
+ | `--combobox-option-padding` | Option padding (driven by `size` prop) |
186
+ | `--combobox-padding` | Dropdown padding (driven by `dropdownPadding`, default 4px) |
187
+
188
+ ### Styles API selectors
189
+ | Selector | Element |
190
+ |---|---|
191
+ | `dropdown` | Dropdown container |
192
+ | `options` | Options listbox |
193
+ | `option` | Individual option |
194
+ | `search` | Search input |
195
+ | `empty` | Nothing found message |
196
+ | `header` | Dropdown header |
197
+ | `footer` | Dropdown footer |
198
+ | `group` | Group container |
199
+ | `groupLabel` | Group label text |