Making a Sass mixin with optional arguments

前端 未结 13 1351
眼角桃花
眼角桃花 2020-12-22 16:31

I am writing a mixin like this:

@mixin box-shadow($top, $left, $blur, $color, $inset:\"\") {
    -webkit-box-shadow:          


        
13条回答
  •  遥遥无期
    2020-12-22 17:17

    Super simple way

    Just add a default value of none to $inset - so

    @mixin box-shadow($top, $left, $blur, $color, $inset: none) { ....
    

    Now when no $inset is passed nothing will be displayed.

提交回复
热议问题