Framework Integration (React, Vue, etc.)
OAS-UI is a Web Components library. You do not need an official wrapper to use it. This page covers native usage per framework, common pitfalls, and optional integrations. It does not introduce a new component wrapper layer.
Verified integration paths include React, Vue, Svelte, Angular, Astro, Next.js, Nuxt, and others; frameworks not listed here can use the native Web Components API directly.
Choose a path
| Scenario | Recommended approach |
|---|---|
| React 19 | Native <oas-*>; bind events with on + all-lowercase event name (onoas-submit) |
| React 17/18, or camelCase event names | Vendor the two hooks from the in-repo @oas-ui/react (~100 lines; not published to npm, see below) |
| Vue 3 | Set compilerOptions.isCustomElement, use <oas-*> directly, bind @oas-* events |
| Svelte 5 | Event attributes, e.g. onoas-click={...} (case-sensitive; kebab-case preserved); Svelte 4 uses on:oas-click (legacy) |
| Angular | schemas: [CUSTOM_ELEMENTS_SCHEMA]; events (oas-click) and properties [options] bind directly |
| Astro | Zero special handling: write tags in HTML, register in a page <script> (islands follow each framework's section) |
| Others (SolidJS, etc.) | No special handling needed; framework-specific interop sections are added when real usage appears |
| Next.js App Router | Use the RSC/DSD integration in @oas-ui/next (see SSR strategy) |
| Nuxt 3 | Use the @oas-ui/nuxt module (auto isCustomElement + theme CSS + client component registration + server-only SSR helpers) |
Register components
import '@oas-ui/theme'
import '@oas-ui/ui' // register everythingOn demand:
import '@oas-ui/theme'
import '@oas-ui/ui/basic/button'React
Events
React 19 maps Custom Element events only for the "on + all-lowercase literal" spelling:
<oas-button type="primary" onoas-submit={(e) => console.log(e.detail)}>
Submit
</oas-button>CamelCase onOasSubmit is not mapped to oas-submit; do not rely on it.
React 17/18 requires manual addEventListener. The repo's packages/react holds a reference implementation of useOasEvent / useOasEvents (two hooks, ~100 lines, MIT/Apache-2.0) — it is not published to npm, and there is no plan for any framework wrapper / bridge package (assessment: React's native custom-element support keeps improving; a bridge is a shrinking interop gap and not worth an official dependency). When you need the camelCase spelling, copy the two hooks into your project:
import { useRef } from 'react'
import { useOasEvent } from '@oas-ui/react'
const ref = useRef<HTMLElement | null>(null)
useOasEvent(ref, 'oas-submit', (detail) => console.log(detail))Complex data and boolean attributes
- Strings/numbers: write them as JSX attributes.
- Arrays/objects: prefer assigning the property through a
ref; otherwise you may write[object Object]into an attribute:
const tableRef = useRef<HTMLElement & { columns?: unknown; data?: unknown }>(null)
useEffect(() => {
if (!tableRef.current) return
tableRef.current.columns = columns
tableRef.current.data = rows
}, [columns, rows])
return <oas-table ref={tableRef} />- Boolean attributes use presence semantics:
<oas-ellipsis expanded>means expanded; remove the attribute (or follow the component docs forfalse) to collapse. - To use
oas-*tags directly in TypeScript, augmentJSX.IntrinsicElements; see the@oas-ui/reactREADME for an example.
Global attributes and the property channel (title, verified)
React 19 assigns existing property names on Custom Elements (title / dir / lang …) as properties (el.title = v) instead of setAttribute. For title specifically — a reflecting HTMLElement property — the assignment synchronously reflects into the same-named attribute, so the component's attribute channel is triggered as usual.
Verified in Chromium (2026-11-04): oas-modal / oas-drawer receive title through both channels; in React just write <oas-modal title="…"> — no workaround needed. One easily-misread detail: these two components consume title — after rendering it into the internal title bar they remove the attribute (to avoid the browser's native tooltip), so not seeing a title attribute left in the DOM is expected behavior, not a failure. Judge by the rendered title bar.
// Just write it (property → reflected attribute → consumed by the component)
<oas-modal title="Details" />Three scenarios that genuinely need attention:
- How to verify: judge
titleby the rendered title bar, not by whether the attribute remains (consuming components remove it). - When authoring your own custom elements: avoid names colliding with read-only properties or methods of
Element/HTMLElement(e.g.prefixvs read-onlyElement.prefix,blurvs the method); shadow them with property accessors when necessary — see the collision section in Integration FAQ for how this library normalizesprefix/suffix/blur. - Plain elements that don't consume
title: atitleattribute triggers the browser's native tooltip (framework-independent).
Vue 3
Vue templates can use Custom Elements directly. The only required compiler setting is:
// vite.config.ts
import vue from '@vitejs/plugin-vue'
export default {
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('oas-'),
},
},
}),
],
}<oas-button type="primary" @oas-click="onClick">Button</oas-button>- Events: bind
@oas-*directly. - Complex data:
:columns="columns"/:data="rows"use the property path; a static JSON attribute also works. v-modelis not natively supported: Custom Elements do not followmodelValue / update:modelValue. Use:value+@oas-change, or wrap it in a local business component.
Nuxt 3 uses the module and does not need the manual isCustomElement config:
export default defineNuxtConfig({
modules: ['@oas-ui/nuxt'],
})Svelte
Svelte 5 listens through event attributes, which are case-sensitive — onoas-click listens to oas-click as-is (kebab-case preserved; spelling it onoasclick would listen to a different event, oasclick, and never receive what the component dispatches):
<oas-button type="primary" onoas-click={(e) => console.log(e.detail)}>Save</oas-button>- Svelte 4's
on:oas-clickdirective still works but is listed as legacy in Svelte 5; new code should use event attributes. - Complex data (arrays/objects): attribute expressions are stringified into attributes — take the element with
bind:thisand assign the property in a$effect:
<script>
let el = $state(null)
$effect(() => {
if (el) el.columns = columns
})
</script>
<oas-table bind:this={el} />bind:valuedoes not sync with the component: Svelte's binding writes back viainput/change, while the component dispatchesoas-change— sync manually withonoas-change(same caveat as Vue'sv-model).
Angular
The one required setting: add CUSTOM_ELEMENTS_SCHEMA to the schemas of a standalone component (the Angular 17+ default) or an NgModule, then write <oas-*> directly in templates:
import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core'
@Component({
selector: 'app-root',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `<oas-button type="primary" (oas-click)="onClick($event)">Save</oas-button>`,
})
export class AppComponent {
onClick(e: Event) {
console.log((e as CustomEvent).detail)
}
}- Events:
(oas-click)="handler($event)"works natively ($eventis the CustomEvent; read data via.detail). - Data binding:
[options]="rows"writes the DOM property when it exists — bind objects/arrays directly without serializing. ngModeldoes not apply (no ControlValueAccessor bridge): sync manually with[value]+(oas-change).
Astro
Astro is an HTML-first MPA with islands — zero special handling: write <oas-*> directly in .astro files and register components in a page <script> (Astro bundles the script and runs it once per page by default):
<oas-button type="primary">Save</oas-button>
<script>
import '@oas-ui/theme'
import '@oas-ui/ui/basic/button'
</script>For interactive components inside islands (React / Vue / Svelte), follow the matching framework section above. SolidJS and other frameworks likewise need no special handling — register and use directly.
SSR / DSD
- Nuxt:
@oas-ui/nuxt. - Next.js:
@oas-ui/next. - Other SSR setups: see SSR strategy for client registration, DSD hydration, and
isCustomElementtiming.
Common pitfalls
- Event names keep the
oas-prefix: components dispatchoas-change/oas-submit; listening forchange/submitwill not work. - Attribute vs property: prefer properties for arrays/objects; strings/numbers can use attributes.
- Boolean empty strings: Vue writes
''for static<oas-ellipsis expanded>; components treat presence as true. Do not useexpanded="false"to disable; follow the component docs. - Register before hydration: do not assign properties to an unupgraded element; wait for
customElements.whenDefined('oas-*')or use a framework integration package. ::part()cannot be chained with pseudo-classes:::part(item):hoverdoes not work; use::part(item)plus the component's internal state attributes.- Global attributes and the property channel: React assigns native property names such as
titleas properties, buttitleis a reflecting property (the assignment becomes an attribute synchronously) —oas-modal/oas-drawerreceive it through both channels and consume it (the attribute is removed after rendering; not seeing it left in the DOM is expected). See Global attributes and the property channel above.