AI Skill Report Card
Building Bootstrap Components
YAML--- name: building-bootstrap-components description: Creates custom Bootstrap components with modular CSS and JavaScript following best practices. Use when building reusable UI components, custom themes, or extending Bootstrap functionality. ---
Building Bootstrap Components
Quick Start15 / 15
HTML<!-- Custom Card Component --> <div class="custom-card" data-card="interactive"> <div class="custom-card__header"> <h3 class="custom-card__title">Component Title</h3> </div> <div class="custom-card__body"> <p class="custom-card__text">Content goes here</p> </div> </div>
SCSS// _custom-card.scss .custom-card { @extend .card; border-radius: $border-radius-lg; transition: transform 0.2s ease-in-out; &:hover { transform: translateY(-2px); } &__header { @extend .card-header; background: linear-gradient(135deg, $primary, $secondary); } &__title { @extend .card-title; color: white; margin: 0; } &__body { @extend .card-body; } }
JavaScript// custom-card.js class CustomCard { constructor(element) { this.element = element; this.init(); } init() { this.element.addEventListener('click', this.handleClick.bind(this)); } handleClick() { this.element.classList.toggle('custom-card--active'); } } // Auto-initialize document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('[data-card="interactive"]') .forEach(card => new CustomCard(card)); });
Recommendation▾
Condense the workflow section - the 6-step checklist followed by 3 detailed steps is redundant. Pick one approach.
Workflow13 / 15
Progress:
- Define component requirements and Bootstrap base classes
- Create SCSS file with BEM naming convention
- Extend Bootstrap utilities where possible
- Write modular JavaScript with data attributes
- Test responsiveness across breakpoints
- Document usage and customization options
Step 1: Component Structure
Use BEM methodology with Bootstrap extensions:
SCSS.component-name { @extend .bootstrap-base-class; &__element { // Element styles } &--modifier { // Modifier styles } }
Step 2: Bootstrap Integration
Leverage Bootstrap's utilities and variables:
SCSS@import 'bootstrap/scss/functions'; @import 'bootstrap/scss/variables'; @import 'bootstrap/scss/mixins'; .custom-component { padding: $spacer-2; color: $text-color; @include border-radius($border-radius); }
Step 3: JavaScript Module Pattern
JavaScriptconst ComponentName = (() => { const init = (selector = '[data-component]') => { document.querySelectorAll(selector).forEach(initComponent); }; const initComponent = (element) => { // Component logic }; return { init }; })();
Recommendation▾
Reduce the Best Practices section length - it contains useful info but is verbose for Claude's skill level.
Examples18 / 20
Example 1: Custom Button Component Input: Need a gradient button with loading state Output:
SCSS.btn-custom { @extend .btn, .btn-primary; background: linear-gradient(45deg, $primary, $info); border: none; &--loading { pointer-events: none; &::after { content: ''; @extend .spinner-border, .spinner-border-sm; margin-left: $spacer-1; } } }
Example 2: Responsive Card Grid Input: Bootstrap card grid that stacks on mobile Output:
SCSS.card-grid { @extend .row; &__item { @extend .col-12, .col-md-6, .col-lg-4; margin-bottom: $spacer-3; .card { height: 100%; transition: all 0.3s ease; } } }
Recommendation▾
Add more concrete input/output examples showing different component types (modals, navbars, forms) to demonstrate versatility.
Best Practices
SCSS Organization:
- One component per file:
_component-name.scss - Import Bootstrap variables before custom styles
- Use
@extendfor Bootstrap classes, custom properties for modifications - Maintain consistent naming:
.component-name__element--modifier
JavaScript Patterns:
- Use data attributes for component initialization:
[data-toggle="custom"] - Implement event delegation for dynamic content
- Expose public methods for external interaction
- Handle cleanup for single-page applications
Responsiveness:
- Mobile-first approach with Bootstrap's breakpoint mixins
- Test all components across Bootstrap's grid breakpoints
- Use Bootstrap's display utilities:
.d-none .d-md-block
Performance:
- Minimize custom CSS by extending Bootstrap classes
- Use CSS custom properties for themeable values
- Lazy-load JavaScript for non-critical components
Common Pitfalls
CSS Issues:
- Don't override Bootstrap classes directly; extend or create new ones
- Avoid
!important; use specificity or CSS custom properties - Don't hardcode breakpoint values; use Bootstrap's mixins
JavaScript Problems:
- Don't rely on DOM ready for dynamic content; use event delegation
- Avoid global variables; use module pattern or ES6 modules
- Don't forget to remove event listeners when destroying components
Integration Mistakes:
- Don't import entire Bootstrap; only import needed components
- Don't mix utility classes with component classes in CSS
- Avoid deep nesting in SCSS (max 3 levels)
File Structure:
components/
├── _custom-card.scss
├── _custom-button.scss
└── custom-components.js
main.scss:
@import 'components/custom-card';
@import 'components/custom-button';