Share a screen with the Web
Mavis now has experimental implementations for NativeScript-Vue and Vue Web. The catalog uses the same example files and application state in both builds. Larger compositions live in the Showcase section.
Open the catalog in your browser ↗
The Web version renders HTML controls with keyboard support, focus indicators, and accessible names. The native version keeps NativeScript views and Jolt. The release candidate is available for testing in real apps.
Run it locally
From a checkout, with Node 22 or later:
npm ci
npm run build
npm run web:devOpen the /playground/ URL printed by Vite. The Web example needs no native SDK. To run the same screens on a device, follow the native example instructions.
What is shared
| Part | Location |
|---|---|
| Theme values, spacing and slider step rules | packages/core/src |
| Vue theme context and common component types | packages/core/src/vue |
| Both screen templates and their behavior | examples/catalog/shared/pages |
| Catalog state and navigation interface | examples/catalog/shared/context.ts |
| Native rendering and Jolt integration | packages/nativescript/src |
| HTML rendering and browser styles | packages/web/src |
Shared screens import Vue APIs from vue, themes from @getcortexlabs/mavis-core, and useMavisTheme from @getcortexlabs/mavis-core/vue. NativeScript's build resolves vue to its native renderer. Each app registers its own Mavis implementation once. If shared code imports core directly, declare @getcortexlabs/mavis-core@0.1.0-rc.21 as a dependency of each app.
For example, this template works in both:
<m-column gap="md" padding="lg">
<m-text as="h1" variant="title">Your temperature</m-text>
<m-slider v-model="temperature" :min="16" :max="28" :step="0.5" label="Temperature" />
<m-button @click="save">Save</m-button>
</m-column>temperature and save belong to the application. The component guide describes the common props. MText.as supplies heading semantics; it selects an HTML tag on the Web and a heading accessibility role on native. click is a platform-independent action with no event payload. Native events remain available separately when needed.
Register the Web implementation
In an existing Vue app, install the release candidate:
npm install @getcortexlabs/mavis-web@0.1.0-rc.21 @rafaelaugusto/jolt@0.1.0-rc.22Then register the components and load the CSS:
import { createApp } from 'vue'
import { createMavis, midnight } from '@getcortexlabs/mavis-web'
import '@getcortexlabs/mavis-web/style.css'
import App from './App.vue'
createApp(App).use(createMavis({ theme: midnight })).mount('#app')The stylesheet supplies focus indicators, box overlays, and motion. Theme changes remain scoped to each app. The Web package can also be imported during server rendering; it does not access browser globals when imported. The interactive catalog itself is a client-rendered app.
Navigation and motion
The shared catalog screens receive a small navigation interface. NativeScript uses vue-router-ns; the Web entry uses Vue Router. The demo uses hash routes so it can be hosted as static files, including direct access to its details screen.
Button/Card/Reveal now use Jolt 0.1.0-rc.22 in both renderers. Web now requires Jolt as a peer, without installing NativeScript. See motion and migration.
Portability limits
Use Mavis props and theme values for shared layout and styling. Numeric dimensions are density-independent units on native and CSS pixels on the Web. Platform attributes, raw CSS, native view references, and direct Jolt calls are specific to their environment.
The Web implementation has responsive layouts and native HTML keyboard behavior. Exact pixels, fonts, navigation transitions, and platform-specific controls can differ. Camera, files, notifications, and other device services still need application-level implementations for each target.
The shared collection includes forms, sheets, dialogs, feedback and composition; see the component catalog. Vue Web can also render through Nuxt SSR and static generation, with the alpha.8 hydration fixes described there. The support matrix separates current Vue renderers from planned frameworks and authorship tools.
For local component imports and selective Web icons, see modular installation.
Shared imports, navigation and source audit
Alpha.9 introduced a common #mavis import, app-owned navigation, a full --example directory and portability diagnostics. The reference covers Vue + Vite SPA, Nuxt SSR/SSG and NativeScript iOS/Android. See Share screens for setup, migration and release availability.
Semantic content and actions
For Web-only documents with their own typography, landmarks and branded controls, the experimental Web entry point exports three composition primitives. Their default slots accept rich Vue content and the site's CSS supplies layout and type.
<script setup lang="ts">
import { MWebButton, MWebElement, MWebLink } from '@getcortexlabs/mavis-web/experimental'
</script>
<template>
<MWebElement as="nav" aria-label="Account">
<MWebLink href="/profile">View <strong>profile</strong></MWebLink>
<MWebButton type="submit" form="preferences">Save preferences</MWebButton>
</MWebElement>
</template>MWebElement defaults to a div. It accepts document landmarks, headings, lists, tables, forms and inline formatting tags, with optional motion regions and surfaces. MWebButton supports form association, a loading state and an optional motion surface. CSS hover and press transitions remain under the stylesheet’s control when a motion surface is omitted. MWebLink uses the same URL and router navigation contract as MLink. Supply a meaningful accessible name through the slot or accessibilityLabel for an icon-only action. Keep interactive descendants outside an action. Portable views can continue to share MBox, MText, MButton and MLink across renderers.