Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webdna/tailwindcss-visuallyhidden
Visually Hidden utility plugin for tailwindcss framework
https://github.com/webdna/tailwindcss-visuallyhidden
Last synced: 4 months ago
JSON representation
Visually Hidden utility plugin for tailwindcss framework
- Host: GitHub
- URL: https://github.com/webdna/tailwindcss-visuallyhidden
- Owner: webdna
- Created: 2018-03-21T15:51:17.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-04T12:14:30.000Z (over 5 years ago)
- Last Synced: 2024-10-13T14:53:38.212Z (4 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 14
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Visually Hidden Utility Tailwind Plugin
## Overview
Hide only visually, but have it available for screen readers: https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
For long content, line feeds are not interpreted as spaces and small width causes content to wrap 1 word per line: https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
## Installation
Add this plugin to your project:
```bash
# Install via npm
npm install --save-dev tailwindcss-visuallyhidden
```## Usage
You can add the plugin to your tailwind config as follows:
```js
require('tailwindcss-visuallyhidden')()
```This plugin outputs the following
```css
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
white-space: nowrap; /* 1 */
}.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
clip: auto;
clip-path: none;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
white-space: inherit;
}
```As per the [tailwind plugin docs](https://tailwindcss.com/docs/plugins/) you are able to pass variants (responsive, hover etc) as a parameter.
```js
require('tailwindcss-visuallyhidden')({
variants: ['responsive', 'hover'],
})
```