websiteuno / launchy

Launchy: An Accessible Modal Window

Home Page:https://svinkle.github.io/launchy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

Launchy! πŸš€

An accessible modal window!

Features include:

  • Easy to use and implement!
  • On launch, keyboard focus shifts to the modal window container
  • The modal window is described via optional modal heading
  • Traps the keyboard focus within the modal when active/visible
  • Closes the window on esc key press
  • Closes the window on overlay mouse click
  • Sets keyboard focus back to the launcher element on window close
  • Transparent border for Windows High Contrast themes

For more details on the accessibility of modal windows:

Demo

  • Check out the demo! πŸ‘ˆ
  • Try your own HTML with the CodePen demo!

Usage

Launchy! is very easy to install and use:

HTML

Wherever you want to have a Launchy! control + window appear in your HTML content, simply wrap your content with a <div> and add the data-launchy attribute.

Example:

<div data-launchy data-launchy-text="Launch window!" data-launchy-title="My modal window">
    <p>This content will appear in the modal window.</p>
</div>
  • Required: data-launchy -- Attribute is required but the value can be anything
  • Required: data-launchy-text -- This is the text that will be output to the launcher control
  • Optional: data-launchy-title -- The text which appears in the heading of the modal window, recommended for greater a11y context πŸ‘

CSS

Launchy! has many CSS classes available on its generated elements for custom styles. Check out the style.scss file for class names and an example on how you might want to style your modal windows!

JavaScript

For any site, grab the /dist/launchy.js file and include it at the bottom of your HTML page/template:

<script src="js/launchy.js"></script>

Launchy! will run automatically and generate all the modal windows for you!

npm Package

Launchy! is also available as an npm package!

Install

npm i launchy-modal-window

Usage

Include the launchy.js directly in your app or site template.

<script src="node_modules/launchy-modal-window/launchy.js"></script>

Contributions

See the CONTRIBUTING file.

License

See the LICENSE file.

About

Launchy: An Accessible Modal Window

https://svinkle.github.io/launchy/

License:MIT License


Languages

Language:JavaScript 43.8%Language:CSS 42.0%Language:HTML 14.1%