Box
Alpha.8 adds the experimental motionSurface prop for visual effects and retained collection targets. It can coexist with motionRegion; both retain their own lifetime. See visual motion for the Jolt RC.11 requirement; this is included in alpha.8.
m-box · Layer content in a single area.
Usage
<m-box :height="160" radius="lg" backgroundColor="#202C25">
<m-column padding="lg"><m-text>Background layer</m-text></m-column>
<m-column justify="end" align="end" padding="md">
<m-button size="sm">Open</m-button>
</m-column>
</m-box>API
| Prop | Type | Default | Purpose |
|---|---|---|---|
radius | token / number | none | Area corners. |
backgroundColor | string | — | Optional background color. |
borderWidth | number | — | Width of the solid border in layout units. |
borderColor | string | — | Border color. |
perspective | number | — | Projection distance for the rotateX/rotateY of direct children. See paths, depth and shadows. |
sharedTag | string | — | Experimental. Identity for shared navigation: one per screen, a letter then up to 99 letters, digits, _, . or -. Not together with motionSurface. |
width / height | number / auto / % | auto | Area dimensions. |
All children share the same area; the last child is drawn on top. Use Row and Column inside each layer to position content. Box does not expose a table grid with rows and columns.
Without height, Box takes the height of its tallest layer, so a background layer can sit behind content-sized controls. With an explicit height, or when a Row stretches it, layers without their own size fill the Box. A layer with its own width or height starts at the top left of the content area, inside padding; percentage sizes use that area. A raw NativeScript GridLayout without rows fills the available height instead; give it rows="auto" or use Box.
A Text placed directly in Box starts at the top of its layer. To center text vertically, put it in a Column with justify="center"; use Row or Column to position controls within a layer.
Composition props
padding, paddingX, paddingY, radius, grow, shrink, width, height and backgroundColor are also accepted. paddingX and paddingY override their respective sides. Row, Column and Box start without padding; Card starts at lg. grow defaults to 0; shrink follows the parent context. A prop that is not given leaves its style untouched, so a plain attribute such as paddingTop or borderRadius, or CSS on the Web, keeps applying across renders; once a prop is given it owns that style.
Since RC.18, borderWidth and borderColor also draw the Box border on Web. The ColorPicker palette shows it on each swatch.
Full example
This file also runs in the NativeScript catalog and the Web preview.
View source
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
const { t } = useCatalogLocale()
withDefaults(defineProps<{ lang?: 'en' | 'pt' }>(), { lang: 'pt' })
const { theme } = useMavisTheme()
</script>
<template>
<m-box :height="180" radius="lg" :backgroundColor="theme.colors.elevated">
<m-column padding="lg">
<m-text variant="display" tone="primary">01</m-text>
<m-text variant="caption" tone="muted">{{
t(lang === 'pt' ? 'Camada de fundo' : 'Background layer')
}}</m-text>
</m-column>
<m-column align="end" justify="end" padding="md">
<m-card padding="sm" radius="sm">
<m-text variant="caption">{{ t(lang === 'pt' ? 'Por cima' : 'On top') }}</m-text>
</m-card>
</m-column>
</m-box>
</template>