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

https://github.com/tomaszbujnowicz/vanilla-js-tailwindcss-modal

A dependency-free Vanilla JS TailwindCSS modal and drawer. No dependencies, no automation build tools.
https://github.com/tomaszbujnowicz/vanilla-js-tailwindcss-modal

drawer drawers javascript modal modal-dialog modals vanilla-javascript vanilla-js

Last synced: 11 months ago
JSON representation

A dependency-free Vanilla JS TailwindCSS modal and drawer. No dependencies, no automation build tools.

Awesome Lists containing this project

README

          

# 🚀 Modal | Vanilla JS TailwindCSS Component

A simple, accessible modal script.

## Requirements
No Node.js, Yarn, NPM, Webpack, Gulp, React, Vue.js etc... just a browser.

## Features
- Vanilla JavaScript
- TailwindCSS
- ARIA attributes
- Data attributes used for JS functionality (semantic and flexible markup)
- Trap focus
- Auto focus on input fields when the modal is opened
- Close a modal with Escape key
- Can be used for multiple modals

## Usage

Trigger via data attributes
```html

Open modal

```

Trigger via a tag
```html

Open from a tag link

```

### Example markup
```html


```

## Animations
You can control overlay and the div wrapper animations using TailwindCSS classes via:

- Leaving screen: `data-class-out` and `class`
- Entering screen: `data-class-in`

```html


```

## Initialize
```javascript
modal.init()
```

## Methods

openModal()
```javascript
modal.openModal('modal-name');
```

closeModal()
```javascript
modal.closeModal('modal-name');
```

### Quick start: Installation
Copy/paste and use.

## Copyright and license
Copyright 2021 Tomasz Bujnowicz under the [MIT license](http://opensource.org/licenses/MIT).