Sass selector-replace() Function

Last Updated:

Sass selector-replace() Function

The selector-replace() function returns a copy of $selector with all instances of $original replaced by $replacement. If $selector doesn’t contain $original, returns it as-is.

Note: The $selector, $original, and $replacement selectors may contain placeholder selectors, but not parent selectors.

Example

SASS TO CSS CONVERTER
#{selector-replace("a.disabled", "a", ".link")} { color: black; } #{selector-replace("a.disabled", "h1", "h2")} { color: black; }

Syntax

selector-replace($selector, $original, $replacement)

Parameter Value

ValueTypeExplanation
$selector Required Specifies the css selector
$original Required Specifies the original css subselector
$replacement Required Specifies the replacement css subselector

Return Value

ValueExplanation
selector Returns a copy of $selector with all instances of $original replaced by $replacement.

Share this Page

Meet the Author