Skip to main content

Accessibility

Functions​

contrast()​

contrast<Color>(a, b): number

Gets the contrast between the passed in colors.

tip

Swapping color a and b in the parameter list doesn't change the resulting value.

Type Parameters​

β€’ Color extends ColorToken

Parameters​

β€’ a: Color

First color to query.

β€’ b: Color

The color to compare against.

Returns​

number

Example​

import { contrast } from 'huetiful-js'

console.log(contrast("black", "white"));
// 21

Defined in​

accessibility.ts:30


deficiency()​

deficiency<Color, Options>(color, options?): ColorToken

Simulates how a color may be perceived by people with color vision deficiency.

tip

To avoid writing the long types, the expected parameters for the kind of blindness are simply the colors that are hard to perceive for the type of color blindness:

  • 'tritanopia' - An inability to distinguish the color 'blue'. The kind is 'blue'.
  • 'deuteranopia' - An inability to distinguish the color 'green'.. The kind is 'green'.
  • 'protanopia' - An inability to distinguish the color 'red'. The kind is 'red'.

Type Parameters​

β€’ Color extends ColorToken

β€’ Options extends DeficiencyOptions

Parameters​

β€’ color: Color

The color to return its simulated variant

β€’ options?: Options

Returns​

ColorToken

Example​

import { deficiency } from 'huetiful-js'

// Here we are simulating color blindness of tritanomaly or we can't see 'blue'.
// We are passing in our color as an array of channel values in the mode "rgb". The severity is set to 0.5

console.log(deficiency(['rgb', 230, 100, 50, 0.5],{ kind:'blue', severity:0.5 }))
// '#dd663680'

Defined in​

accessibility.ts:140