Skip to content

v5.2.0: Bootstrap 4 compatibility SCSS; Bootstrap.defaultLoadCss - #15

Merged
gmpassos merged 1 commit into
masterfrom
feat/bs4-compat-scss
Oct 8, 2026
Merged

gmpassos merged 1 commit into
masterfrom
feat/bs4-compat-scss

Conversation

@gmpassos

@gmpassos gmpassos commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

For apps moving from 4.x (Bootstrap 4): a SCSS that normalizes Bootstrap 5 to look like Bootstrap 4, so the fixes each app would otherwise make are shared.

$primary: #a2a2a2; // app theme, before the import
@import "package:bones_ui_bootstrap/bootstrap-5/bs4-compat/bootstrap";

lib/bootstrap-5/bs4-compat

  • bootstrap.scss: _variables + the bundled Bootstrap 5 SCSS + _rules.
  • _variables.scss (all !default, app variables win): Bootstrap 4 values for the variables whose defaults changed: border radius, no responsive font sizes, links without underline, <small>/<code>, <hr>, .badge, .btn-warning text ($color-contrast-dark), .card, .form-control, .table, .navbar (padding, colors, no toggler ring after a tap), and the accordion.
  • _rules.scss: Bootstrap 4 styles without a Bootstrap 5 variable: checkboxes/radios without padding (dropped from the reboot), date inputs height, lists indent, inherited .badge/.card colors, .form-control appearance, .table borders (keeping .table-bordered/.table-borderless), .navbar-brand, and BSAccordion with the 4.x look: each item a .card (relative flex column, own borders/radius), header a .card-header (inherited font), button a .btn-link (centered, parts spread, no chevron, hover/focus underline), body a .card-body.
  • _class-aliases.scss (optional): Bootstrap 4 class names extending their Bootstrap 5 classes (float-right, text-left, ml-2/mr-md-auto/..., font-weight-bold, font-italic, sr-only, badge-pill, badge-primary, no-gutters, custom-select, form-group, btn-block, ...).

These come from migrating a production app from 4.x, each checked by comparing computed styles (old Bootstrap 4 CSS vs Bootstrap 5 + these files) in headless Chrome.

Bootstrap.defaultLoadCss

load({bool? loadCss}) now defaults to Bootstrap.defaultLoadCss. Only the first load call loads, and the package itself calls load() (e.g. enableTooltip), so an app compiling its own Bootstrap CSS sets Bootstrap.defaultLoadCss = false at start instead of relying on its load(loadCss: false) being first.

Tests

  • bones_ui_bootstrap_bs4_compat_vm_test.dart: compiles through the package: URL; variables, rules after the Bootstrap rules they override, .table-bordered/.table-borderless, accordion, app variable override, variables-only import outputs nothing, class aliases.
  • bones_ui_bootstrap_default_no_css_test.dart: defaultLoadCss = false with enableTooltip making the first load.
  • dart test -p vm: 28 passed. dart test -p chrome: 65 passed. dart analyze, dependency_validator: clean.

🤖 Generated with Claude Code

- lib/bootstrap-5/bs4-compat: Bootstrap 5 normalized to look like
  Bootstrap 4, for apps moving from 4.x:
  - _variables.scss: Bootstrap 4 values for the variables whose defaults
    changed (all !default).
  - _rules.scss: Bootstrap 4 styles without a Bootstrap 5 variable
    (checkbox/radio padding, date inputs, lists indent, .badge/.card
    color, .form-control, .table borders keeping .table-bordered and
    .table-borderless, .navbar-brand) and BSAccordion with the 4.x look.
  - _class-aliases.scss (optional): Bootstrap 4 class names.
  - bootstrap.scss: variables + Bootstrap 5 + rules.
- Bootstrap.defaultLoadCss: the load() loadCss when not passed, also for
  the package's own load() calls (e.g. enableTooltip).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gmpassos
gmpassos merged commit 4140dc5 into master Oct 8, 2026
1 check passed
@gmpassos
gmpassos deleted the feat/bs4-compat-scss branch October 8, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant