Sass str-insert() Function

Last Updated:

Sass str-insert() Function

The str-insert() function returns a copy of a string with a new letter(s) inserted at the specified index.

Example

SASS TO CSS CONVERTER
//Check your console @debug str-insert("sansserif", "-", 5); // "sans-serif" @debug str-insert("sansserif", "-", -6); // "sans-serif" @debug str-insert("sansserif", "-", 100); // "sansserif-" @debug str-insert("sansserif", "-", -100); // "-sansserif"

Syntax

str-insert($string, $insert, $index)

Parameter Value

ValueTypeExplanation
$string Required A string.
$insert Required A string to be inserted
$index Required A index number (a position to add 'insert string').

Return Value

ValueExplanation
string Returns a copy of $string with $insert inserted at $index.
  • If of $index is higher than the length of $string, $insert is added to the end.
  • If $index is smaller than the negative length of the string, $insert is added to the beginning.

Share this Page

Meet the Author