npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

a11y-syntax-highlighting

v1.1.0

Published

Accessible light and dark syntax highlighting themes.

Downloads

129

Readme

a11y-syntax-highlighting

Accessible light and dark syntax highlighting themes. Supports WCAG level AA contrast requirements (good for most websites and apps).

Use

You can download the files directly, or use NPM. After that you can either link to the CSS you need directly, or incorporate it into your build sustem.

Other services are also supported.

Supported

Libraries

Applications

Misc

  • Carbon (remember to include alt text with your image!)
  • JSON

Themes

a11y-dark

The a11y-dark theme being applied to the HTML of the Prism.js website. Screenshot.

  • Light text on a dark background.
  • Background color of #2B2B2B.
  • WCAG AAA compliant for color contrast.

| Color | Hex | Ratio | Normal Text | Large Text | | :---- | :-- | ----: | :---------- | :--------- | | Background | #2B2B2B | N/A | N/A | N/A | | No token | #F8F8F2 | 13.28:1 | AAA | AAA | | Comment | #D4D0AB | 9.04:1 | AAA | AAA | | Blue | #00E0E0 | 8.58:1 | AAA | AAA | | Green | #ABE338 | 9.28:1 | AAA | AAA | | Gray | #F8F8F2 | 13.28:1 | AAA | AAA | | Orange | #F5AB32 | 7.25:1 | AAA | AAA | | Purple | #DCC6E0 | 8.89:1 | AAA | AAA | | Red | #FFA07A | 7.12:1 | AAA | AAA | | Yellow | #FFD700 | 10.09:1 | AAA | AAA |

a11y-light

The a11y-light theme being applied to the HTML of the Prism.js website. Screenshot.

  • Dark text on a light background.
  • Background color of #FEFEFE.
  • WCAG AA compliant for color contrast. WCAG AAA compliance forces the values on a light background to be too similar to each other to be used effectively for syntax highlighting.

| Color | Hex | Ratio | Normal Text | Large Text | | :---- | :-- | ----: | :---------- | :--------- | | Background | #FEFEFE | N/A | N/A | N/A | | No token | #545454 | 7.5:1 | AAA | AAA | | Comment | #802200 | 9.69:1 | AAA | AAA | | Blue | #007299 | 5.38:1 | AA | AAA | | Green | #008000 | 5.09:1 | AA | AAA | | Gray | #696969 | 5.44:1 | AA | AAA | | Orange | #A85D00 | 4.92:1 | AA | AAA | | Purple | #9400D3 | 6.5:1 | AA | AAA | | Red | #D91E18 | 5.01:1 | AA | AA | | Yellow | #856514 | 5.38:1 | AA | AAA |

Forced Colors mode

Both themes have enhanced support for Windows High Contrast Mode when possible:

The a11y-dark theme responding to Windows High Contrast Mode. Screenshot.

FAQ

Can you explain what the filenames mean?

  • a11y-light-on-light-dark-on-dark: This theme contains both light text on a dark background and dark text on a light background visual treatments for code. It is set to show a light background color for code when your operating system's light mode is active, and a dark background color when your operating system's dark mode is active.
  • a11y-dark-on-light-light-on-dark: This theme contains both light text on a dark background and dark text on a light background visual treatments for code. It is set to show a dark background color for code when your operating system's light mode is active, and a light background color when your operating system's dark mode is active.
  • a11y-light: This theme uses a light background color for code for an operating system's light and dark modes.
  • a11y-dark: This theme uses a dark background color for code for an operating system's light and dark modes.
  • Files that end with .min.css: These themes have had their contents compressed to be used in production environments.
  • a11y-dark-legacy.css, a11y-dark-legacy.min.css a11y-light-legacy.css, a11y-light-legacy.min.css: These files are for Internet Explorer support.

What's the difference between non-legacy and legacy files?

The current version of each syntax file uses features not supported by Internet Explorer. These features include:

Only use the legacy files if you need to support Internet Explorer. Otherwise, syntax highlighting will not work for this browser.

How do I only use light text on a dark background visual treatment, or vice-versa?

Don't use a11y.css or a11y.min.css, as they use the prefers-color-scheme media query. Pick either a11y-light-on-dark.min.css or a11y-dark-on-light.min.csss depending on what you want.

What happened to the old color names?

Naming things is hard. I had to redo them to have better control between light and dark modes, as well as normalization across different services.

What's the difference between -ms-high-contrast and forced-colors?

forced-colors is a cross-browser standard derived from the propritary -ms-high-contrast declaraction. It has a slightly different syntax, but will also honor legacy -ms-high-contrast code.

-ms-high-contrast will not honor forced-colors code. The situation is a bit of a mess, honestly. You can read more about the difference between Windows High Contrast Mode and cross-browser Forced Colors mode in this Smashing Magazine article.

I noticed that the colors in the Forced Color Mode screenshot don't all look like they have high enough contrast?

This is by design. These colors are dynamic, and can be adjusted by the person using the theme to make the experience work for their vision needs.

Something strange is going on with inheriteance, can you help?

Check your Cascade Layer order. These themes use the vendor-prism and vendor-highlight namespaces, respectively.

Will you consider supporting this service I use?

Possibly! Raise an issue and let's talk about it.

I don't like these colors, can you change them?

I'm not interested in that, but modifying the CSS Custom Property values is a good starting point. Just make sure to check the foreground's color value against the background color value to make sure it passes level AA.

Roadmap

Used by

Run across it being used elsewhere? Let me know!

Thanks