Skip to content
getcortexlabsPublic

About

A UI library for NativeScript, starting with Vue. Components, motion with Jolt, and native navigation. In development.

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

1,135 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mavis UI

Vue components for native iOS, Android, macOS and Windows apps, and for the Web.

Mavis release candidate on npm Check library MIT license

English · Português · Live catalog · Releases

<script setup lang="ts">
import { ref } from 'vue'
import { MButton, MColumn, MScreen, MText } from '#mavis'

const count = ref(0)
</script>

<template>
  <MScreen>
    <MColumn padding="lg" gap="md">
      <MText as="h1" variant="title">Check-ins ({{ count }})</MText>
      <MButton @click="count++">Check in</MButton>
    </MColumn>
  </MScreen>
</template>

That screen runs on all five targets in a generated Mavis project. The #mavis import resolves to the renderer for the current app. On mobile it creates NativeScript views. On macOS it creates AppKit views, on Windows it creates XAML controls, and in a browser it produces HTML. The counter, event handler and template are shared. How shared screens work

The Vue catalog ships 99 components on Web and mobile. Native desktop implements 12 of those components, enough for the Directory starter’s search, details and editing flow. Direct NativeScript adapters for React, Angular, Svelte, Solid and plain JavaScript/TypeScript implement six foundation components. The CLI reports the contract for each target. Component reference · Platform support

Features

Install

New project. The creator can generate one target or a shared application. This creates a working Directory app for all five targets. Node 22.23.3 or later is required for the desktop and direct-framework starters.

npx @getcortexlabs/create-mavis@rc directory --targets web,native,macos,windows --example directory --no-install
cd directory
npm run install:apps
npm run dev:web

Edit shared/Directory.vue. Run npm run ios, npm run android, npm run macos or npm run windows on a host with the corresponding SDK. Use --web nuxt --rendering ssr or --rendering ssg to generate the Nuxt host. CLI options

Existing Vue Web app

npm install @getcortexlabs/mavis-web@rc @rafaelaugusto/jolt@0.1.0-rc.22
import { createApp } from 'vue'
import { createMavis } from '@getcortexlabs/mavis-web'
import '@getcortexlabs/mavis-web/style.css'
import App from './App.vue'

createApp(App).use(createMavis()).mount('#app')

Existing NativeScript-Vue app

npm install @getcortexlabs/mavis@rc @rafaelaugusto/jolt@0.1.0-rc.22
import { createApp } from 'nativescript-vue'
import { createMavis } from '@getcortexlabs/mavis/vue'
import App from './App.vue'

createApp(App).use(createMavis()).start()

Rebuild the native application after upgrading Jolt. Keep installed Mavis packages on the same version and commit the lockfile. The public rc channel contains prereleases. Release notes and compatibility

Platform support

Target Renderer Component coverage and output
iOS NativeScript-Vue 99 components. Native views, safe areas, keyboard insets and native navigation.
Android NativeScript-Vue 99 components. Native views, system back, keyboard handling and recycled list cells.
macOS NativeScript with AppKit 12 components. Standalone Apple Silicon .app with native controls, menus and keyboard shortcuts.
Windows NativeScript with XAML Islands 12 components. Native XAML controls, keyboard focus and a portable folder with its runtime.
Web Vue with Vite or Nuxt 99 components. HTML, browser input, production SSR and static generation.

The desktop set is MScreen, MColumn, MRow, MGrid, MText, MInput, MButton, MLink, MCard, MAlert, MEmptyState and MReveal. The examples below use the Vue Web and mobile catalog unless a desktop host is named. Check the installed creator for current target and property coverage.

npx @getcortexlabs/create-mavis@rc --capabilities --json

Working with Vue components

These examples use the components registered by createMavis() on Vue Web and NativeScript for iOS and Android. Each example can go in its own Vue single-file component.

Lay out a screen and label its sections

MColumn stacks its children. MRow places them side by side. Give the child that should take the remaining width :grow="1". Typography and semantics are independent. Here, variant="title" selects the theme style and as="h1" supplies a heading to the browser and mobile screen readers. Row · Text

<template>
  <MScreen scroll>
    <MColumn padding="lg" gap="md">
      <MText as="h1" variant="title">Directory</MText>
      <MRow gap="md" align="center">
        <MColumn :grow="1" gap="xs">
          <MText variant="heading">Recife</MText>
          <MText tone="muted">Brazil</MText>
        </MColumn>
        <MText variant="caption">Office</MText>
      </MRow>
    </MColumn>
  </MScreen>
</template>

Edit a value in a sheet

Bind the editor to a draft and the sheet to v-model:open. This example applies a trimmed name only when Save is pressed. Dismissing the sheet leaves the displayed name intact. MScreen hosts the native sheet on mobile. The Web sheet opens a modal dialog. Input · FormGroup · Sheet

<script setup lang="ts">
import { ref } from 'vue'

const name = ref('Recife')
const draft = ref('')
const open = ref(false)

function edit() {
  draft.value = name.value
  open.value = true
}

function save() {
  const value = draft.value.trim()
  if (!value) return
  name.value = value
  open.value = false
}
</script>

<template>
  <MScreen>
    <MColumn padding="lg" gap="md">
      <MText as="h1" variant="title">{{ name }}</MText>
      <MButton @click="edit">Edit office</MButton>
      <MSheet v-model:open="open" title="Edit office" gap="md">
        <MFormGroup label="Office details">
          <MInput v-model="draft" label="Office name" returnKey="done" @submit="save" />
        </MFormGroup>
        <MButton :disabled="!draft.trim()" @click="save">Save</MButton>
      </MSheet>
    </MColumn>
  </MScreen>
</template>

Render a long collection

Give MVirtualList a bounded viewport, a fixed row height and a unique key per item. The Web renderer mounts a window of rows. NativeScript recycles native list cells. Keep selection or edits in your data so they follow the item as its row is reused. Numeric dimensions are CSS pixels on Web and device-independent pixels on mobile. VirtualList

<script setup lang="ts">
const offices = Array.from({ length: 1000 }, (_, index) => ({
  id: 'office-' + index,
  name: 'Office ' + (index + 1),
}))
</script>

<template>
  <MVirtualList :items="offices" itemKey="id" :rowHeight="56" :height="336" label="Offices">
    <template #default="{ item }">
      <MText :text="item.name" />
    </template>
  </MVirtualList>
</template>

Reorder a short collection

MSortableList mounts every row and emits a new array through v-model when a move succeeds. The dedicated drag handle and the move buttons both update the same order. Supply a readable itemLabel for the controls. SortableList

<script setup lang="ts">
import { ref } from 'vue'

const stops = ref([
  { id: 'rec', name: 'Recife' },
  { id: 'ssa', name: 'Salvador' },
  { id: 'for', name: 'Fortaleza' },
])
</script>

<template>
  <MSortableList v-model="stops" itemKey="id" :itemLabel="stop => stop.name" label="Route stops">
    <template #default="{ item, index }">
      <MText>{{ index + 1 }}. {{ item.name }}</MText>
    </template>
  </MSortableList>
</template>

Move a card between columns

MKanban takes a flat array. Each card’s column identifies its lane. A filter changes which cards are visible while the column limit still counts the whole board.

<script setup lang="ts">
import { ref } from 'vue'
import type { KanbanCard } from '@getcortexlabs/mavis-core'

const query = ref('')
const columns = [
  { id: 'ideas', title: 'Ideas' },
  { id: 'making', title: 'Making', limit: 2 },
]
const cards = ref<KanbanCard[]>([
  { id: 'site', column: 'ideas', title: 'Studio website' },
])
</script>

<template>
  <MColumn gap="md">
    <MInput v-model="query" label="Filter projects" />
    <MKanban v-model="cards" :columns="columns" :query="query" label="Studio board" />
  </MColumn>
</template>

A successful move emits the new array and a move event carrying { id, from, to, before }. A full destination rejects the move. Keyboard and menu actions use the same model as dragging. Kanban API · Catalog implementation

Themes

defineTheme(overrides, base) inherits unspecified tokens and returns an immutable theme. A scoped provider changes only its descendants and adds no layout view.

<script setup lang="ts">
import { defineTheme, mavis } from '@getcortexlabs/mavis-core'

const studio = defineTheme({
  name: 'studio',
  colors: { primary: '#5636A8', onPrimary: '#FFFFFF' },
  radius: { md: 12 },
  typography: { title: { fontSize: 36 } },
}, mavis)
</script>

<template>
  <MThemeProvider :theme="studio">
    <MCard padding="lg"><MText variant="title">Studio notes</MText></MCard>
  </MThemeProvider>
</template>

At the app level, createMavis({ theme: mavis, darkTheme: midnight }) follows system appearance. On a server-rendered route, pass the same initial appearance to the server and the hydrating client. Theme tokens and appearance · Studio theme source

Motion and gestures

Built-in press feedback and sheet dragging are implemented by the renderer. For an interaction that crosses components, the experimental API lets the app describe how their gesture recognizers relate. This example gives the photo a two-finger pinch and lets the sheet wait for its pan.

<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { createMotionGesture, relateMotionGestures } from '@getcortexlabs/mavis-core/experimental'

defineProps<{ photoUrl: string }>()
const open = ref(false)
const sheet = createMotionGesture()
const photo = createMotionGesture()
const relation = relateMotionGestures([
  { gesture: sheet, other: photo, relation: 'waitFor', otherKind: 'pan' },
  { gesture: photo, kind: 'pinch', other: sheet, relation: 'block' },
])
onBeforeUnmount(() => relation.dispose())
</script>

<template>
  <MScreen>
    <MButton @click="open = true">Open photograph</MButton>
    <MSheet v-model:open="open" title="Above the clouds" :gesture="sheet">
      <MImage :src="photoUrl" alt="A mountain ridge" :zoom="3" :gesture="photo" />
    </MSheet>
  </MScreen>
</template>

The recognizers stay with their owning components. At minimum zoom the photo can yield a downward drag to the sheet. Removing the relation releases the coordination. For application-owned effects, createMotionSurface() exposes motion values, spring followers and property bindings on a declared surface. Gesture relations · Kinetic spring and drag recipe · Jolt

Navigation and server rendering

Shared screens can express a destination as <MCard href="/entries/library"> or call useMavisNavigation() in setup. The Web host supplies Vue Router, Nuxt supplies its request-owned router and the mobile host supplies vue-router-ns. Ordinary browser links retain their resolved URLs and modified-click behavior. The host keeps its own route guards and history. Routing and shared screens

For a Vue Web app that imports components locally, install just the shared services in the application entry point. Pass the app’s existing router through its navigation adapter.

import { createRouterNavigation } from '@getcortexlabs/mavis-core'
import { createMavisServices } from '@getcortexlabs/mavis-web/services'

app.use(createMavisServices({ navigation: createRouterNavigation(router) }))

In Nuxt, install the plugin per request. Seed the initial appearance from the request or prerender payload so the first client render matches the HTML. The acceptance app exercises production SSR, hydration, navigation and static pages served without a Node server. Nuxt setup · Tested Nuxt plugin

Native desktop

The two windows below run the same Directory.vue, routes and store. Search, navigation, edits and local persistence run inside each packaged application.

macOS · AppKit Windows · XAML Islands
Directory using native AppKit controls Directory using native Windows XAML controls

Run the matching pair in a generated desktop project.

# On macOS
npm run build:macos
npm run package:macos

# On Windows
npm run build:windows
npm run package:windows

The macOS preset produces an ad hoc signed .app. Windows produces an unsigned portable folder. Each package includes its runtime and runs without a development server. Desktop setup and packaging

Package entry points

Entry point Use it for
@getcortexlabs/mavis-core Themes, neutral component contracts, units, capabilities and router adapters.
@getcortexlabs/mavis-core/vue Shared Vue props, theme context and composables.
@getcortexlabs/mavis-core/experimental Scoped motion surfaces, gesture relations and other experimental APIs.
@getcortexlabs/mavis-web and @getcortexlabs/mavis/vue The Web and NativeScript-Vue renderers. Each also offers a /services entry for local component imports.
@getcortexlabs/mavis/native Direct NativeScript foundations for JavaScript or TypeScript.
@getcortexlabs/mavis-react-nativescript React NativeScript bindings for the six foundation components.
@getcortexlabs/mavis-angular-nativescript Angular NativeScript bindings for the same components.
@getcortexlabs/mavis-svelte-nativescript Svelte Native bindings.
@getcortexlabs/mavis-solid-nativescript Solid NativeScript bindings.
@getcortexlabs/create-mavis The project generator, target setup, environment doctor and portability checker.

Direct adapter imports and examples · Modular installs and icon bundles · Core contracts

Demos

These are excerpts from the English catalog recordings. Open the linked examples for the full playback and source.

iOS simulator and Android emulator. On iOS, a drag catches the Kinetic card during its spring. On Android, swiping the row exposes its Star and Archive actions.

Dragging and releasing a spring-driven card on iOS Revealing and activating the Star and Archive actions on Android

Web · reorder and transfer a Kanban card with the mouse

A Chromium pointer reorders a card and transfers it between columns

The live catalog also includes a vehicle dashboard, a sign-in flow with retained drafts and a themed editorial app.

Development

npm ci
npm run build
npm run web:dev          # interactive Web catalog
npm run typecheck
npm test
npm run docs:check-media
npm run docs:build

For native development, install the NativeScript toolchain, run npm ci in examples/catalog, then npm run ios or npm run android there. Release checks install the packed npm archives into clean Web and NativeScript projects. The performance reports name the workload, build configuration and device used for each measurement. Contributing · CI and release checks · Performance protocol

Mavis UI is built by Cortex Labs. Code and documentation are MIT licensed. Artwork and font credits

About

A UI library for NativeScript, starting with Vue. Components, motion with Jolt, and native navigation. In development.

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages