• Stars
    star
    277
  • Rank 148,875 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“Ÿ Accessible character counter for input elements

Short and Sweet, Accessible Character Counter

License: MIT npm version

Tested with VoiceOver (Safari 11) & NVDA (FF 60)

  • Tells user the amount of space left when the field is focussed
  • Updates the user periodically while typing

Play around with the demo:

https://codepen.io/rikschennink/pen/LmoJYY

View a video of Short and Sweet with VoiceOver:

http://www.youtube.com/watch?v=3NDCEvHHaCY (sound is off)


Buy me a Coffee / Dev updates on Twitter


Features

  • No dependencies
  • Easy setup
  • Accessible

Installation

Install from npm:

npm install short-and-sweet --save

Or download dist/short-and-sweet.min.js and include the script on your page like shown below.

Usage

Run short-and-sweet like shown below and pass an element reference or a querySelector. For best performance include the script just before the closing </body> element.

<textarea maxlength="200"></textarea>

<script src="short-and-sweet.min.js"></script>
<script>
    shortAndSweet('textarea', {
        counterClassName: 'my-short-and-sweet-counter',
    });
</script>

The following options are available to pass to the shortAndSweet method.

Option Default Description
counterClassName 'short-and-sweet-counter' The classname of the counter element
counterLabel '{remaining} characters left' The text shown in the counter element, placeholders available are {remaining}, {maxlength}, {length}
assistDelay 2000 The time in milliseconds the assist waits before updating the user with the screenreader user with the current count
append (el, counter) => { el.parentNode.appendChild(counter); } The method used to append the element to the DOM

Tested

  • Modern browsers
  • VoiceOver + Safari
  • NVDA + Firefox
  • IE 10+

Versioning

Versioning follows Semver.

License

MIT

More Repositories

1

fitty

✨ Makes text fit perfectly
JavaScript
3,615
star
2

shiny

🌟 Shiny reflections for mobile websites
JavaScript
2,807
star
3

conditioner

πŸ’†πŸ» Frizz free, context-aware, JavaScript modules
JavaScript
1,068
star
4

tilt

πŸ‚ Simulates touch feedback on HTML elements
CSS
42
star
5

eve-of-impact

πŸŒβ˜„οΈ Eve of Impact iOS game source code
Objective-C
33
star
6

scrollscreen

🌁 Custom styled vertical scrollbars
JavaScript
12
star
7

smashing-magazine-lazy-loading-javascript-with-conditioner

πŸ‘©πŸ»β€πŸ’» Example code for Smashing Magazine article on Conditioner
HTML
8
star
8

react-contextual-router

πŸ“±Render components based on user context
JavaScript
7
star
9

cordova-tabbar

Native iOS TabBar for Cordova
Objective-C
4
star
10

conditioner-boilerplate-amd

An AMD based boilerplate for Conditioner based on RequireJS.
JavaScript
3
star
11

rikschennink.nl

Personal website
HTML
3
star
12

conditioner-boilerplate-webpack

A webpack boilerplate for Conditioner.
JavaScript
3
star
13

quick-fox

Quick Character Visualizer for Web Safe Fonts
3
star
14

prompt-reader

Reddit WritingPrompts Reader
2
star
15

sunsets

A collection of 15 moody sunsets (2560 x 1920)
2
star
16

aria-autopilot

πŸ€– Declarative accessibility control
2
star
17

conditioner-boilerplate-esm

An ES Module based boilerplate for Conditioner
HTML
2
star
18

cordova-networkactivity

Toggle network activity indicator on iOS
Objective-C
2
star
19

highlightjs-themes

Themes for HighlightJS
CSS
2
star
20

conditioner-boilerplate-global

A global scope based boilerplate for Conditioner.
JavaScript
1
star
21

ds-character-count

An accessible character count prototype
JavaScript
1
star
22

poost

Boost form posts
JavaScript
1
star
23

webspockify

NodeJS WebSocket Server to Control Spotify
JavaScript
1
star
24

wally

Subway map of New York traced in Affinity Designer
1
star
25

eve-of-impact-www

Website for Eve of Impact
HTML
1
star
26

cordova-loadingindicator

Cordova iOS loading indicator plugin
Objective-C
1
star
27

gulpin-sass-to-css

Related to article Gulpin SASS to CSS
JavaScript
1
star
28

simulate

simple particle simulator
JavaScript
1
star
29

conditioner-bower

Bower Endpoint for ConditionerJS
1
star
30

hva-css-minor

HTML
1
star
31

conditioner-boilerplate-browserify

A Browserify boilerplate for Conditioner.
JavaScript
1
star