Giter Club home page Giter Club logo

a11y-hideshow's Introduction

Accessible Hide/Show

A simple, yet fairly complex (and accessible) hide/show toggle behavior

View the Pen: http://codepen.io/timwright12/pen/yerzqG

Syntax for using a button as the toggle

<button
	type="button"
	data-action="hide-show"
	data-text="Hide"
	data-class="is-hidden"
	aria-controls="your-target-id"
	aria-live="polite"
	aria-expanded="false">
	Show
</button>

<div id="your-target-id" class="is-hidden"></div>

type="button"

This is standard HTML to make a button be a button.

data-action="hide-show"

This attribute calls the plugin on this element.

data-text="hide"

This is the text you want to replace the current button text when the toggle happens, it is optional.

data-class="is-hidden"

If you're using a class to hide content, add that here otherwise the plugin will just use JavaScript, this is optional

aria-controls="your-target-id"

This tells the plugin which div to target for the hide-show. It is the ID attribute for the element.

aria-live="polite"

If you're updating the button text iwht data-text, you'll need this to alert screen readers.

aria-expanded="false"

The default state of the target area, false = closed, true = open

Syntax for using a link as the toggle

This could have all the say attributes as the button toggle, but some are a bit redundant

<a
	href="#your-target-id-2"
	data-action="hide-show"
	data-text="Hide"
	data-class="is-hidden"
	aria-live="polite">
	Show
</a>

<div id="your-target-id-2" class="is-hidden"></div>

a11y-hideshow's People

Contributors

timwright12 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.