Skip to main content

Shape Composition

Width Mixin

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-width('component', 100vw);
// or
@include hashi.shape-width('component', (
default: 100%,
min: 10vw,
max: 100vw
));
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$widthnumber or mapThe width you want to apply.
$intentstringThe intention of the shape application. Choose between create and bind.

Height Mixin

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-height('component', 100vh);
// or
@include hashi.shape-height('component', (
default: 100%,
min: 10vh,
max: 100vh
));
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$heightnumber or mapThe height you want to apply.
$intentstringThe intention of the shape application. Choose between create and bind.

Radius Mixin

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-radius('component', hashi.token-get('radius-sm'));
// or
@include hashi.shape-radius('component', ('sm' 0 0 'sm'));
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$radiustoken, list, or numberThe radius you want to apply.
$intentstringThe intention of the shape application. Choose between create and bind.

Padding Mixin

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-padding('component', hashi.token-get('padding-sm'));
// or
@include hashi.shape-padding('component', ('sm' 0 0 'sm'));
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$paddingtoken, list, or numberThe padding you want to apply.
$intentstringThe intention of the shape application. Choose between create and bind.

Margin Mixin

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-margin('component', hashi.token-get('margin-sm'));
// or
@include hashi.shape-margin('component', ('sm' 0 0 'sm'));
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$paddingtoken, list, or numberThe margin you want to apply.
$intentstringThe intention of the shape application. Choose between create and bind.

Border Width Mixin

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-border-width('component', hashi.token-get('margin-sm'));
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$border-widthtoken or numberThe border width you want to apply.
$intentstringThe intention of the shape application. Choose between create and bind.

Border Style Mixin

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-border-style('component', hashi.token-get('margin-sm'));
}
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$border-stylestringThe border style you want to apply.
$intentstringThe intention of the shape application. Choose between create and bind.

shape-apply() mixin.

This mixin is located inside the main hashi module. This mixin allows you to apply shape properties, and creating an API with it.

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-apply('component', (
radius: 'small',
padding: ('xs' 'sm'),
margin: (0 0 'sm' 0),
gap: 'xs'
));
}

Syntax

@mixin shape-apply($component, $theme) { ... }
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$thememap<string, string>The shape properties you want to apply. (radius, padding, margin, gap, width, height, border-style, border-width)

shape-bind() mixin.

This mixin is located inside the main hashi module. This mixin allows you to bind shape properties to an existing styled component (with the appropriate keys).

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

@use 'node_modules/@devprotocol/hashi';

.hs-component {
@include hashi.shape-bind('component', (
radius: 'small',
padding: 'xs sm',
margin: '0 0 sm 0',
gap: 'xs'
));
}

Syntax

@mixin shape-bind($component, $theme) { ... }
ParameterTypeDescription
$componentstringThe component name. This is used for the keys.
$thememap<string, string>The shape properties you want to apply. (radius, padding, margin, gap, width, height, border-style, border-width)