Mixins
flex Mixinâ
Quickly create flexbox layouts:
@mixin flex($direction: row, $justify: normal, $align: normal, $wrap: nowrap) // Usage
.my-container {
@include flex($justify: center, $align: center);
}
.my-column {
@include flex($direction: column, $justify: space-between);
}
font Mixinâ
Apply font styles consistently:
@mixin font($size: $t3-text, $color: $primary-text-clr, $weight: normal) // Usage
.my-label {
@include font($size: $t4-text, $color: $ink-lighter-clr, $weight: bold);
}
typography Mixinâ
Enhanced typography with more options:
@mixin typography(
$size: 14,
$weight: "regular",
$color: $primary-text-clr,
$line-height: 1.5,
$family: $primary-font
) // Usage
.field-label {
@include typography(14, "bold", $primary-text-clr);
}
.section-heading {
@include typography(16, "bold", $primary-text-clr);
}
text-truncate Mixinâ
Truncate text with ellipsis:
@mixin text-truncate($lines: 1) // Single line truncation
.truncate-single {
@include text-truncate(1);
}
// Multi-line truncation
.truncate-multi {
@include text-truncate(3);
}
transition-linear Mixinâ
Standard transition for hover effects:
@mixin transition-linear // Usage
.my-button {
@include transition-linear;
&:hover {
background: $brand-hover-color;
}
}
Utility Classesâ
Font Size Classesâ
.fs-12, .f12 // 12px
.fs-14, .f14 // 14px
.fs-16, .f16 // 16px
.fs-18, .f18 // 18px
.fs-20, .f20 // 20px
.fs-24, .f24 // 24px
Font Weight Classesâ
.fw-regular // 400
.fw-medium // 500
.fw-bold // 600
.fw-bolder // 900
.bold // 600 (legacy)
.bolder // 900 (legacy)
Line Height Classesâ
.lh-tight // 1.2
.lh-normal // 1.5
.lh-relaxed // 1.75
.lh-loose // 2
Text Truncation Classesâ
.text-truncate // Single line
.text-truncate-2 // 2 lines
.text-truncate-3 // 3 lines
Creating New Componentsâ
When adding new components, follow this pattern:
// 1. Import helpers
@import "../helpers/index.scss";
// 2. Scope under .cm-admin
.cm-admin .my-component {
// 3. Extend Bootstrap classes
@extend .d-flex, .align-items-center;
// 4. Use cm-admin variables
background: $grey-lightest-clr;
border-radius: $radius-4;
// 5. Use mixins for common patterns
@include font($size: $t4-text, $color: $primary-text-clr);
// 6. Add custom styles
padding: 16px;
&:hover {
@include transition-linear;
background: $grey-lighter-clr;
}
}
Example: Custom Alertâ
@import "../helpers/index";
.cm-admin .alert {
@extend .alert-dismissible, .d-flex, .align-items-center;
}
.flag-alert {
max-width: 752px;
padding: 24px;
background: $red-lightest-clr;
border-radius: $radius-4;
.alert-header {
@include font($size: $t6-text, $color: $red-regular-clr, $weight: bold);
text-transform: uppercase;
}
.alert-body {
margin-top: 16px;
.body-title {
@include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
}
}
}
Best Practicesâ
- Always scope under
.cm-admin- Prevents style leakage - Use
@extendfor Bootstrap classes - Keeps markup clean - Prefer variables over hardcoded values - Ensures consistency
- Use mixins for repeated patterns - Reduces code duplication
- Follow the color scale - Use semantic colors for states (error, success, etc.)