v-contrast

Directive

Automatically adjusts foreground text colour to meet the WCAG AA contrast ratio (4.5:1 by default, configurable via createOrigam). Pass false to opt out on a specific element.

API

Value / Arguments

Shape of the binding value and each property in the options object.

value
boolean | undefined
Omit or set to true to enable auto-contrast. Pass false to disable contrast enforcement for this element only.

The threshold and algorithm are set globally in createOrigam({ contrast: { threshold: 4.5 } }). Individual elements can override with v-contrast="false" but cannot raise the threshold above the global value.

Usage

Examples

Ready-to-paste code snippets for your templates.

Auto-contrast on a coloured surface

vue

Per-element opt-out

vue