Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wobsoriano/vue-wrap-balancer

Simple Vue Component That Makes Titles More Readable.
https://github.com/wobsoriano/vue-wrap-balancer

typography vue wrapping

Last synced: 3 days ago
JSON representation

Simple Vue Component That Makes Titles More Readable.

Awesome Lists containing this project

README

        

# Vue Wrap Balancer

Vue port of [React Wrap Balancer](https://github.com/shuding/react-wrap-balancer). Check here for a [demo](https://vue-wrap-balancer.vercel.app/) 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”:

![](https://i.imgur.com/2LWVkXk.gif)

## Installation

```bash
npm install vue-wrap-balancer
```

## Usage

Wrap text content with it:

```vue

import { Balancer } from 'vue-wrap-balancer'


My Awesome Title

```

### ``

`` 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](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) attribute to allowlist inline script injection by the component.

### ``

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

```vue

import { BalancerProvider } from 'vue-wrap-balancer'



```

For use cases, please visit [**vue-wrap-balancer.vercel.app**](https://vue-wrap-balancer.vercel.app).

For Vue 2, check [this](https://github.com/wobsoriano/vue-wrap-balancer/tree/vue2) branch.

## Browser Support Information
Desktop:

| Browser | Min Version |
|:-------:|:-----------:|
| Chrome | 64 |
| Edge | 79 |
| Safari | 13.1 |
| FireFox | 69 |
| Opera | 51 |
| IE | No Support |

Mobile:

| Browser | Min Version |
|:---------------:|:-----------:|
| Chrome | 64 |
| Safari | 13.4 |
| Firefox | 69 |
| Opera | 47 |
| WebView Android | 64 |

## License

MIT