Clarifying design system needs
The user is asking about developing a component-driven design system using Bootstrap 5 and SCSS, which is quite broad. I think it might help to clarify the scope since they didn't specify details like the brand or target environment—whether it's React or plain HTML. They might be looking for guidelines, architecture, and code samples. I should aim for concise yet information-rich responses, perhaps creating examples without a specific brand palette.Creating design system overview
I need to provide an overview that includes goals and principles, along with a specific file structure for SCSS featuring partials. It's important to explain how to integrate Bootstrap 5 via SCSS, customize variables, and define design tokens like colors and typography. I also want to create custom components using BEM, include examples for buttons and forms, and cover theming possibly with Storybook. I must keep it concise and use current Bootstrap 5.3 knowledge. The structure looks like: architecture, setup, SCSS structure, and Bootstrap configuration.Defining example components
I want to outline some example components like buttons, cards, alerts, and layout containers, along with usage in HTML. I think it could be helpful to show how to build SCSS mixins for these components. Although the user didn't specifically ask for tooling, they might appreciate mentioning Storybook since it supports a component-driven design system.
As for the file structure, I plan to organize it with a clear hierarchy under /src/scss, which includes everything from tokens to specific component styles. Bootstrap 5 recommends the proper order for imports, so I'll keep that in mind.Discussing Bootstrap SCSS imports
In setting up the SCSS for Bootstrap, I want to show the typical imports, starting with functions, design tokens, and various Bootstrap SCSS elements like variables and mixins. It's important to note that while Bootstrap 5.3 recommends using @use for sass modules, many practitioners still use @import, which may make things simpler for them.
I should provide examples for both methods, but since the documentation still showcases @import, I'll stick with that for customizing compiled CSS while being mindful of the transition to @use.Structuring the design system
I want to guide users through creating a component-driven design system using Bootstrap and SCSS. While @import is widely used, I'll suggest using @use for a more modern approach, especially with Dart Sass, but for simplicity, I'll stick with @import.
Next, I'll define design tokens using SCSS maps for colors, typography, and spacing, ensuring alignment with Bootstrap's theme colors. For example, I might show how to map my colors to Bootstrap's variables.
I'll also highlight how to implement components following BEM methodology, demonstrating button variations and how to extend Bootstrap's styling with custom components like c-card. Finally, scaling and maintaining the system is crucial, so I'll recommend documenting tokens and components through tools like Storybook while providing installation instructions for Bootstrap and Sass. Below is a practical blueprint for a component‑driven design system built on Bootstrap 5 and SCSS. It covers structure, theming, tokens, and example components.
1. Setup
Install Bootstrap and Sass:
npm install bootstrap sass
Example build script in package.json:
{
"scripts": {
"build:css": "sass src/scss/main.scss dist/css/main.css --style=compressed --no-source-map",
"watch:css": "sass --watch src/scss/main.scss dist/css/main.css"
}
}
2. SCSS Architecture
Use a predictable, layered structure:
src/
scss/
abstracts/ // design system core
_functions.scss
_mixins.scss
_tokens.scss // design tokens
_maps.scss // maps built from tokens
bootstrap/ // bootstrap partials wiring
_bootstrap.scss
_bootstrap-custom.scss
components/ // atomic components
_buttons.scss
_cards.scss
_forms.scss
_navbar.scss
_badges.scss
...
patterns/ // composite/complex components
_hero.scss
_sidebar-layout.scss
utilities/ // project-specific utilities
_utilities-spacing.scss
_utilities-typography.scss
main.scss // entry point
main.scss
// 1. Abstracts (tokens, functions, mixins)
@import "abstracts/functions";
@import "abstracts/tokens";
@import "abstracts/maps";
@import "abstracts/mixins";
// 2. Bootstrap wired to tokens
@import "bootstrap/bootstrap";
// 3. Project components (built on top of Bootstrap)
@import "components/buttons";
@import "components/cards";
@import "components/forms";
@import "components/navbar";
@import "components/badges";
// 4. Patterns & layouts
@import "patterns/hero";
@import "patterns/sidebar-layout";
// 5. Project utilities (optional)
@import "utilities/utilities-spacing";
@import "utilities/utilities-typography";
3. Design Tokens
Define brand-agnostic tokens once, reuse everywhere.
abstracts/_tokens.scss
// Color tokens
$color-blue-500: #2563eb;
$color-blue-600: #1d4ed8;
$color-purple-500: #7c3aed;
$color-green-500: #22c55e;
$color-red-500: #ef4444;
$color-amber-500: #f59e0b;
$color-sky-500: #0ea5e9;
$color-gray-50: #f9fafb;
$color-gray-100: #f3f4f6;
$color-gray-200: #e5e7eb;
$color-gray-300: #d1d5db;
$color-gray-400: #9ca3af;
$color-gray-500: #6b7280;
$color-gray-700: #374151;
$color-gray-900: #111827;
$color-white: #ffffff;
$color-black: #000000;
// Semantic colors
$color-brand-primary: $color-blue-600;
$color-brand-secondary: $color-purple-500;
$color-success: $color-green-500;
$color-danger: $color-red-500;
$color-warning: $color-amber-500;
$color-info: $color-sky-500;
$color-body-bg: $color-white;
$color-body-text: $color-gray-900;
$color-muted-text: $color-gray-500;
// Spacing scale (rem)
$space-0: 0;
$space-1: 0.25rem;
$space-2: 0.5rem;
$space-3: 0.75rem;
$space-4: 1rem;
$space-5: 1.5rem;
$space-6: 2rem;
$space-7: 3rem;
// Typography tokens
$font-family-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
sans-serif;
$font-size-100: 0.75rem;
$font-size-200: 0.875rem;
$font-size-300: 1rem;
$font-size-400: 1.125rem;
$font-size-500: 1.5rem;
$font-size-600: 2rem;
$line-height-tight: 1.2;
$line-height-normal: 1.5;
// Radii
$radius-sm: 0.25rem;
$radius-md: 0.5rem;
$radius-lg: 1rem;
$radius-pill: 999px;
// Shadows
$shadow-sm: 0 1px 2px rgba($color-black, 0.05);
$shadow-md: 0 4px 10px rgba($color-black, 0.08);
$shadow-lg: 0 10px 25px rgba($color-black, 0.12);
abstracts/_maps.scss (optional but powerful)
$ds-theme-colors: (
"primary": $color-brand-primary,
"secondary": $color-brand-secondary,
"success": $color-success,
"danger": $color-danger,
"warning": $color-warning,
"info": $color-info,
"light": $color-gray-100,
"dark": $color-gray-900,
);
$ds-spacing-scale: (
0: $space-0,
1: $space-1,
2: $space-2,
3: $space-3,
4: $space-4,
5: $space-5,
6: $space-6,
7: $space-7,
);
4. Wiring Bootstrap 5 to Your Tokens
Customize Bootstrap before importing its components.
bootstrap/_bootstrap.scss
// 1. Bootstrap core imports in correct order
@import "~bootstrap/scss/functions";
// 2. Override Bootstrap variables using our tokens BEFORE variables/maps/mixins
// Map our tokens into Bootstrap "source of truth"
$primary: $color-brand-primary;
$secondary: $color-brand-secondary;
$success: $color-success;
$danger: $color-danger;
$warning: $color-warning;
$info: $color-info;
$light: $color-gray-100;
$dark: $color-gray-900;
$body-bg: $color-body-bg;
$body-color: $color-body-text;
$font-family-sans-serif: $font-family-sans;
$font-size-base: $font-size-300;
$line-height-base: $line-height-normal;
// Radius
$border-radius-sm: $radius-sm;
$border-radius: $radius-md;
$border-radius-lg: $radius-lg;
$border-radius-pill: $radius-pill;
// Spacing scale (Bootstrap’s $spacers map)
$spacer: 1rem;
$spacers: (
0: $space-0,
1: $space-1,
2: $space-2,
3: $space-3,
4: $space-4,
5: $space-5,
6: $space-6,
7: $space-7
);
// Shadows
$box-shadow-sm: $shadow-sm;
$box-shadow: $shadow-md;
$box-shadow-lg: $shadow-lg;
// Compose theme colors
$theme-colors: $ds-theme-colors;
// 3. Rest of Bootstrap
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/maps";
@import "~bootstrap/scss/mixins";
@import "~bootstrap/scss/utilities";
@import "~bootstrap/scss/root";
@import "~bootstrap/scss/reboot";
@import "~bootstrap/scss/type";
@import "~bootstrap/scss/images";
@import "~bootstrap/scss/containers";
@import "~bootstrap/scss/grid";
@import "~bootstrap/scss/helpers";
// Core components
@import "~bootstrap/scss/buttons";
@import "~bootstrap/scss/forms";
@import "~bootstrap/scss/nav";
@import "~bootstrap/scss/navbar";
@import "~bootstrap/scss/dropdown";
@import "~bootstrap/scss/card";
@import "~bootstrap/scss/alert";
@import "~bootstrap/scss/modal";
// ... add what you need
// Utilities (final)
@import "~bootstrap/scss/utilities/api";
Now Bootstrap’s built-in .btn-primary, .alert-danger, .card, etc. all follow your tokens.
5. Component-Driven Layer (on top of Bootstrap)
Adopt consistent naming, e.g. c- prefix for design-system components:
- Base components often wrap/compose Bootstrap classes.
- Each component has its own SCSS partial and HTML spec.
5.1 Buttons
components/_buttons.scss
// High-level button design system built on Bootstrap .btn
.c-btn {
@extend .btn;
font-weight: 500;
border-radius: $radius-md;
padding: $space-2 $space-4;
display: inline-flex;
align-items: center;
gap: $space-2;
transition: background-color 0.15s ease, color 0.15s ease,
box-shadow 0.15s ease, transform 0.1s ease;
&:active {
transform: translateY(1px);
box-shadow: none;
}
}
// Variants using Bootstrap mixins
.c-btn--primary {
@include button-variant(
$background: $primary,
$border: $primary,
$color: $color-white,
$hover-background: shade-color($primary, 7.5%),
$hover-border: shade-color($primary, 7.5%),
$active-background: shade-color($primary, 12.5%),
$active-border: shade-color($primary, 12.5%),
$disabled-background: $primary,
$disabled-border: $primary
);
}
.c-btn--secondary {
@include button-variant(
$background: $secondary,
$border: $secondary,
$color: $color-white,
$hover-background: shade-color($secondary, 7.5%),
$hover-border: shade-color($secondary, 7.5%),
$active-background: shade-color($secondary, 12.5%),
$active-border: shade-color($secondary, 12.5%),
$disabled-background: $secondary,
$disabled-border: $secondary
);
}
// Outline / ghost variants
.c-btn--ghost {
@include button-variant(
$background: transparent,
$border: transparent,
$color: $body-color,
$hover-background: $color-gray-100,
$hover-border: transparent,
$active-background: $color-gray-200,
$active-border: transparent
);
}
// Sizes
.c-btn--sm {
@extend .btn-sm;
padding: $space-1 $space-3;
font-size: $font-size-200;
}
.c-btn--lg {
@extend .btn-lg;
padding: $space-3 $space-5;
font-size: $font-size-400;
}
Usage:
<button class="c-btn c-btn--primary c-btn--lg">Primary</button>
<button class="c-btn c-btn--ghost c-btn--sm">Ghost</button>
5.2 Cards
components/_cards.scss
.c-card {
@extend .card;
border-radius: $radius-lg;
border: 1px solid $color-gray-200;
box-shadow: $shadow-sm;
}
.c-card__header {
@extend .card-header;
padding: $space-3 $space-4;
border-bottom-color: $color-gray-200;
background-color: $color-gray-50;
font-weight: 500;
}
.c-card__body {
@extend .card-body;
padding: $space-4;
}
.c-card__footer {
@extend .card-footer;
padding: $space-3 $space-4;
background-color: $color-white;
border-top-color: $color-gray-200;
}
// Variant example
.c-card--highlight {
border-color: rgba($primary, 0.25);
box-shadow: $shadow-md;
}
Usage:
<article class="c-card c-card--highlight">
<header class="c-card__header">Card title</header>
<div class="c-card__body">
<p>Card content using system typography & spacing.</p>
</div>
<footer class="c-card__footer">
<button class="c-btn c-btn--primary c-btn--sm">Action</button>
</footer>
</article>
5.3 Forms
components/_forms.scss
.c-form-label {
@extend .form-label;
font-weight: 500;
margin-bottom: $space-1;
}
.c-form-control {
@extend .form-control;
border-radius: $radius-md;
padding: $space-2 $space-3;
border-color: $color-gray-300;
font-size: $font-size-300;
&::placeholder {
color: $color-muted-text;
}
&:focus {
border-color: $primary;
box-shadow: 0 0 0 0.2rem rgba($primary, 0.15);
}
&--invalid {
@extend .is-invalid;
}
}
.c-form-help {
font-size: $font-size-200;
color: $color-muted-text;
margin-top: $space-1;
}
Usage:
<div class="mb-3">
<label class="c-form-label" for="email">Email</label>
<input id="email" class="c-form-control" type="email" placeholder="you@example.com">
<p class="c-form-help">We’ll never share your email.</p>
</div>
5.4 Navbar
components/_navbar.scss
.c-navbar {
@extend .navbar;
@extend .navbar-expand-lg;
@extend .navbar-light;
background-color: $color-white;
border-bottom: 1px solid $color-gray-200;
padding-block: $space-2;
}
.c-navbar__brand {
@extend .navbar-brand;
font-weight: 600;
font-size: $font-size-400;
color: $primary;
&:hover {
color: shade-color($primary, 10%);
}
}
.c-navbar__nav {
@extend .navbar-nav;
gap: $space-2;
}
.c-navbar__link {
@extend .nav-link;
font-weight: 500;
&.is-active,
&.active {
color: $primary;
}
}
Usage:
<nav class="c-navbar">
<div class="container-fluid">
<a class="c-navbar__brand" href="#">Brand</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav">
<span class="navbar-toggler-icon"></span>
</button>
<div id="mainNav" class="collapse navbar-collapse">
<ul class="c-navbar__nav ms-auto">
<li class="nav-item">
<a class="c-navbar__link active" href="#">Home</a>
</li>
<li class="nav-item">
<a class="c-navbar__link" href="#">Docs</a>
</li>
</ul>
</div>
</div>
</nav>
6. Utilities Layer (Optional but Useful)
Create project-specific utilities from your token maps.
utilities/_utilities-spacing.scss
// Example: margin-bottom utilities based on design tokens: .u-mb-1, .u-mb-2, ...
@each $key, $value in $ds-spacing-scale {
.u-mb-#{$key} {
margin-bottom: $value !important;
}
}
utilities/_utilities-typography.scss
.u-text-muted {
color: $color-muted-text !important;
}
.u-text-xs {
font-size: $font-size-100;
line-height: $line-height-normal;
}
.u-text-sm {
font-size: $font-size-200;
line-height: $line-height-normal;
}
7. Dark Mode / Theming (Optional Next Step)
With Bootstrap 5.3+ and CSS variables:
- Keep your SCSS tokens as the default theme.
- Override a subset with
.theme-dark or [data-theme="dark"].
Example:
:root {
--ds-body-bg: #ffffff;
--ds-body-color: #111827;
}
[data-theme="dark"] {
--ds-body-bg: #020617;
--ds-body-color: #e5e7eb;
}
body {
background-color: var(--ds-body-bg);
color: var(--ds-body-color);
}
You can then gradually refactor SCSS to read from CSS variables instead of hard-coded token values where runtime theming is required.
8. Documentation & Component-Driven Workflow
To make this a true design system:
-
Document every component
- Name, purpose, states, anatomy, accessibility notes.
- Showcase variants (primary/secondary/ghost, sizes, disabled).
-
Use a component explorer
- Storybook, Pattern Lab, or even a simple static “kitchen sink” page listing all
.c-* components.
-
Governance
- New UI is built only from existing components; if you need something new, you add a component or pattern, not ad-hoc CSS.
If you share your brand palette or specific component list (e.g. “table, toast, side navigation”), I can extend this with concrete SCSS and markup tailored to your needs.