### Vue 3 Example: Dynamic Pane Management
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
Example of dynamically adding and removing panes.
```html
```
--------------------------------
### Basic Usage Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/README.md
A simple example demonstrating how to use the Splitpanes and Pane components to create a basic two-pane layout.
```APIDOC
```vue
Left (30%)Right (70%)
```
```
--------------------------------
### Install Splitpanes Package
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/README.md
Install the Splitpanes component library using npm.
```bash
npm install splitpanes
```
--------------------------------
### Vue 3 Example: Three-Pane Editor Layout
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
An example demonstrating a three-pane editor layout.
```html
```
--------------------------------
### Splitpanes Pane Maximize Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/types.md
Shows how to handle the @pane-maximize event to get detailed information about the maximized pane, including its full state.
```javascript
function onMaximize({ pane, index, panes }) {
console.log(`Pane at index ${index} maximized:`, pane)
// Output:
// Pane at index 0 maximized: {
// id: 1,
// el: HTMLElement,
// min: 0,
// max: 100,
// givenSize: 30,
// size: 100,
// index: 0
// }
}
```
--------------------------------
### Install Splitpanes for Vue 2
Source: https://github.com/antoniandre/splitpanes/blob/main/README.md
Use this command to install the legacy version of Splitpanes for Vue 2 projects.
```bash
npm i splitpanes@legacy
```
--------------------------------
### Vue 3 Example: Responsive Layout with Toggle
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
Demonstrates a responsive layout that can be toggled.
```html
```
--------------------------------
### Vue 3 Example: Live Event Logging
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
Logs Splitpanes events in real-time.
```html
Events:
{{ event }}
```
--------------------------------
### Vue 3 Example: Two-Pane Layout
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
A basic two-pane layout example using Splitpanes in Vue 3.
```html
```
--------------------------------
### Basic Splitpanes Usage
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/README.md
A basic example demonstrating a two-pane layout with Splitpanes and Pane components. Ensure to import the necessary CSS.
```vue
Left (30%)Right (70%)
```
--------------------------------
### Install Splitpanes for Vue 3
Source: https://github.com/antoniandre/splitpanes/blob/main/README.md
Use this command to install the latest version of Splitpanes for Vue 3 projects.
```bash
npm i splitpanes
```
--------------------------------
### Reactive Pane Sizing Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/configuration.md
Pane sizes (`size`, `minSize`, `maxSize`) are reactive and recalculate the layout immediately. This example toggles between two size configurations for two panes.
```vue
Pane APane B
```
--------------------------------
### Vue 3 Example: Keyboard Navigation
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
Enables keyboard navigation for panes.
```html
```
--------------------------------
### Vue 3 Example: Layout Persistence with localStorage
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
Persists pane sizes using localStorage.
```html
```
--------------------------------
### Vue 3 Example: Constrained Panes
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/SUMMARY.txt
Sets minimum and maximum sizes for panes.
```html
```
--------------------------------
### Using splitter-click Event
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
This Vue example demonstrates how to listen for and handle the splitter-click event. It logs the index of the clicked splitter and the sizes of the adjacent panes.
```vue
LeftRight
```
--------------------------------
### Pane Constraint Precedence Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/configuration.md
Demonstrates constraint precedence where `minSize` overrides `size` if they conflict. The pane will adhere to the `minSize` value.
```vue
```
--------------------------------
### Managing Reactive Layout State
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of using Vue's `ref` to manage reactive layout state, including pane sizes, orientation, and readiness for interaction.
```vue
```
--------------------------------
### Example Usage of Resized Event
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/types.md
Demonstrates how to use the 'resized' event to differentiate between drag-based resizing and pane add/remove operations, and to access final pane sizes.
```javascript
function onResized(payload) {
if (payload.event) {
console.log('Drag ended or keyboard navigation completed')
} else {
console.log('Panes were added or removed')
}
console.log('Final pane sizes:', payload.panes)
}
```
--------------------------------
### Handling Splitter Double Click in Vue
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of how to use the `splitter-dblclick` event to implement custom maximize or collapse logic.
```vue
LeftRight
```
--------------------------------
### Splitpanes Ready Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/types.md
Demonstrates how to use the @ready event to access pane size data upon initial layout. The `panes` array in the payload contains PaneData objects.
```javascript
function onReady({ panes }) {
console.log(panes)
// Output:
// [
// { min: 10, max: 80, size: 45 },
// { min: 20, max: 90, size: 55 }
// ]
}
```
--------------------------------
### Basic Resize Event Handling
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of how to handle the 'resize' event in a Vue component to log information about the splitter and pane sizes during a drag operation.
```vue
```
--------------------------------
### Persisting Layout State with Session Storage
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of persisting pane sizes to `sessionStorage` when the layout is resized and restoring it on component mount.
```vue
```
--------------------------------
### Pane Size Prop Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Control the initial size of a Pane using the 'size' prop, specified as a percentage. This prop can be a number or a string and is clamped between minSize and maxSize.
```vue
```
--------------------------------
### Ready Event Usage
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Fires once after the Splitpanes component mounts and the initial layout is complete. Use this to initialize external state or start animations based on pane sizes.
```vue
```
--------------------------------
### Using pane-maximize Event
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of how to use the pane-maximize event in a Vue component. This snippet demonstrates listening for the event and logging information about the maximized pane.
```vue
LeftRight
```
--------------------------------
### Splitpanes Resize Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/types.md
Illustrates how to use the @resize event to track splitter dragging in real-time. The payload provides access to the event, splitter index, adjacent panes, and current pane sizes.
```javascript
function onResize({ event, index, prevPane, nextPane, panes }) {
console.log(`Splitter ${index} being dragged`)
if (prevPane) console.log(`Previous pane size: ${prevPane.size}%`)
if (nextPane) console.log(`Next pane size: ${nextPane.size}%`)
}
```
--------------------------------
### Three-Pane Editor Layout
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/usage-examples.md
Creates an IDE-like interface with a sidebar, code editor, and output panel. This example uses nested Splitpanes and includes basic styling for panels and content.
```vue
Files
{{ file }}
Editor
Output
{{ output }}
```
--------------------------------
### Using pane-add and pane-remove Events
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
This Vue component example demonstrates how to add and remove panes dynamically and handle the corresponding pane-add and pane-remove events. It logs the number of panes after each operation.
```vue
{{ pane.label }}
```
--------------------------------
### Pane Min/Max Size Props Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Set constraints for pane resizing using the 'minSize' and 'maxSize' props. These props, specified as percentages, prevent panes from shrinking or growing beyond defined limits during resize operations.
```vue
```
--------------------------------
### Splitter Double Click Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Use the 'splitter-dblclick' event to respond to double-clicks or double-taps on a splitter. Similar to 'splitter-click', it provides event details and pane context.
```javascript
function onSplitterDblClick(payload) {
console.log(`Splitter ${payload.index} double-clicked`)
}
```
--------------------------------
### Custom Splitter Handle with CSS
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Create a custom visual handle for the splitter using pseudo-elements and absolute positioning. This example styles both vertical and horizontal splitters.
```vue
Panel 1Panel 2
```
--------------------------------
### Custom Transition Duration for Splitpanes
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Override the default transition duration and easing for pane resizing. This example sets a longer duration and a custom cubic-bezier timing function.
```vue
Pane 1Pane 2
```
--------------------------------
### Responsive Splitter Styling
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Adapt splitter appearance based on screen size for better mobile usability. This example increases splitter width on smaller screens for easier touch interaction.
```vue
Panel 1Panel 2
```
--------------------------------
### Splitpanes Pane Add Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Handle the 'pane-add' event to be notified when a new Pane component is mounted within Splitpanes. This is useful for tracking the total number of panes.
```javascript
function onPaneAdded(payload) {
console.log('Pane added, total panes:', payload.panes.length)
}
```
--------------------------------
### Debug Mode Styles for Splitpanes
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Apply visual debugging styles to panes and splitters. This example uses dashed borders and semi-transparent backgrounds to highlight the components during development.
```vue
Panel 1Panel 2
```
--------------------------------
### Splitpanes Pane Click Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Respond to 'pane-click' events to detect when a user directly clicks on a pane. The event provides details about the clicked pane and its index.
```javascript
function onPaneClick(payload) {
console.log(`Pane ${payload.index} clicked`)
}
```
--------------------------------
### Theming Splitpanes with CSS Variables
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Define custom themes for Splitpanes using CSS variables. This example demonstrates light and dark themes by overriding default variables like background and border colors.
```vue
Panel 1Panel 2
```
--------------------------------
### High Contrast Mode Styling for Splitter
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Adjust splitter styling for high contrast mode using a media query. This example adds a thicker black border and outline.
```vue
```
--------------------------------
### Resized Event Handling for Persistence
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of handling the 'resized' event to save pane sizes to localStorage. It checks for the presence of 'event' to distinguish between drag completion and pane add/remove operations.
```vue
```
--------------------------------
### Splitpanes Initialization Data Flow
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/implementation-guide.md
Outlines the steps involved when the Splitpanes component is first mounted and ready for interaction.
```text
1. Splitpanes mounts
2. DOM tree is validated (non-Pane/non-Splitter nodes removed)
3. Splitters are injected between panes
4. Initial pane sizes are calculated
5. `ready` flag is set, transitions enabled
6. `ready` event emitted
```
--------------------------------
### Splitpanes Resize Algorithm Steps
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/implementation-guide.md
Summarizes the core logic for calculating pane sizes during drag operations, including constraint handling.
```text
1. **Clamp drag percentage** to valid range [minDrag, maxDrag]
2. **Identify panes to resize** (usually splitter index and index+1)
3. **Check for max size violations** on immediate neighbors
- If violated, clamp and return early
4. **Push other panes if enabled** (cascade resizing):
- If dragging beyond first pane's min, find previous expanded pane to resize
- If dragging beyond last pane's min, find next expanded pane to resize
- Update panes in between to their minimum size
5. **Calculate final sizes** for the two panes being resized:
- Clamped to their respective min/max constraints
6. **Update DOM** via style binding (width: X% or height: X%)
```
--------------------------------
### Handling Direction Change in Vue
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of listening to the `direction-changed` event to react to layout orientation changes, such as updating UI elements or persisting state.
```vue
Pane APane B
```
--------------------------------
### Direction Changed Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Listen for the 'direction-changed' event, which fires when the layout orientation changes between horizontal and vertical. The payload indicates the new orientation.
```typescript
interface SplitpanesDirectionChangedPayload {
horizontal: boolean
panes: PaneData[]
}
```
```javascript
function onDirectionChange(payload) {
console.log(`Layout is now ${payload.horizontal ? 'horizontal' : 'vertical'}`)
}
```
--------------------------------
### ready
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Fired once after the Splitpanes component mounts and the initial layout is complete. It signifies that the panes have been sized and the component is ready for interaction. The payload includes an array of PaneData objects summarizing the size state.
```APIDOC
## ready
### Description
Fired once, after component mounts and initial layout is complete. This is the first event emitted after Splitpanes mounts, indicating that all panes have been sized and the container is ready for user interaction.
### Payload
```typescript
{
panes: PaneData[];
}
```
### Usage
```vue
```
### Common Use Cases
- Initialize external state based on pane sizes
- Start animations or load content into panes
- Set up resize observers or state management
- Trigger analytics event
```
--------------------------------
### Pane Remove Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Listen for the 'pane-remove' event to be notified when a Pane component is unmounted. The payload includes the removed pane and the remaining panes.
```typescript
interface SplitpanesPaneRemovePayload {
pane: Pane
panes: PaneData[]
}
```
```javascript
function onPaneRemoved(payload) {
console.log('Pane removed, remaining panes:', payload.panes.length)
}
```
--------------------------------
### Fade-in Animation for Panes
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Apply a fade-in animation to panes as they appear. This example uses CSS keyframes and `animation-delay` to stagger the fade-in effect for each pane.
```vue
Panel 1Panel 2
```
--------------------------------
### Basic Two-Pane Layout
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/configuration.md
Sets up a simple two-pane layout with predefined sizes. The first pane is not resizable by default.
```vue
Left (30%)Right (70%)
```
--------------------------------
### Custom Keyboard Focus Indicator for Splitter
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Customize the keyboard focus indicator for the splitter. This example uses a dashed outline with a different color and offset.
```vue
```
--------------------------------
### Importing Components
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/README.md
How to import the Splitpanes and Pane components into your Vue 3 project.
```APIDOC
```javascript
import { Splitpanes, Pane } from 'splitpanes'
```
```
--------------------------------
### Splitpanes Resized Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Handle the 'resized' event, which fires once after a resize operation (drag completion or pane add/remove). It provides the final pane configuration.
```javascript
function onResized(payload) {
if (payload.event) {
console.log('Drag completed')
} else {
console.log('Panes added or removed')
}
console.log('Final sizes:', payload.panes)
}
```
--------------------------------
### Reactive Pane Sizing
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Demonstrates how to make pane sizes reactive using Vue's ref. Changing the values in `paneSizes` or `constraints` will automatically update the pane dimensions.
```vue
```
--------------------------------
### Live Preview with Resize Event
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
A Vue component demonstrating a live preview of pane sizes updated by the 'resize' event. It shows how to bind pane sizes to refs and update them in real-time.
```vue
Left: {{ leftSize }}% | Right: {{ rightSize }}%
```
--------------------------------
### Basic Splitpanes Styling
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Customize the root container, panes, and splitter appearance. Ensure 'splitpanes' and 'Pane' components are imported and 'splitpanes.css' is included.
```vue
LeftRight
```
--------------------------------
### Style Nested Splitpanes
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Style nested splitpanes to ensure they fill their parent container and differentiate splitter colors. This example shows styling for both outer and inner splitpanes.
```vue
LeftTopBottom
```
--------------------------------
### Applying the Default Theme in Vue
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/styling-css.md
Demonstrates how to apply the optional `.default-theme` class to Splitpanes or a parent element for professional styling.
```vue
LeftRight
LeftRight
```
--------------------------------
### Import Splitpanes Component
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Import the main Splitpanes component from the library. This is the first step to using the component in your application.
```javascript
import { Splitpanes } from 'splitpanes'
```
--------------------------------
### Attribute Fallthrough Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Standard HTML attributes can be passed to the root element of Splitpanes via fallthrough. Ensure 'inheritAttrs: false' is set on the component to manage attribute binding.
```vue
Pane 1Pane 2
```
--------------------------------
### Splitter Click Event Example
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/api-reference-splitpanes.md
Handle the 'splitter-click' event to detect when a user clicks on a splitter without dragging. The payload provides information about the clicked splitter and adjacent panes.
```typescript
interface SplitpanesSplitterClickPayload {
event: MouseEvent | TouchEvent
index: number
prevPane: Pane | undefined
nextPane: Pane | undefined
panes: PaneData[]
}
```
```javascript
function onSplitterClick(payload) {
console.log(`Splitter ${payload.index} between panes clicked`)
}
```
--------------------------------
### Enable Keyboard Navigation with Step
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/README.md
Configure keyboard navigation for Splitpanes, allowing users to resize panes using arrow keys. The `keyboardStep` prop defines the increment/decrement value.
```vue
```
--------------------------------
### Splitpanes Touch Event Handling
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/implementation-guide.md
Explains the handling of touch events for splitter dragging and double-tap detection.
```text
**Touch:**
- `touchstart` on splitter → bind events, detect if double-tap (for splitter double-click)
- `touchmove` on document → calculate drag, emit `resize`
- `touchend` on document → emit `resized`, unbind events
**Double-Click Detection:**
- Mouse: native `dblclick` event
- Touch: manual detection via two taps within 500ms on same splitter index
```
--------------------------------
### Pane Click Event Handling
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/event-reference.md
Example of handling the 'pane-click' event in a Vue component to log information about the clicked pane and its size. It demonstrates accessing the event target and pane data.
```vue
Another pane
```
--------------------------------
### Global Default Configuration with Wrapper Component
Source: https://github.com/antoniandre/splitpanes/blob/main/_autodocs/configuration.md
Applies global default props (e.g., `pushOtherPanes`, `maximizePanes`, `keyboardStep`) to all Splitpanes instances by using a wrapper component. This avoids repetitive prop definitions.
```vue
```