Skip to content

<Box>

A flexbox container — the terminal equivalent of a <div>. It maps to OpenTUI's box renderable, which owns layout (real flexbox), borders, padding/margin and background natively. Children go in the default slot.

vue
<script setup lang="ts">
import { Box, Text } from 'vue-termui'
</script>

<template>
  <Box border borderStyle="rounded" :padding="1" flexDirection="column" :gap="1">
    <Text bold>Title</Text>
    <Text>Body</Text>
  </Box>
</template>

See Layout & Boxes for a guided tour. This page is the full prop reference.

Sizing

PropTypeDescription
width / heightDimensionSize in cells, 'auto', or a '%'
minWidth / minHeightDimensionLower bound
maxWidth / maxHeightDimensionUpper bound

Dimension is number | 'auto' | \${number}%``.

Flex layout

PropTypeDefault
flexDirection'row' | 'column' | 'row-reverse' | 'column-reverse''row'
flexGrownumber
flexShrinknumber
flexBasisnumber | 'auto'
flexWrap'no-wrap' | 'wrap' | 'wrap-reverse'
alignItems'flex-start' | 'center' | 'flex-end' | 'stretch'
alignSelf'flex-start' | 'center' | 'flex-end' | 'stretch'
justifyContent'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
gapnumber | '%'
rowGapnumber | '%'
columnGapnumber | '%'

Positioning

PropTypeDescription
position'static' | 'relative' | 'absolute'Positioning mode
top / right / bottom / leftDimensionOffsets when positioned
zIndexnumberStacking order
overflow'visible' | 'hidden' | 'scroll'How overflowing content is handled

Spacing

Both margin and padding expand into per-axis and per-side shorthands:

PropVariants
marginmarginX, marginY, marginTop, marginRight, marginBottom, marginLeft
paddingpaddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft
template
<Box :padding="1" :marginX="2" />

Appearance

PropTypeDescription
backgroundColorColorInputFill color
borderbooleanDraw a border
borderStyle'single' | 'double' | 'rounded' | 'heavy' | 'none'Border preset
borderColorColorInputBorder color
focusedBorderColorColorInputBorder color while focused
titlestringText shown in the top border
titleAlignment'left' | 'center' | 'right'Title position

ColorInput is a hex/name string or an OpenTUI RGBA instance.

Misc

PropTypeDescription
visiblebooleanHide without removing from layout
opacitynumber01 opacity
focusablebooleanAllow the box to receive focus

Mouse handlers

Bind OpenTUI's per-element mouse handlers as props (:onMouseDown, :onMouseMove, …). See Handling Input → Mouse.

template
<Box :onMouseDown="() => select()"></Box>

Released under the MIT License.