• Stars
    star
    455
  • Rank 96,175 (Top 2 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Various styled accessible form controls

The Accessibility of Styled Form Controls

A repository of styled and "styled" form control elements and markup patterns, and how they are announced by screen readers.

Why?

Form controls are necessary in many interfaces, but are often considered annoying, if not downright difficult, to style. Many of the markup patterns presented here can serve as a baseline for building more attractive form controls without having to exclude users who may rely on assistive technology to get things done.

In some cases, there may be a lack of support, or complications that arise when controls are styled. Those instances will be noted as well.

How to use?

Largely, many of these demos can be copied and pasted into your pattern library, project, or pattern library project. Each form control has its own CSS file, and a JavaScript file as necessary. Each form control shares the --demo-only--.css and --shared--.css files. These stylesheets are largely only for use on these demo pages. Many of the shared styles are merely instances of a few normalize.css selectors.

Wait, JavaScript?

Yes, while many of these form controls can be styled with some thoughtful maneuvering of markup and CSS, controls such as file uploads, toggle buttons and switches need a bit of JavaScript (and sometime ARIA) to properly function and convey state.

The Different Form Elements

The following controls and elements each have demo pages with additional documentation pertaining to implementation, UX, and screen reader announcements.

Regarding screen reader announcements...

Note the documentation of screen reader announcements is based on using the versions of the screen reader and browser combos, as indicated on each test page. Be sure to check the last updated date of each test page. Documentation is noted as "updated" when new testing or techniques have changed. Editorial updates may not constitute a change in the posted updated date.

Things may change as browsers and screen readers are updated, so please refer to these as a snapshot in time rather than being definitive results.

If you find that announcements and/or support has changed, please file an issue!

Checkboxes and Radio Buttons

Styled HTML checkboxes, and radio button patterns.

Checkboxes can be used as a single form option, or grouped with similar checkboxes. Within a group, one or more checkboxes may be checked by the user. In contrast, radio buttons provide users two or more options to choose from, but only one option may be chosen from a radio button grouping at a time.

  1. Styled Checkboxes
  2. Styled Radio Buttons
  3. Radio Button Star Rating
  4. Radio Button Pill

Switches & Toggle Buttons

Switches are a type of form control that are often visually represented as an on/off toggle. A toggle button may be styled similarly, or as a button that has a clear difference between the default and active (pressed) state. A toggle button is created when a button has the aria-pressed attribute set to true or false.

Unlike checkboxes, which are largely used in the context of forms where a user submits data after filling out all necessary information, switches and toggle buttons can be used to perform an instant change to a component or application's state. As there is no "switch" in HTML, a checkbox or button element can be progressively enhanced into a switch, with the appropriate ARIA attributes.

  1. Switch Checkbox
  2. ARIA Switch Controls (external repo)
  3. ARIA Toggle Button
  4. Switch Radio Button Group

File Upload

A styled file upload form control that relies on the native HTML input type="file" for providing the appropriate announcements to screen readers.

A file upload allows users to add one, or more, file(s) to submit with a form.

  1. File Upload

Range Slider

A styled input type="range" form control that takes multiple browser's CSS implementations into consideration.

Range sliders allow users to select a point, or a scoped range, from a series of data.

  1. Range Slider

Select Boxes

Styled single and multi-select patterns.

Selects allow a user to pick one or more options from a menu of choices.

  1. Select (single)

Progress Bar & Meter

Progress bars indicate the current status of a particular task, or tasks, on a scale of 0 to completion. A meter acts as a gauge and indicates a value within a finite value set.

The progress and meter elements are considered form elements, but they are not focusable form controls.

Unfortunately, neither of these elements are consistently accessible to screen readers. Styling each can actually make them even more inaccessible...

  1. Progress Bar
  2. Meter

Search Component

A search component offers users an easily discoverable way to find information in a website or application.

  1. Search Component

Contribute?

There are still patterns to make and test, as well as retesting of current patterns to ensure nothing gets stale. File or check out available issues for some of the stuff that needs working on :)

License, Thanks, and such

Everything here is under an MIT license.

While I was unaware of WTFForms when starting this project, it is still a great example of what can be done with only CSS, and served as an excellent baseline to compare against. Thank you mdo and to those involved with that project.

Additional thanks to Eric Bailey, Josh Drumm, James Curd, Adrian Roselli, Sara Soueidan, Heydon Pickering, Richard Keizer, Chris O'Brien and Alexander Farkas. They have each provided inspiration and/or excellent resources that have been quite helpful in the building of these components.

More Repositories

1

accessible_components

Listing of accessible components & patterns
652
star
2

accessibility_interview_questions

A starting point for questions to ask someone that wants you to give them a job
367
star
3

accessible_modal_window

Accessible modal dialogs
HTML
264
star
4

a11y_accordions

ES5 ARIA Accordion Component
JavaScript
135
star
5

Ground-Floor

Basic HTML Styling framework for starting up new, NeoCities websites.
HTML
81
star
6

a11y_tooltips

Accessible Tooltip Component
HTML
59
star
7

a11y_breadcrumbs

Accessible breadcrumb pattern
HTML
48
star
8

Brass-Tacks

Starting point for Sass projects. Really needs a good update though....
CSS
44
star
9

aria-switch-control

ARIA Switch control component
HTML
42
star
10

aria_disclosure_widget

Progressively enhanced hide/show content areas with vanilla JS & appropriate ARIA attributes
HTML
35
star
11

a11y_tab_widget

Accessible Tab Widget built with ARIA
HTML
28
star
12

landmarks_demo

A demonstration and informative document about landmark roles
HTML
22
star
13

aria_buttons

Make role="button" elements listen for Space & Enter Keypresses
HTML
7
star
14

a11y_switch_web_component

ARIA Switch control web component
JavaScript
7
star
15

css-focus-within-demos

Demos for :focus-within pseudo-class
HTML
5
star
16

accessible_hamburger

Archived - check out my disclosure widget pattern for a comparable script
5
star
17

tests

A place to share test files
HTML
4
star
18

aria_links

Fake links made with ARIA & Vanilla JavaScript
HTML
3
star
19

Numbler

jQuery plugin for accessible, styleable number input
HTML
3
star
20

clear-text-field-button

HTML
3
star
21

playground

A place to play
HTML
1
star