DEV Community

Cover image for Accessible syntax highlighting colour schemes for developers
Paul Love for Measured

Posted on • Originally published at

Accessible syntax highlighting colour schemes for developers

Why we designed and released two Base16 colour schemes for publishing code on the web.

When we started Measured, we knew we’d want to write things about technical aspects of our work. Inevitably, that means publishing code snippets.

We built our website to comply with WCAG AA accessibility, so we needed our code snippets to comply too. That meant applying a colour scheme to snippets to comply with the WCAG requirements for contrast.

More than that, we actually needed two schemes because our website adapts to visitor system preferences for day and night modes.

When we went looking at colour schemes already out there, we ran into one of two issues:

  1. They weren’t AA-compliant
  2. They were visually jarring (and in a way that wouldn’t work alongside our existing brand colours)

So Scott set about creating them instead. We collectively decided to release them as open source in case people shared our need for AA-compliant Base16 schemes that, not to put too fine a point on it, also look quite nice.

They’re available on GitHub for anyone to use. The obvious use cases are for either writing or publishing code, but the underlying schemes could be used for any lightweight web project.

Notes on development

A few more points for anyone interested in a bit more detail:

We didn’t start from scratch. We used Solarized as the basis of the project. It didn’t meet AA criteria, but it did give us a good platform to build from. From there, we essentially adapted our brand colours to meet Base16 needs.

Once we’d decided to share the schemes, we were keen to contribute to the Base16 ecosystem. To that end, we submitted pull requests to a couple of GitHub projects with mixed success. But the schemes are now included at Tinted Theming.

We’ve assumed this project will potentially interest developers, so we haven’t included much hand-holding in the README. That said, we did want to make this work immediately useful, so the repo includes files to get the schemes working with widely-used tools. Specifically:

We don’t plan to do more work on this project, but we welcome contributions. There is scope to support more tooling, for example.

You can start using the Base16 Measured Scheme via the GitHub repo.

Top comments (0)