You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 37791a2
Browse filesBrowse the repository at this point in the historyBrowse files
feat(elements): generate a Custom Elements Manifest at build time (#3150)
* feat(elements): generate a Custom Elements Manifest at build time
`pnpm --filter reka-ui build` now writes `dist/custom-elements.json`
(schema 2.1.0) from the element registry the runtime uses: the built
`rekaElementFamilies` and `getPartMeta()`, so tags, attributes,
properties and events are exactly what `defineRekaElements()` defines.
Types, descriptions and defaults come from the docs' generated
component meta and the component pages.
`package.json` points to it with `customElements`, and exports it as
`reka-ui/custom-elements.json`. A test checks the generator and the
built file against the live registry, per tag.
Closes#3080
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: document the custom elements manifest, and that every family is available
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/content/docs/guides/custom-elements.md
+47-3Lines changed: 47 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Use Reka UI primitives outside Vue, as standard custom elements, from plain HTML
11
11
12
12
<Callouttype="warning"title="Experimental">
13
13
14
-
`reka-ui/elements` is experimental. It covers a first set of families, and its API may change before it is marked stable.
14
+
`reka-ui/elements` is experimental. Its API may change before it is marked stable.
15
15
16
16
</Callout>
17
17
@@ -627,6 +627,51 @@ Element types for the default-prefixed tags are opt-in, through a types-only ent
627
627
628
628
`reka-ui/elements/global` has no JavaScript: reference it from a `.d.ts` file or with `import type {} from 'reka-ui/elements/global'`, not with a runtime `import`. With a custom prefix, declare your tags from `RekaElementTagNameMap` yourself.
629
629
630
+
## Custom Elements Manifest
631
+
632
+
The package ships a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) (schema 2.1.0) for editors, documentation tools and linters. `package.json` points to it (`"customElements": "dist/custom-elements.json"`), and it is exported as `reka-ui/custom-elements.json`.
633
+
634
+
It is generated at build time from the registry `defineRekaElements()` reads, so it lists every element of every family, with the default `reka` prefix:
635
+
636
+
-**Attributes**, with the value each one takes (`'horizontal' | 'vertical'`, a boolean flag, an ISO 8601 string for a date) and the property it sets.
637
+
-**Properties**, with their TypeScript types, including the ones that have no attribute (`handle`, `filter`, …).
638
+
-**Events**, typed as `RekaElementEvent<Value, Details>`. The cancelable ones (`before-update-*`, and the ones that carry a DOM event) say so.
639
+
-**Descriptions and defaults** from the component's API reference.
640
+
641
+
The element classes are created by `defineRekaElements()`. Their names in the manifest (`DialogRootElement`, …) identify the tags: they are not exports.
642
+
643
+
**VS Code.**[`custom-element-vs-code-integration`](https://www.npmjs.com/package/custom-element-vs-code-integration) turns the manifest into HTML custom data, for tag and attribute completion, attribute values and hover docs in HTML files:
**Storybook.** With the web components framework, give the manifest to `setCustomElementsManifest()`. A story whose `component` is a tag (`component:'reka-dialog-root'`) gets its attributes, properties and events in the args table, and its description on the docs page:
With a custom prefix, the manifest still names the `reka-` tags.
674
+
630
675
## React
631
676
632
677
React 19 sets props as properties on custom elements when one exists, and listens to custom events with `on<event-type>`, in the event's own casing:
@@ -716,7 +761,7 @@ Bind props in camelCase (`:modelValue="checked"`, or `:modelValue.prop` to force
716
761
717
762
## Limitations
718
763
719
-
-**Families.**Only the families listed above are available. The rest will follow.
764
+
- **Families.** Every public family is available, except `Label` (below). The utility components (`Primitive`, `Presence`, `FocusScope`, `RovingFocusGroup`, `Viewport`) are building blocks for Vue components and have no elements.
720
765
- **Parts a custom element can't be.** These parts render a native element whose behaviour a custom element can't take on, so they aren't available:
721
766
- `Label`: a `<label>`. Its `for` only labels a control when it's on a native `<label>`. Use a native `<label for>`: it labels Reka form elements, which are form-associated. (`<reka-field-label>` works, through `aria-labelledby`.)
722
767
- `AvatarImage`: an `<img>`. A custom element can't display an image source. `<reka-avatar-root>` and `<reka-avatar-fallback>` work.
@@ -734,5 +779,4 @@ Bind props in camelCase (`:modelValue="checked"`, or `:modelValue.prop` to force
734
779
- **Temporal.** Date families need a global `Temporal`, like the Vue components.
735
780
- **SSR.** Server rendering and declarative shadow DOM are not supported. Elements render on the client after they are defined.
736
781
- **Bundler required.** See the [quick start](#quick-start).
737
-
-**Custom Elements Manifest.** Not generated yet.
738
782
- **Vue version.** Tested on Vue 3.5. With older versions generated ids are not unique between elements, and a warning says so in development.
0 commit comments