Skip to main content

Color Composition

Fill Mixin

The fill mixin lets you apply background color to an element while creating an API around it that follows the Hashi spec.

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.color-fill('component', 'primary-400');
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$colortoken or colorThe fill color you want to apply.
$intentstringThe intention of the color application. Choose between create and bind.

Ink Mixin

The ink mixin lets you apply text color to an element while creating an API around it that follows the Hashi spec.

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.color-ink('component', 'primary-400');
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$colortoken or colorThe text color you want to apply.
$intentstringThe intention of the color application. Choose between create and bind.

Border Mixin

The border mixin lets you apply border color to an element while creating an API around it that follows the Hashi spec.

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.color-border('component', 'primary-400');
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$colortoken or colorThe border color you want to apply.
$intentstringThe intention of the color application. Choose between create and bind.

Apply Mixin

This mixin is located inside the main hashi module. This mixin allows you to apply colors based on Hashi's component color anatomy spec, and creating an API with it.

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.color-apply('component', (
fill: '',
ink: '',
border: ''
));
}

Syntax

@mixin color-apply($component, $theme) { ... }
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$thememap<string, string>The colors you want to apply. (fill, ink, border)

Bind Mixin

This mixin is located inside the main hashi module. This mixin allows you to bind colors based on Hashi's component color anatomy spec to an existing styled component (with the appropriate keys).

This is especially useful whenever you want to make variants in color on an already styled component.

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.color-bind('component', (
fill: '',
ink: '',
border: ''
));
}

Syntax

@mixin color-bind($component, $theme) { ... }
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$thememap<string, string>The colors you want to apply. (fill, ink, border)