vue-balance-text

A Vue directive that implements balance-text
5,221 8
Install
npm install vue-balance-text
Latest Version:1.3.0
License:MIT
Last Updated:May 1, 2023
Links: GitHub  ·  npm
Maintainer: weotch

vue-balance-text

A Vue directive that implements balance-text. Here is their demo page.

Install

yarn add vue-balance-text or npm install --save vue-balance-text

Vue
Vue = require('vue')
Vue.directive('balance-text', require('vue-balance-text'))
Nuxt

In nuxt.config.js:

{
  modules: [ 'vue-balance-text/nuxt/module' ]
}

Usage

Use in a Vue template like:

<h1 v-balance-text>A long title with many words that will wrap to multiple lines</h1>

When rendering HTML with v-html, you need to tell v-balance-text to operate on the children vs on the element it's attached to:

<div v-balance-text.children v-html='body'></div>

Example

Before:

After:

Related Packages

vue

The progressive JavaScript framework for building modern web UI.

468,054,189 54,906
vue
eslint-plugin-vue

Official ESLint plugin for Vue.js

266,364,830 4,591
@vueuse/shared
260,835,866 22,398
@vitejs/plugin-vue

The official plugin for Vue SFC support in Vite.

257,315,514 686
@vueuse/core

Collection of essential Vue Composition Utilities

256,285,643 22,398

Version History

Version Released License
1.3.0 MIT
1.2.3 MIT
1.2.2 MIT
1.2.1 MIT
1.2.0 MIT