Components/Splitter
Universal Component

Splitter

Resizable two-pane layout with pointer and keyboard controls.

This page was migrated by AI, please review carefully

Migration is complete, but please validate against source code and manual review.

Splitter

TxSplitter divides a container into two resizable panes. It exposes a ratio through v-model, supports horizontal and vertical layouts, and keeps pointer and keyboard resizing on the same clamped ratio contract.

Basic Usage

Splitter

Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const ratio = ref(0.4)
</script>

<template>
  <div style="width: 520px; height: 240px; border: 1px solid var(--tx-border-color); border-radius: 12px; overflow: hidden;">
    <TxSplitter v-model="ratio" style="width: 100%; height: 100%;">
      <template #a>
        <div style="height: 100%; padding: 12px; color: var(--tx-text-color-secondary);">
          A ({{ ratio.toFixed(2) }})
        </div>
      </template>
      <template #b>
        <div style="height: 100%; padding: 12px; color: var(--tx-text-color-secondary);">
          B
        </div>
      </template>
    </TxSplitter>
  </div>
</template>

API

Props

PropTypeDefaultDescription
modelValuenumber0.5Current pane A ratio, clamped between 0 and 1 before rendering.
direction'horizontal' | 'vertical''horizontal'horizontal splits left/right; vertical splits top/bottom.
minnumber0.1Minimum ratio emitted while resizing.
maxnumber0.9Maximum ratio emitted while resizing.
disabledbooleanfalseDisables pointer and keyboard resizing and ends any active drag.
barSizenumber10Separator size in pixels, with a runtime floor of 6px.
snapnumber0Optional ratio interval used to snap emitted values.

Slots

NameDescription
aContent rendered in the first pane.
bContent rendered in the second pane.

Events

EventParamsDescription
update:modelValue(ratio: number)Emitted whenever pointer or keyboard resizing requests a new ratio.
change(ratio: number)Emitted with the same clamped and snapped ratio for change listeners.
drag-start-Emitted when pointer resizing starts.
drag-end-Emitted when pointer resizing ends or is cancelled by disabling.