sass:string
Compatibility:
- Dart Sass
- since 1.23.0
- LibSass
- ✗
- Ruby Sass
- ✗
Only Dart Sass currently supports loading built-in modules with @use
. Users of other implementations must call functions using their global names instead.
string.quote($string)
quote($string)
Returns $string
as a quoted string.
@debug string.quote(Helvetica);
@debug string.quote("Helvetica");
@debug string.quote(Helvetica)
@debug string.quote("Helvetica")
string.index($string, $substring)
str-index($string, $substring)
Returns the first index of $substring
in $string
, or null
if $string
doesn’t contain $substring
.
@debug string.index("Helvetica Neue", "Helvetica");
@debug string.index("Helvetica Neue", "Neue");
@debug string.index("Helvetica Neue", "Helvetica")
@debug string.index("Helvetica Neue", "Neue")
string.insert($string, $insert, $index)
str-insert($string, $insert, $index)
Returns a copy of $string
with $insert
inserted at $index
.
@debug string.insert("Roboto Bold", " Mono", 7);
@debug string.insert("Roboto Bold", " Mono", -6);
@debug string.insert("Roboto Bold", " Mono", 7)
@debug string.insert("Roboto Bold", " Mono", -6)
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.
@debug string.insert("Roboto", " Bold", 100);
@debug string.insert("Bold", "Roboto ", -100);
@debug string.insert("Roboto", " Bold", 100)
@debug string.insert("Bold", "Roboto ", -100)
string.length($string)
str-length($string)
Returns the number of characters in $string
.
@debug string.length("Helvetica Neue");
@debug string.length(bold);
@debug string.length("");
@debug string.length("Helvetica Neue")
@debug string.length(bold)
@debug string.length("")
string.slice($string, $start-at, $end-at: -1)
str-slice($string, $start-at, $end-at: -1)
Returns the slice of $string
starting at index $start-at
and ending at index $end-at
(both inclusive).
@debug string.slice("Helvetica Neue", 11);
@debug string.slice("Helvetica Neue", 1, 3);
@debug string.slice("Helvetica Neue", 1, -6);
@debug string.slice("Helvetica Neue", 11)
@debug string.slice("Helvetica Neue", 1, 3)
@debug string.slice("Helvetica Neue", 1, -6)
string.to-upper-case($string)
to-upper-case($string)
Returns a copy of $string
with the ASCII letters converted to upper case.
@debug string.to-upper-case("Bold");
@debug string.to-upper-case(sans-serif);
@debug string.to-upper-case("Bold")
@debug string.to-upper-case(sans-serif)
string.to-lower-case($string)
to-lower-case($string)
Returns a copy of $string
with the ASCII letters converted to lower case.
@debug string.to-lower-case("Bold");
@debug string.to-lower-case(SANS-SERIF);
@debug string.to-lower-case("Bold")
@debug string.to-lower-case(SANS-SERIF)
string.unique-id()
unique-id()
Returns a randomly-generated unquoted string that’s guaranteed to be a valid CSS identifier and to be unique within the current Sass compilation.
@debug string.unique-id();
@debug string.unique-id();
@debug string.unique-id();
@debug string.unique-id();
string.unquote($string)
unquote($string)
Returns $string
as an unquoted string. This can produce strings that aren’t valid CSS, so use with caution.
@debug string.unquote("Helvetica");
@debug string.unquote(".widget:hover");
@debug string.unquote("Helvetica")
@debug string.unquote(".widget:hover")