Skip to content

how to simply have a dark variable for --box-shadow #40589

Closed Answered by julien-deramond
jipexu asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jipexu,

I'll try to bring some first answers, but they are partial and could help or not depending on your use cases.

The first thing that is customizable from outside is the CSS variables linked to the box shadows, you could for instance do something like that to have red shadows in light mode and green in dark mode:

:root {
  --bs-box-shadow: 0 .5rem 1rem rgba(255, 0, 0, .15);
  --bs-box-shadow-sm: 0 .125rem .25rem rgba(255, 0, 0, .075);
  --bs-box-shadow-lg: 0 1rem 3rem rgba(255, 0, 0, .175);
  --bs-box-shadow-inset: inset 0 1px 2px rgba(255, 0, 0, .075);
}

[data-bs-theme="dark"] {
  --bs-box-shadow: 0 .5rem 1rem rgba(0, 255, 0, .15);
  --bs-box-shadow-sm: 0 .125rem .25rem rgba(0, 2…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by jipexu
Comment options

You must be logged in to vote
1 reply
@julien-deramond
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants