1.1.3 • Published 9 months ago

vue-wrap-balancer v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Vue Wrap Balancer

Vue port of React Wrap Balancer. Check here for a demo with Nuxt.

Vue Wrap Balancer is a simple Vue Component that makes your titles more readable in different viewport sizes. It improves the wrapping to avoid situations like single word in the last line, makes the content more “balanced”:

npm.io

Installation

npm install vue-wrap-balancer

Usage

Wrap text content with it:

<script setup>
import WrapBalancer from 'vue-wrap-balancer'
</script>

<template>
  <h1>
    <WrapBalancer>My Awesome Title</WrapBalancer>
  </h1>
</template>

<WrapBalancer>

<WrapBalancer> is the main component of the library. It will automatically balance the text content inside it. It accepts the following props:

  • as (optional): The HTML tag to be used to wrap the text content. Default to span.
  • ratio (optional): The ratio of “balance-ness”, 0 <= ratio <= 1. Default to 1.
  • preferNative (optional): An option to skip the re-balance logic and use the native CSS text-balancing if supported. Default to true.
  • nonce (optional): The nonce attribute to allowlist inline script injection by the component.

<BalancerProvider>

If you have multiple <WrapBalancer> components used, it’s recommended (but optional) to use <BalancerProvider> to wrap the entire app. This will make them share the re-balance logic and reduce the HTML size:

<script setup>
import { BalancerProvider } from 'vue-wrap-balancer'
</script>

<template>
  <BalancerProvider>
    <App />
  </BalancerProvider>
</template>

For use cases, please visit vue-wrap-balancer.vercel.app.

For Vue 2, check this branch.

Browser Support Information

Desktop:

BrowserMin Version
Chrome64
Edge79
Safari13.1
FireFox69
Opera51
IENo Support

Mobile:

BrowserMin Version
Chrome64
Safari13.4
Firefox69
Opera47
WebView Android64

License

MIT

1.1.1

9 months ago

1.1.0

9 months ago

1.0.0

11 months ago

1.1.3

9 months ago

1.1.2

9 months ago

0.3.0

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago