getContrast
Commons
stable
Computes the WCAG 2 contrast ratio between two colors. A ratio of 4.5 meets AA for normal text; 3.0 meets AA for large text.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- firstrequisTColorType
- The first color — any format accepted by parseColor (#hex, rgb(), hsl(), number, RGBA/HSLA object).
- secondrequisTColorType
- The second color — same formats as first.
API
Valeur de retour
La valeur retournée par cet util.
- The WCAG 2 contrast ratio (1–21). Higher is better; 4.5 = AA for normal text, 7 = AAA.
Usage
Exemples
Extraits de code prêts à coller.
Check contrast between two colors