tailwindcss-text-border
Version:
A tailwindcss plugin to enable text borders based on text-shadow property
52 lines (32 loc) • 1.34 kB
Markdown
add text-border in tailwind.
It uses text-shadows under the hood, which act as 1px or 2px border (if thicker, things get ugly)
Works as simple as normal borders.
## Installation
Install the plugin from npm:
`npm install -D @tailwindcss-text-border`
Then add the plugin to your tailwind.config.js file:
```
module.exports = {
theme: {
// ...
},
plugins: [
require('tailwindcss-text-border'),
// ...
],
}
```
It works just like normal tailwind borders, by adding `text-border-[width]` and `text-border-[color]`
The width is limited to 2px max. For values above this it gets ugly. Default width is 1px.
The plugin uses the theme colors, so no limitations here.
`<h1 class="text-border text-border-red">Hello world</h1>`
`<h1 class="text-border-2 text-border-yellow">Hello world</h1>`
The plugin relies on the following function for getting the colors from the theme:
`const flattenColorPalette = require('tailwindcss/lib/util/flattenColorPalette').default`
This can potentially lead to future problems. Check [this github issue](https://github.com/tailwindlabs/tailwindcss/discussions/8598) for more information.
Tips on how to fix this are welcomed!
A plugin to