Top Related Projects
Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
Simple and fast JSON database
💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
Cross-browser storage for all use cases, used across the web.
An HTML5 saveAs() FileSaver implementation
Quick Overview
Split.js is a lightweight JavaScript library for creating resizable split views in web applications. It allows developers to easily create adjustable, multi-pane layouts with draggable gutters, supporting both horizontal and vertical splits.
Pros
- Lightweight and dependency-free
- Supports both horizontal and vertical splits
- Highly customizable with various options and callbacks
- Works well with modern frameworks like React, Vue, and Angular
Cons
- Limited built-in styling options
- May require additional CSS for more complex layouts
- Documentation could be more comprehensive
- No built-in support for nested splits (though possible with multiple instances)
Code Examples
Creating a basic horizontal split:
Split(['#left', '#right'], {
sizes: [50, 50],
minSize: 100,
gutterSize: 10,
});
Vertical split with custom styling:
Split(['#top', '#bottom'], {
direction: 'vertical',
sizes: [25, 75],
gutterStyle: (dimension, gutterSize) => ({
'background-color': '#ddd',
'border-radius': '5px',
}),
});
Using callbacks:
Split(['#pane1', '#pane2', '#pane3'], {
sizes: [25, 50, 25],
onDragEnd: function(sizes) {
console.log('Drag ended. New sizes:', sizes);
},
});
Getting Started
- Install Split.js using npm:
npm install split.js
- Import and use Split.js in your JavaScript file:
import Split from 'split.js';
document.addEventListener('DOMContentLoaded', function() {
Split(['#left', '#right'], {
sizes: [50, 50],
minSize: 100,
});
});
- Add the necessary HTML structure:
<div class="split-container">
<div id="left">Left pane content</div>
<div id="right">Right pane content</div>
</div>
- Add some basic CSS:
.split-container {
display: flex;
height: 100vh;
}
#left, #right {
overflow-y: auto;
}
.gutter {
background-color: #eee;
background-repeat: no-repeat;
background-position: 50%;
}
.gutter.gutter-horizontal {
cursor: col-resize;
}
Competitor Comparisons
Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
Pros of electron-store
- Specifically designed for Electron apps, providing seamless integration
- Offers encryption options for sensitive data storage
- Supports automatic loading and saving of data
Cons of electron-store
- Limited to Electron applications, not suitable for web or other environments
- Requires more setup and configuration compared to split
Code Comparison
electron-store:
const Store = require('electron-store');
const store = new Store();
store.set('unicorn', '🦄');
console.log(store.get('unicorn'));
split:
Split(['#one', '#two'], {
sizes: [25, 75],
minSize: 100
});
Key Differences
- Purpose: electron-store is for data persistence in Electron apps, while split is for creating resizable split views in web applications
- Functionality: electron-store handles data storage and retrieval, whereas split manages UI layout
- Ecosystem: electron-store is tied to the Electron ecosystem, while split is more versatile for web development
Use Cases
- electron-store: Ideal for Electron apps requiring local data storage, settings management, or caching
- split: Perfect for creating adjustable split panes in web interfaces, such as code editors or file managers
Both libraries serve different purposes and excel in their respective domains. The choice between them depends on the specific requirements of your project and the development environment you're working in.
Simple and fast JSON database
Pros of lowdb
- Provides a lightweight JSON database for Node.js and the browser
- Supports data persistence and querying with a simple API
- Can be used as a drop-in replacement for larger databases in small projects
Cons of lowdb
- Limited to JSON data storage, unlike Split's flexible UI splitting functionality
- May not be suitable for large-scale applications or complex data structures
- Lacks the real-time UI manipulation capabilities offered by Split
Code Comparison
lowdb:
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync('db.json')
const db = low(adapter)
db.defaults({ posts: [] })
.write()
Split:
Split(['#left', '#right'], {
sizes: [25, 75],
minSize: 100,
expandToMin: false,
gutterSize: 10,
cursor: 'col-resize'
})
Summary
While lowdb focuses on providing a simple JSON database solution for small-scale applications, Split is designed for creating resizable split views in web applications. The two libraries serve different purposes, with lowdb handling data storage and retrieval, and Split managing UI layout and interactions.
💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
Pros of localForage
- Provides a simple, asynchronous data storage API that works across different browser storage mechanisms
- Supports storing complex JavaScript objects, not just strings
- Offers fallback options if preferred storage methods are unavailable
Cons of localForage
- Focused solely on data storage, lacking split functionality
- May have a larger footprint for projects that don't need extensive storage capabilities
- Requires additional setup and configuration compared to simpler storage solutions
Code Comparison
localForage:
localforage.setItem('key', { complex: 'object' })
.then(() => localforage.getItem('key'))
.then(value => console.log(value.complex))
.catch(err => console.error(err));
Split:
Split(['#left', '#right'], {
sizes: [25, 75],
minSize: 100,
expandToMin: true,
gutterSize: 10,
});
Key Differences
- Purpose: localForage is for data storage, while Split is for creating resizable split views
- API: localForage uses promises for asynchronous operations, Split uses a more configuration-based approach
- Browser Support: localForage works across various storage mechanisms, Split focuses on DOM manipulation
- Use Cases: localForage is ideal for web apps needing offline storage, Split is best for UI layouts with adjustable panes
Conclusion
While both libraries serve different purposes, they can be complementary in a web application. localForage provides robust client-side storage capabilities, whereas Split offers flexible UI layout options. The choice between them depends on the specific needs of your project.
Cross-browser storage for all use cases, used across the web.
Pros of store.js
- Focuses on cross-browser local storage, providing a consistent API across different browsers
- Supports fallback mechanisms for older browsers, ensuring wider compatibility
- Offers plugins for additional functionality like encryption and expiration
Cons of store.js
- Limited to storage-related functionality, unlike Split's resizing capabilities
- May have a larger footprint due to cross-browser support and fallback mechanisms
- Less actively maintained, with fewer recent updates compared to Split
Code Comparison
store.js:
store.set('user', { name: 'Marcus' })
store.get('user')
store.remove('user')
store.clearAll()
store.each(function(value, key) { console.log(key, '==', value) })
Split:
Split(['#one', '#two'], {
sizes: [25, 75],
minSize: 100,
expandToMin: true,
gutterSize: 10,
cursor: 'col-resize'
})
Summary
While store.js excels in providing a unified storage API across browsers, Split focuses on creating resizable split views in web applications. store.js offers broader browser support and storage-specific features, but Split provides specialized functionality for creating adjustable layouts. The choice between these libraries depends on the specific needs of your project: storage management or UI layout control.
An HTML5 saveAs() FileSaver implementation
Pros of FileSaver.js
- Focused on file saving functionality, making it more specialized and potentially easier to use for this specific task
- Supports a wider range of browsers, including older versions of Internet Explorer
- Smaller file size, which can lead to faster load times and reduced bandwidth usage
Cons of FileSaver.js
- Limited to file saving operations, while Split offers more versatile functionality for UI manipulation
- Less active development and fewer recent updates compared to Split
- Lacks the extensive customization options and event handling capabilities of Split
Code Comparison
FileSaver.js:
import { saveAs } from 'file-saver';
const blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
saveAs(blob, "hello world.txt");
Split:
import Split from 'split.js';
Split(['#left', '#right'], {
sizes: [25, 75],
minSize: 100,
gutterSize: 10,
cursor: 'col-resize'
});
While both libraries serve different purposes, this comparison highlights the simplicity of FileSaver.js for file operations and the flexibility of Split for creating resizable split views in web applications.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Split
Unopinionated utilities for resizeable split views.
- Zero Deps
- Tiny: Each is between 1-2kb gzipped.
- Fast: No overhead or attached window event listeners, uses pure CSS for resizing.
- Unopinionated: Only compute view sizes. Everything else is up to you.
Two utilities:
- Split.js - The original library, maintained since 2014, works with
float
andflex
layouts. Supports all browsers. - Split Grid - Successor to Split.js, for
grid
layouts. Supports modern browsers.
Two React wrappers:
- React Split - Thin wrapper component for Split.js.
- React Split Grid - Thin wrapper component for Split Grid.
Credits
Contributors
This project exists thanks to all the people who contribute. [Contribute].
Backers
Thank you to all our backers! ð [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
Used By
- JSFiddle - Code playground
- Viz.js - Graphviz in your browser
- Perchance - Platform for creating and sharing random text generators
- Babylon.js Playground
- And many more. Submit a PR to list your project here.
Top Related Projects
Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
Simple and fast JSON database
💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
Cross-browser storage for all use cases, used across the web.
An HTML5 saveAs() FileSaver implementation
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot