Color

Color Accessibility

Web accessibility empowers individuals with disabilities to fully engage with and contribute to the applications you develop. This crucial principle encompasses various aspects, including the intentional utilization of colors. Your color system should adhere to the principles of being perceivable, operable, understandable, and robust for all users.

Color Contrast Ratios

Color contrast compliance is required within our experience. The contrast ratio is the difference between colors that live on top of one another or next to one another, also known as adjacent colors. If the design elements within any design pattern contain information critical to understanding the interaction, it must pass color contrast.

  • Non-objects (ex. text on backgrounds): Any color that makes a 50 point difference or greater is a 4.5:1 or greater contrast ratio.
  • Objects (ex. buttons): Any color that makes a 40 point difference or greater is a 3:1 or greater contrast ratio.
  • All four objects in this example pass color contrast, including the default informational text (1), the informational non-text (2), the selected informational text (3), and the decorative non-text (4) objects.

    An example of good color contrast in a UI. All four objects here pass color contrast, including the default informational text (1), the informational non-text (2), the selected informational text (3), and the decorative non-text (4) objects.
    An example of good color contrast in a UI.

    Ensuring colors meet WCAG color contrast rules can be a tricky, manual process. Our system provides clear and obvious guidance on which colors work together, and which ones don’t. Built-in contrast ratio scores solve for those decisions.

    When designing any element of the UI there are questions we need to always be asking ourselves. Do you know what the difference between decorative and functional UI is? Is the UI element or elements of a design pattern decorative or functional? The answer to these questions determines the color contrast requirements of the UI element or elements being created.

    In this example, the badge provides necessary information for the user to understand in order to advance within an experience. These qualities make it functional. However, the UI elements that compose a badge may be functional (the text) or decorative (such as the shape or background.) This image shows a decorative background (1), a decorative badge (2), and functional text (3).

    Be considerate of each UI element's construction and its purpose. This image shows a decorative background (1), a decorative badge (2), and functional text (3).
    Be considerate of each UI element's construction and its purpose.

    For the neutral button in this example, the image shows a decorative background (4), a functional background within the visible container (5), a functional visible boundary (6), and functional text (7). Note that decisions can be more nuanced and should be informed by our color contrast guidelines. (Review the Color Contrast Rules in the section below.)

    Knowing whether a UI element is decorative or functional is crucial for meeting color contrast guidelines. Test your ability to design with accessibility compliance in mind by taking this How to Design with Color Contrast quiz.

    Color Contrast Rules: UI Design Cheat Sheet

    1. If it serves a function, make it contrast-compliant.
    2. Color contrast applies to text, state indicators, purpose indicators, and anything else that can be interpreted as crucial to understanding an interaction.

    3. Text always requires contrast.
    4. Text contrast requires 4.5:1, unless it’s large, and everything else is 3:1.

    5. To convey meaning, don’t solely rely on color.
    6. Avoid using color as the sole indicator of state in a component. Color should never be a primary indicator for something that is functional.

    7. Intended visibility must pass contrast.
    8. When a functional UI is visible at all, it should be visible for all, unless it’s purely decorative.

    9. Use secondary indicators.
    10. When trying to avoid relying on color for communication, height or width changes, icons, and secondary text-based indicators are your friend.

    The Numerical System

    In our numerical color system, it’s simple to remember the “magic numbers”:

  • Any color that makes a 50 point difference or greater is 4.5:1 or greater contrast ratio and meets accessibility compliance.
  • Any color that makes a 40 point difference or greater is 3:1 or greater contrast ratio and meets accessibility compliance.
  • What must be a 50 point difference?

  • Non-bold text that is less than 24px (1.5rem, 18pt) must meet 4.5:1 contrast
  • Bold text that is less than 19px (~1.2rem, 14pt) must meet 4.5:1 contrast
  • What must be a 40 point difference?

  • Text that is larger than 24px is considered “large” and can be as low as 3:1 contrast
  • Iconography (unless decorative)
  • Objects that are functional and can be interacted with. This rule also includes any visible boundary.
  • Decorative vs. Functional Elements

    We declare elements in our experience as either decorative or functional. Decorative elements aren’t required to pass color contrast accessibility requirements while functional items do.

  • Decorative refers to a visual in the UI that doesn’t convey information or possess functionality (ex. an illustration or a redundant object).
  • Functional describes a visual in the UI that is required for interaction, conveys information, or aids in error prevention (ex. a button.)
  • In this example, the decorative image (1) is an illustration being used for brand expression. It doesn’t include information or functionality that would disrupt a user from taking action. Because of that it isn’t required to pass color contrast. However, the functional button text and background (2) are required to be color contrast compliant. This is because they can be interacted with and convey important information.

    This image shows the differences between a decorative image (1) that does not convey important information and a functional button and text (2) that do.
    The differences between a decorative image (1) and a functional button with text (2).

    Keep in mind, however, that just because something doesn't "need" to pass color contrast doesn't mean it shouldn't. There are always opportunities to make a UI more accessible, even if there aren't rules that say it's needed. Just because there's a bare minimum doesn't mean we should strive for that. Designing accessibly serves all users better.

    Redundant vs. Informational

    What is the difference between when something is redundant and something is informational? A visual element becomes redundant when paired with a functional element.

    In this example, the displayed descriptive text for percentage on the progress bar makes the graphic of progress (in blue and gray) redundant.

    Do use descriptive text to make the UI accessible
    Do use descriptive text to make the UI accessible
    Don’t rely solely on color to relay information
    Don’t rely solely on color to relay information

    Having contextual awareness is important. Just because something is considered redundant here, doesn’t mean it may not be used elsewhere as an informational or functional element.

    Contextual Awareness

    An element may be compliant in one part of an experience but that doesn’t automatically mean that it’s compliant elsewhere. Understanding this principle is key to practicing contextual awareness while designing.

    In this example, because the first icon (1) isn’t paired with descriptive text it’s required to be 3:1 contrast ratio or greater. However, because the second icon (2) is paired with descriptive text, technically speaking, it isn’t required to pass 3:1. In our system, to alleviate deltas, all of our icons meet a 3:1 contrast ratio or greater.

    This image shows that when an icon isn’t paired with descriptive text (1) it’s required to be 3:1 contrast ratio compliant. However, when the icon is paired with descriptive text (2), it isn’t required to pass 3:1.
    An icon required to be 3:1 contrast ratio compliant (1), versus one that it isn’t required to pass (2).

    When Color is the Only Option

    Color contrast guidelines for state changes and other status communication are often hard to meet for complex interactions because of the number of colors that must contrast with each other.

    This requirement only applies when color is the only means of conveying information. Common ways to avoid this requirement by providing a secondary information source are:

  • Adding a state icon
  • Adding a text equivalent to visualizations
  • Adding a texture change to color blocks in charts
  • Thickness changes (such as borders)
  • Modification of shape (square versus circle, line versus dash)
  • These examples show that a state icon can act as a secondary information source that reduces sole reliance on color.

    Do use a state icon as a clear secondary information source
    Do use a state icon as a clear secondary information source
    Don’t rely solely on color to relay information
    Don’t rely solely on color to relay information

    Reverse Text on Relevant Backgrounds

    Although we commonly use white text on backgrounds, sometimes background colors are too light for white text or objects. In those cases, consider using dark text for added emphasis and to meet compliance.

    To read more about text on backgrounds, visit General Guidelines for Text on Backgrounds.

    Borders and Backgrounds Visibility

    If there’s a perceivable target boundary or click target, it must pass 3:1+ contrast ratio. This rule applies to gray borders and backgrounds. The w3C recommends making the target area visible to assist users with cognitive disabilities, and their recommendation is our rule.

    We saw the recommendation as an opportunity to evaluate our own patterns. In that investigation we recognized value in creating a rule for all interactive visual boundaries to meet a 3:1 or greater color contrast.

    In this example, the border in the first button’s target boundary uses neutral-60 and passes at 3:1. The second button doesn’t pass color contrast.

    Do use darker neutral colors for added emphasis and to meet compliance
    Do use darker neutral colors for added emphasis and to meet compliance
    Don’t use low constrast colors for functional elements
    Don’t use low contrast colors for functional elements

    Resources