Customize Bootstrap 5.3 with CSS variables #39551
-
I'm starting a new project with Bootstrap 5.3 and I'm trying to do some basic customizations with CSS variables but I'm unsure what the best approach is... Basically I'm loading the CSS from a CDN, and as a first step I'd like to customize the primary color that is used everywhere.
This has no effect, though, the button is still displayed in the default primary blue. What is the correct way to override the primary color with CSS variables? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Ok I found this article that says I need to change Is that correct? Do I need to go back to using Sass, so I can set |
Beta Was this translation helpful? Give feedback.
-
Hey @manuelmeurer So right now, tweaking the However, as explained in the article, depending on the needs, it's possible to override the rendering of the components one by one by overriding their CSS variables. Some improvements will be made when Bootstrap is refactored in v6 for an easier theming approach. The groundwork with CSS variables and color modes in v5.2/3 was the opening act, and we committed to keeping things smooth without any regressions. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation, @julien-deramond! I'll stick with Sass for now and look forward to v6! :) |
Beta Was this translation helpful? Give feedback.
Hey @manuelmeurer
So right now, tweaking the
--bs-primary
CSS variable to give all components a new color isn't possible. You can see--bs-primary
primarily as a read-only CSS variable reusable in your website to get the primary color. For a consistent global look and setting a new primary color, diving into Sass is the way to go.However, as explained in the article, depending on the needs, it's possible to override the rendering of the components one by one by overriding their CSS variables.
Some improvements will be made when Bootstrap is refactored in v6 for an easier theming approach. The groundwork with CSS variables and color modes in v5.2/3 was the opening act, and we committed to…