Using npm:
$ npm i wcag-compliant-accessible-library
This library can be used with either ESM or CommonJS.
In the following example, you can see the import and passing of the properties using an example component.
import { WCAGH2H58 } from 'wcag-compliant-accessible-library'
...
<WCAGH2H58
imageData={{
imageSource: image,
additionalStyling: { height: 75, width: 75 },
}}
link="/star-id"
childrenBeforeImage
>
<div>Go to the home page</div>
</WCAGH2H58>
...
This library deals with the WCAG 2.2 success criteria.
WCAG stands for Web Consortium Accessibility Guidelines and is an initiative of the World Wide Web Consortium.
The aim behind these guidelines is to make the internet accessible to a wider audience.
The WCAG 2 guidelines are primarily aimed at people with disabilities, people with impaired vision and hearing, impaired movement, speech impairments, photosensitivity and cognitive impairments.
However, people without these disabilities will also benefit from these guidelines.
These guidelines apply to web content for desktops, laptops, tablets and mobile devices.
WCAG 2.2 is divided into four chapters:
-
Perceivable,
-
Operable,
-
Understandable and
-
Robust.
For each of these four principles, the W3C provides a set of success criteria that should be met to ensure digital accessibility.
(World Wide Web Consortium, Inc., 2023)
This library fulfils a number of these criteria for success.
A number of components are provided which are not styled at all.
This means that you can easily integrate your own designs.
This library takes up two of these four principles: 1) Perceivable and 3) Understandable.
The success criteria covered in this library are:
Each of these success criteria is given certain techniques by the W3C which fulfil these criteria.
These defined techniques and components have been implemented in this library:
(World Wide Web Consortium, Inc., 2023)
You can find the Storybook here.
The technologies used are listed in sequence according to the WCAG prefix.
They start with either ARIA, G or H.
WCAGNonTextContent:
By using this component you fulfil the success criteria 1.1.1 Non-text Content, 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<input title="description" lang="de" />
By using this component you fulfil the success criteria 1.1.1 Non-text Content and 3.1.2 Language of Parts
Code snippet:
<div aria-label="description" lang="de"> children </div>
By using this component you fulfil the success criteria 1.1.1 Non-text Content and 3.1.2 Language of Parts
Code snippet:
WCAGARIA10H58:
<div aria-labelledbyid="id" lang="de"> children </div>
WCAGARIA10H58Text:
<div id="id" lang="de"> children </div>
By using this component you fulfil the success criteria 1.1.1 Non-text Content and 3.1.2 Language of Parts
Code snippet:
WCAGARIA15H58:
<>
<img aria-describedby="id" src={imageSource-1} />
<img aria-describedby="id" src={imageSource-2} />
</>
WCAGARIA15H58Text:
<p id="id" lang="de"> children </p>
By using this component you fulfil the WCAG2.2 success criteria 1.1.1 Non-text Content and 3.1.2 Language of Parts
Code snippet:
WCAGG73H58:
<div aria-describedby="long-desc" id="div-id" lang="de">
children
<a target="_blank" href="#long-desc"> buttonText </a>
shortText
</div>
WCAGG73H58Text:
<div id="long-desc" lang="de">
children
<p>
<a target="_blank" href="#div-id"> buttonText </a>
</p>
</div>
By using this component you fulfil the success criteria 1.1.1 Non-text Content and 3.1.2 Language of Parts
Code snippet:
WCAGG74G92H58:
<div aria-describedby="long-desc" lang="de">
children
shortText
</div>
WCAGG74G92H58Text:
<p id="long-desc" lang="de"> children </p>
By using this component you fulfil the success criterion 1.1.1 Non-text Content
Code snippet:
<>
<img alt="description" src={imageSource-1} />
<img src={imageSource-2} />
</>
By using this component you fulfil the success criteria 1.1.1 Non-text Content, 2.4.4 Link Purpose (In Context), 2.4.9 Link Purpose (Link Only) and 3.1.2 Language of Parts
Code snippet:
<a target="_blank" href="link" lang="de">
children
<img src={imageSource} />
</a>
By using this component you fulfil the success criteria 1.1.1 Non-text Content, 2.4.4 Link Purpose (In Context) and 2.4.9 Link Purpose (Link Only)
Code snippet:
<>
<img useMap"#mapName" src={imageSource} />
<map name="mapName">
<area coords="0 0 0 0" shape"rect" />
</map>
</>
By using this component you fulfil the success criteria 1.1.1 Non-text Content, 2.4.4 Link Purpose (In Context), 2.4.9 Link Purpose (Link Only) and 3.1.2 Language of Parts
Code snippet:
<a target="_blank" href="link" lang="de">
preImageText
<img src={imageSource-1} />
<img src={imageSource-2} />
postImageText
</a>
By using this component you fulfil the success criterion 1.1.1 Non-text Content
Code snippet:
<input type="image" alt="description" />
By using this component you fulfil the success criterion 1.1.1 Non-text Content
Code snippet:
<img alt="description" src={imageSource} />
By using this component you fulfil the success criteria 1.1.1 Non-text Content, 1.3.1 Info and Relationships, 3.1.2 Language of Parts and 3.3.2 Labels or Instructions
Code snippet:
<>
<label htmlFor="id" lang="de"> labelText </label>
<select/textarea/input id="id"> options </select/textarea/input>
</>
By using this component you fulfil the success criteria 1.1.1 Non-text Content, 1.2.3 Audio Description or Media Alternative (Prerecorded) and 1.2.8 Media Alternative (Prerecorded)
Code snippet:
<object> children </object>
By using this component you fulfil the success criteria 1.1.1 Non-text Content and 3.1.2 Language of Parts
Code snippet:
<span aria-label="description" lang="de"> emoji </span> or
<div aria-label="description" lang="de"> emoji </div> or
<abbr title="description" lang="de"> emoji </abbr>
By using this component you fulfil the WCAG2.2 success criterion 1.1.1 Non-text Content
Code snippet:
<img alt="" src={imageSource} />
WCAGInfoAndRelationships:
By using this component you fulfil the success criteria 1.3.1 Info and Relationships, 3.1.2 Language of Parts and 3.3.2 Labels or Instructions
Code snippet:
<form (optional)>
<fieldset>
<legend> legendText </legend>
<div lang="de">
<input id="id" />
<label htmlFor="id"> labelText </label>
</div>
</fieldset>
</form>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<form>
<label htmlFor="id"> labelText </label>
<select id="id">
<optgroup>
<option lang="de"> option </option>
<option lang="de"> option </option>
</optgroup>
</select>
</form>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships, 1.3.6 Identify Purpose , 2.4.1 Bypass Blocks and 3.1.2 Language of Parts
Code snippet:
<div lang="de" aria-label="description"> children </div> or
<form lang="de" aria-label="description"> children </form>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<div aria-level="3" lang="de"> children </div>
By using this component you fulfil success criterion 1.3.1 Info and Relationships
Code snippet:
<code> children </code>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<a target="_blank" href="link" lang="de"> children </a>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<b lang="de"> children </b>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<cite lang="de"> children </cite>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<em lang="de"> children </em>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<blockquote lang="de"> children </blockquote>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<q lang="de"> children </q>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<strong lang="de"> children </strong>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<sub lang="de"> children </sub>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<sup lang="de"> children </sup>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<ul>
<li lang="de"> item </li>
<li lang="de"> item </li>
</ul>
or
<ol>
<li lang="de"> item </li>
<li lang="de"> item </li>
</ol>
or
<dl>
<div>
<dt lang="de"> name </dt>
<dd lang="de"> description </dd>
</div>
</dl>
By using this component you fulfil the success criteria 1.3.1 Info and Relationships, 2.4.1 Bypass Blocks and 3.1.2 Language of Parts
Code snippet:
<nav>
<ul>
<li>
<a target="_blank" href="link" lang="de"> displayedText </a>
<a target="_blank" href="link" lang="de"> displayedText </a>
</li>
</ul>
</nav>
By using this component you fulfil the success criteria 1.1.1 Non-text Content, 1.2.3 Audio Description or Media Alternative (Prerecorded), 1.2.8 Media Alternative (Prerecorded), 1.3.1 Info and Relationships and 3.1.2 Language of Parts
Code snippet:
<table>
<caption> captionText </caption>
<tbody>
<tr>
<th id="id" scope"col" lang="de"> header </th>
</tr>
<tr headers="id">
<td lang="de"> item </td>
</tr>
<tr headers="id">
<td lang="de"> item </td>
</tr>
</tbody>
</table>
WCAGIdentifyInputPurpose
By using this component you fulfil the success criteria 1.3.5 Identify Input Purpose, 3.1.2 Language of Parts, 3.2.2 On Input and 3.3.2 Labels or Instructions
Code snippet:
<form>
changedContextText (optional)
<div>
<label htmlFor="id"> labelText </label>
<input type="month" autocomplete="bday-month" id="id" />
</div>
<div>
<input type="submit" /> (div and submit are optional)
</div>
</form>
You can find the Storybook here.