Use this sass script i made & improved by @Eric M Suzanne
DEMO
$insideBorderThickness: 2px !default;
$insideBorderColor: black !default;
$insideBorderAlpha: .05 !default;
@mixin insideBorder($values...) {
$borderThickness: $insideBorderThickness;
$borderColor: $insideBorderColor;
$borderAlpha: $insideBorderAlpha;
@each $value in $values {
@if type_of($value) == number {
@if unit($value) == "" {
$borderAlpha: $value;
} @else {
$borderThickness: $value;
}
} @else if type_of($value) == color {
$borderColor: $value;
}
}
box-shadow: inset 0 0 0 $borderThickness rgba($borderColor, $borderAlpha);
}
Then you can use @include like this:
@include insideBorder();
OR
@include insideBorder(20px);
OR
@include insideBorder(blue);
OR
@include insideBorder(.6);
OR
@include insideBorder(3em, orange, .5);
LOGIC:
First default values are defined for the box-shadow.
When insideBorder() mixin is used it will assign the default values to inner variables (to avoid default values getting changed on each call of the mixin).
Next it will check if the value type is "number" & assign it to alpha variable & if the type is number with any other measurement unit like em-px-rm, it will be assigned to thickness & if the type is color, it will be assigned to color variable.
finally it will create the box shadow css depending on the variable values.