Responsive masonry layout with SSR support and zero dependencies for Vue 3.
- 📱 Responsive: Responsive with configurable column width and gaps. Based on
ResizeObserver
. - 🔁 Reactive: Reacts to property changes.
- 🪶 Lightweight: Zero dependencies. Less than 1.2 kB.
- ⬅️ RTL: Supports LTR and RTL layouts.
# yarn
$ yarn add @yeger/vue-masonry-wall
# npm
$ npm install @yeger/vue-masonry-wall
import { createApp } from 'vue'
import MasonryWall from '@yeger/vue-masonry-wall'
const app = createApp()
app.use(MasonryWall)
Props:
items
: Array of items. Required.column-width
: Minimal width of columns inpx
.gap
: Spacing between items inpx
. Defaults to0
.rtl
: Toggles between LTR (false
) and RTL (true
) layouts. Defaults tofalse
.ssr-columns
: Number of server-side-rendered columns. Optional.
<template>
<masonry-wall :items="items" :ssr-columns="1" :column-width="300" :gap="16">
<template #default="{ item, index }">
<div style="height: 100px">
<h1>{{ item.title }}</h1>
<span>{{ item.description }}</span>
</div>
</template>
</masonry-wall>
</template>
<script>
export default {
data() {
return {
items: [
{ title: 'First', description: 'The first item.' },
{ title: 'Second', description: 'The second item.'},
]
}
}
}
</script>
# install dependencies
$ yarn install
# build for production
$ yarn build
# lint project files
$ yarn lint
# serve demo
$ yarn demo:serve
# build demo for production
$ yarn demo:build
This component originated as a modified version of vue-masonry-wall by Fuxing Loh.
MIT - Copyright © Fuxing Loh, Jan Müller