weableColor Icon
OverviewPricingDocsToolsBlogCase Studies
Get Started
Back to Blog

Beyond WCAG: Introducing APCA Calculation in @weable/a11y-color-utils

4/19/2025

contrast
apca
accessibility
weable
library

While WCAG 2.x contrast ratios are the current standard, the accessibility world is moving towards more perceptually accurate models. The leading candidate is the Accessible Perceptual Contrast Algorithm (APCA), and the @weable/a11y-color-utils library brings this advanced calculation directly into your workflow.

What is APCA?

APCA is a newer contrast algorithm designed to better reflect how humans actually perceive differences in text readability based on color, font size, and font weight. Unlike WCAG's single ratio, APCA produces a Lightness Contrast (Lc) score. This score, combined with lookup tables based on font size and weight, gives a more nuanced assessment of readability.

Key advantages of APCA include:

  • Better handling of light text on dark backgrounds.
  • More accurate predictions for thin or decorative fonts.
  • Context-dependent recommendations (e.g., body text needs higher Lc than large headlines).

Using APCA with WeAble

Our library makes using APCA straightforward with the calculateAPCA function:

import { calculateAPCA, initLicense } from '@weable-tools/a11y-color-utils';

// Remember to initialize!
initLicense('YOUR_LICENSE_KEY');

const foreground = '#FFFFFF';
const background = '#333333';
const fontSize = 16; // Optional: Font size in pixels (default is 16)

const apcaScore = calculateAPCA(foreground, background, fontSize);

console.log(`APCA Lightness Contrast (Lc): ${apcaScore}`);
// Example Output: APCA Lightness Contrast (Lc): 78.9

Parameters:

  • fgColorHex (string): Foreground color hex code.
  • bgColorHex (string): Background color hex code.
  • fontSize (number, optional): The font size in pixels. Defaults to 16px if omitted. Providing an accurate font size improves the relevance of the APCA score.

Return Value:

  • Returns a number representing the APCA Lc score, or null if the input colors are invalid.

Interpreting APCA Scores

Interpreting the Lc score requires referring to the APCA guidelines and lookup tables. Generally:

  • Lc 90+: Preferred for thin fonts and critical body text.
  • Lc 75+: Minimum for normal body text (like 16px, 400 weight).
  • Lc 60+: Minimum for larger text (e.g., 24px) or non-text elements.
  • Lc 45+: Minimum for very large/bold text (e.g., 36px bold headlines).

(Note: These are simplified guidelines. Always consult the official APCA documentation and tables for specific use cases and font weights.)

Why Use It Now?

Even though APCA isn't the official conformance standard yet, incorporating calculateAPCA into your checks provides valuable insights:

  • Future-Proofing: Prepare for potential future adoption of APCA in standards.
  • Enhanced Readability: Identify and fix combinations that pass WCAG but might still be difficult for users.
  • Informed Design: Make better color choices based on a more perceptually accurate model.

The @weable/a11y-color-utils library gives you the tools to leverage both established WCAG standards and cutting-edge APCA calculations, helping you build the most accessible experiences possible.

weableColor Icon
weableColor

Making accessibility sexy, one color at a time. Professional tools for developers who care about inclusive design.

WCAG 2.1 AA
APCA Ready
Products

© 2025 weableColor. All rights reserved. Made with ❤️ for accessible design.

Built with:

TypeScript
SACA