UI Introduction
cm-admin uses Bootstrap 5 as its CSS foundation, wrapped inside a .cm-admin root class to ensure style isolation and prevent conflicts with the host application's styles.
Design System: CM-Admin Design System (Figma)
Core Concept: Scoped Bootstrapâ
All cm-admin styles are scoped under the .cm-admin class. When creating custom components, we use SCSS @extend to inherit Bootstrap classes while keeping them namespaced:
// Don't use Bootstrap classes directly in markup
<button class="btn btn-primary btn-sm">Click</button>
// Use cm-admin scoped classes
<button class="btn-cta">Click</button>
How It Worksâ
@import "../helpers/index.scss";
// Custom button extending Bootstrap classes
.cm-admin .btn-cta {
@extend .btn, .btn-sm;
--bs-btn-color: var(--bs-white);
--bs-btn-bg: var(--bs-primary);
}
.cm-admin .btn-primary {
@extend .btn, .btn-outline-primary, .btn-sm;
}
This pattern:
- Isolates styles - cm-admin styles won't leak into the host app
- Leverages Bootstrap - Full access to Bootstrap's utility classes and components
- Enables customization - Override Bootstrap variables and add custom properties
File Structureâ
app/assets/stylesheets/cm_admin/
âââ helpers/
â âââ _variable.scss # Color, typography, spacing variables
â âââ _mixins.scss # Reusable mixins (flex, font, etc.)
â âââ _typography.scss # Typography utilities and classes
â âââ index.scss # Exports all helpers
âââ components/
â âââ _buttons.scss
â âââ _alerts.scss
â âââ _modal.scss
â âââ ...
âââ base/ # Page-specific styles
âââ dependency/
âââ bootstrap/ # Bootstrap source files