npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ibohonos/split-vue

v1.0.1

Published

Vue 2.6 and Vue 3 wrapper for split.js

Downloads

26

Readme

Vue Split

A lightweight Vue wrapper for Split.js, with support for both Vue 2.6+ and Vue 3.

The package uses a single Vue component source and provides separate builds for Vue 2 and Vue 3.

Features

  • Vue 2.6+ support
  • Vue 3 support
  • Horizontal split panes
  • Vertical split panes
  • Two or more panes
  • Custom initial sizes
  • Access to Split.js options
  • Vue events for drag lifecycle
  • Dynamic panes
  • Automatic refresh when panes are added or removed
  • Programmatic getSizes()
  • Programmatic setSizes()
  • Programmatic collapse()
  • Manual refresh() when required
  • No vue-demi dependency
  • Split.js included as a package dependency

Installation

npm install @ibohonos/split-vue

The package contains separate builds for Vue 2 and Vue 3.


Vue 2

Vue 2.6 and newer are supported.

Register the plugin globally:

import Vue from 'vue'
import VueSplit from '@ibohonos/split-vue/vue2'

Vue.use(VueSplit)

You can then use the component anywhere:

<template>
    <VueSplit>
        <div>
            First pane
        </div>

        <div>
            Second pane
        </div>
    </VueSplit>
</template>

Local registration

You can also import the component directly:

import {
    VueSplit,
} from '@ibohonos/split-vue/vue2'

export default {
    components: {
        VueSplit,
    },
}

Vue 3

Register the plugin globally:

import { createApp } from 'vue'
import App from './App.vue'

import VueSplit from '@ibohonos/split-vue/vue3'

const app = createApp(App)

app.use(VueSplit)

app.mount('#app')

Local registration

With Composition API:

<script setup>
import {
    VueSplit,
} from '@ibohonos/split-vue/vue3'
</script>

<template>
    <VueSplit>
        <div>
            First pane
        </div>

        <div>
            Second pane
        </div>
    </VueSplit>
</template>

Or with Options API:

import {
    VueSplit,
} from '@ibohonos/split-vue/vue3'

export default {
    components: {
        VueSplit,
    },
}

Basic usage

<VueSplit>
    <div>
        Left
    </div>

    <div>
        Right
    </div>
</VueSplit>

No special classes such as left, right, top, or bottom are required.

Every direct child of VueSplit is treated as a pane.

For example:

<VueSplit>
    <Sidebar />

    <MainContent />
</VueSplit>

or:

<VueSplit>
    <div>Pane 1</div>
    <div>Pane 2</div>
    <div>Pane 3</div>
</VueSplit>

Initial sizes

Use the sizes property to define the initial size of each pane.

<VueSplit
    :sizes="[30, 70]"
>
    <div>
        Sidebar
    </div>

    <div>
        Content
    </div>
</VueSplit>

The values represent percentages.

In this example:

Sidebar: 30%
Content: 70%

For three panes:

<VueSplit
    :sizes="[20, 50, 30]"
>
    <div>
        Left
    </div>

    <div>
        Center
    </div>

    <div>
        Right
    </div>
</VueSplit>

Direction

By default, panes are displayed horizontally.

<VueSplit direction="horizontal">
    <div>
        Left
    </div>

    <div>
        Right
    </div>
</VueSplit>

For vertical panes:

<VueSplit direction="vertical">
    <div>
        Top
    </div>

    <div>
        Bottom
    </div>
</VueSplit>

Supported values:

horizontal
vertical

Split.js options

Additional Split.js configuration can be passed through the options property.

<VueSplit
    :sizes="[30, 70]"
    :options="{
        minSize: 200,
        gutterSize: 8,
        snapOffset: 0
    }"
>
    <div>
        Sidebar
    </div>

    <div>
        Content
    </div>
</VueSplit>

For example:

{
    minSize: 100,
    maxSize: Infinity,
    gutterSize: 10,
    snapOffset: 30,
    dragInterval: 1
}

The direction and drag callbacks are managed by the Vue wrapper.

Use Vue events instead of passing onDrag, onDragStart, or onDragEnd inside options.


Events

The component emits Vue events corresponding to the Split.js drag lifecycle.

drag-start

Emitted when dragging starts.

<VueSplit
    @drag-start="handleDragStart"
>
    ...
</VueSplit>
methods: {
    handleDragStart(sizes) {
        console.log(sizes)
    },
}

drag

Emitted while the gutter is being dragged.

<VueSplit
    @drag="handleDrag"
>
    ...
</VueSplit>
methods: {
    handleDrag(sizes) {
        console.log(sizes)
    },
}

drag-end

Emitted when dragging ends.

<VueSplit
    @drag-end="handleDragEnd"
>
    ...
</VueSplit>
methods: {
    handleDragEnd(sizes) {
        console.log(sizes)
    },
}

A common use case is saving the pane sizes:

<VueSplit
    :sizes="savedSizes"
    @drag-end="saveSizes"
>
    <div>
        Sidebar
    </div>

    <div>
        Content
    </div>
</VueSplit>
export default {
    data() {
        return {
            savedSizes: [30, 70],
        }
    },

    methods: {
        saveSizes(sizes) {
            this.savedSizes = sizes

            localStorage.setItem(
                'split-sizes',
                JSON.stringify(sizes)
            )
        },
    },
}

Component methods

The component exposes several methods through a Vue ref.

getSizes()

Returns the current pane sizes.

<VueSplit ref="split">
    <div>
        Left
    </div>

    <div>
        Right
    </div>
</VueSplit>
const sizes = this.$refs.split.getSizes()

console.log(sizes)

Example result:

[
    35.2,
    64.8,
]

setSizes()

Changes pane sizes programmatically.

this.$refs.split.setSizes([
    25,
    75,
])

For example:

<template>
    <div>
        <button @click="resetSizes">
            Reset
        </button>

        <VueSplit ref="split">
            <div>
                Sidebar
            </div>

            <div>
                Content
            </div>
        </VueSplit>
    </div>
</template>

<script>
export default {
    methods: {
        resetSizes() {
            this.$refs.split.setSizes([
                30,
                70,
            ])
        },
    },
}
</script>

collapse()

Collapses a pane by index.

this.$refs.split.collapse(0)

This collapses the first pane.

For the second pane:

this.$refs.split.collapse(1)

refresh()

Recreates the Split.js instance.

Normally you do not need to call refresh() manually.

The component automatically detects when direct panes are added or removed and recreates the Split.js instance.

The method is still available for cases where the DOM structure is modified in a way that cannot be detected automatically.

this.$refs.split.refresh()

If you manually call it immediately after changing Vue data, wait until Vue updates the DOM:

this.items.push(newItem)

this.$nextTick(() => {
    this.$refs.split.refresh()
})

Dynamic panes

Dynamic panes are supported.

<template>
    <div>
        <button @click="addPane">
            Add pane
        </button>

        <VueSplit>
            <div
                v-for="pane in panes"
                :key="pane.id"
            >
                {{ pane.title }}
            </div>
        </VueSplit>
    </div>
</template>

<script>
export default {
    data() {
        return {
            panes: [
                {
                    id: 1,
                    title: 'Pane 1',
                },
                {
                    id: 2,
                    title: 'Pane 2',
                },
            ],
        }
    },

    methods: {
        addPane() {
            this.panes.push({
                id: Date.now(),
                title: 'New pane',
            })
        },
    },
}
</script>

No manual refresh() call is normally required.


Three or more panes

Split.js is not limited to two panes.

<VueSplit
    :sizes="[20, 50, 30]"
>
    <div>
        Navigation
    </div>

    <div>
        Editor
    </div>

    <div>
        Inspector
    </div>
</VueSplit>

The component automatically creates gutters between every pane.

Conceptually:

Navigation
    |
  gutter
    |
Editor
    |
  gutter
    |
Inspector

Vue components as panes

A pane does not have to be a <div>.

Vue components can be used directly:

<VueSplit
    :sizes="[25, 75]"
>
    <Sidebar />

    <MainContent />
</VueSplit>

The important requirement is that each pane renders a DOM element as its root.

This is especially relevant when using Vue 3 fragments.

For maximum compatibility with both Vue 2 and Vue 3, each direct pane should have a single root DOM element.


Vertical layout example

<VueSplit
    direction="vertical"
    :sizes="[25, 75]"
>
    <div>
        Header content
    </div>

    <div>
        Main content
    </div>
</VueSplit>

The container must have a defined height for vertical splitting to work correctly.

For example:

.page {
    height: 100vh;
}
<div class="page">
    <VueSplit
        direction="vertical"
        :sizes="[30, 70]"
    >
        <div>
            Top
        </div>

        <div>
            Bottom
        </div>
    </VueSplit>
</div>

Nested splits

Split components can be nested.

For example:

<VueSplit
    :sizes="[25, 75]"
>
    <div>
        Sidebar
    </div>

    <VueSplit
        direction="vertical"
        :sizes="[60, 40]"
    >
        <div>
            Main
        </div>

        <div>
            Console
        </div>
    </VueSplit>
</VueSplit>

This can be used to create layouts similar to IDEs or administration dashboards:

┌───────────┬──────────────────────────┐
│           │                          │
│ Sidebar   │        Main              │
│           │                          │
│           ├──────────────────────────┤
│           │        Console           │
│           │                          │
└───────────┴──────────────────────────┘

Styling

The package provides the basic styles required for the split layout.

The gutters created by Split.js have these classes:

.gutter
.gutter-horizontal
.gutter-vertical

You can override their appearance globally.

For example:

.gutter {
    background: #e5e7eb;
}

.gutter-horizontal {
    cursor: col-resize;
}

.gutter-vertical {
    cursor: row-resize;
}

A more visible gutter:

.gutter {
    background-color: #d1d5db;
    background-repeat: no-repeat;
    background-position: 50%;
}

Your panes do not require any predefined classes.

This is valid:

<VueSplit>
    <section>
        First pane
    </section>

    <main>
        Second pane
    </main>
</VueSplit>

As is this:

<VueSplit>
    <MySidebar />

    <RouterView />
</VueSplit>

Props

| Prop | Type | Default | Description | |-------------|----------|-------------:|---------------------------------------------| | sizes | Array | null | Initial pane sizes in percentages | | direction | String | horizontal | Split direction: horizontal or vertical | | options | Object | {} | Additional Split.js options |

Example:

<VueSplit
    direction="horizontal"
    :sizes="[30, 70]"
    :options="{
        minSize: [200, 300],
        gutterSize: 8,
        snapOffset: 20
    }"
>
    ...
</VueSplit>

Events

| Event | Arguments | Description | |--------------|-----------|------------------------------| | drag-start | sizes | Emitted when dragging starts | | drag | sizes | Emitted while dragging | | drag-end | sizes | Emitted when dragging ends |

Example:

<VueSplit
    @drag-start="onDragStart"
    @drag="onDrag"
    @drag-end="onDragEnd"
>
    ...
</VueSplit>

Methods

| Method | Arguments | Description | |-------------------|-----------|---------------------------------| | getSizes() | — | Returns current pane sizes | | setSizes(sizes) | Array | Changes pane sizes | | collapse(index) | Number | Collapses a pane | | refresh() | — | Recreates the Split.js instance |

Example:

this.$refs.split.getSizes()

this.$refs.split.setSizes([
    30,
    70,
])

this.$refs.split.collapse(0)

this.$refs.split.refresh()

Package builds

The package contains two separate builds:

dist/
├── vue2/
│   └── index.js
│
└── vue3/
    └── index.js

Use the Vue 2 build:

import VueSplit from '@ibohonos/split-vue/vue2'

Use the Vue 3 build:

import VueSplit from '@ibohonos/split-vue/vue3'

Separate builds are necessary because Vue 2.6 and Vue 3 use different Single File Component compilers.

The source component itself is shared:

src/
├── VueSplit.vue
└── index.js

Browser support

Browser support follows Split.js requirements.

The component also uses MutationObserver to detect dynamic pane changes, which is supported by modern browsers.


Development

Install dependencies:

npm install

Install dependencies for the Vue 2 build environment:

npm run install:vue2-build

Build both versions:

npm run build

Build only Vue 2:

npm run build:vue2

Build only Vue 3:

npm run build:vue3

Generated files:

dist/
├── vue2/
│   └── index.js
│
└── vue3/
    └── index.js

Project structure

vue-split/
│
├── src/
│   ├── VueSplit.vue
│   └── index.js
│
├── build/
│   ├── vue2/
│   │   ├── package.json
│   │   └── rollup.config.js
│   │
│   └── vite.vue3.config.js
│
├── dist/
│   ├── vue2/
│   │   └── index.js
│   │
│   └── vue3/
│       └── index.js
│
├── package.json
└── README.md

Why separate Vue 2 and Vue 3 builds?

Vue 2.6 and Vue 3 use different SFC compilers:

VueSplit.vue
      │
      ├──────────────┐
      │              │
      ▼              ▼
Vue 2 compiler   Vue 3 compiler
      │              │
      ▼              ▼
dist/vue2       dist/vue3

Vue 2.6 uses:

vue-template-compiler

Vue 3 uses:

@vue/compiler-sfc

Keeping separate build outputs allows the same source component to support both Vue generations without requiring vue-demi.


Split.js

This package is a Vue wrapper around:

Split.js

For advanced configuration options, see the Split.js documentation.


License

MIT