Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !36242

Add new `.text-bg-{color}` helpers

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Mark Otto requested to merge text-bg-helpers into main Apr 28, 2022
  • Overview 2
  • Commits 5
  • Pipelines 0
  • Changes 10
Screen Shot 2022-04-28 at 4 21 17 PM

These new helpers aim to replace the instances where you must declare a contrasting color and background-color on the same element. Currently we defer to the developer/designer to decide how to handle this via separate utilities, which is kind of a shitty experience. Since we cannot use the completely unsupported native color contrast CSS function (you can opt into it in Safari dev tools though), we rely on our own custom color-contrast() function. As such, the contrast action doesn't happen live in browser, but at compilation time via Sass.

These new helpers are great for common component use cases like badges and cards, as shown below.

Screen Shot 2022-04-28 at 4 21 43 PM

These utilities also ship with a local CSS variable for --bs-bg-opacity, so you can also do fun stuff like:

<span class="badge text-bg-info bg-opacity-25">Light info</span>

Note that these are helpers because utilities, at least in our definition, are singular property and value pairings. Helpers are small snippets of code.


Todos:

  • Bundlewatch
  • Update badges and cards pages to use new helpers
  • Update migration guide
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: text-bg-helpers