Sass color.ie-hex-str() Function

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
Deprecated use case
Non-standard IE target
sass:color · Dart Sass

What You’ll Learn

color.ie-hex-str() belongs to the built-in sass:color module. It formats a color as an unquoted #AARRGGBB string for legacy Internet Explorer -ms-filter values—at compile time. This page covers the alpha-first layout, how opacity maps into AA, when (not) to use it, and five compiled examples.

01

Concept

#AARRGGBB string

02

Module

@use "sass:color"

03

Alpha

First two hex digits

04

Target

IE -ms-filter

05

Modern

Prefer CSS gradients

06

Practice

5 examples

What Is color.ie-hex-str()?

ie-hex-str means “turn this Sass color into the weird hex string old IE filters expected.” Official docs: it returns an unquoted string in #AARRGGBB form for Internet Explorer’s -ms-filter property.

  • color.ie-hex-str(#b37399)#FFB37399
  • color.ie-hex-str(rgba(242, 236, 228, 0.6))#99F2ECE4
  • color.ie-hex-str(#abc)#FFAABBCC
💡
Beginner tip

Normal CSS hex is often #RRGGBB (or #RRGGBBAA). IE filter strings put alpha first: #AARRGGBB. Opaque colors start with FF.

📝 Syntax

Load the color module, then pass one color:

styles.scss
@use "sass:color";

color.ie-hex-str($color)
// Global alias:
// ie-hex-str($color)

Parameters

ParameterTypeDescription
$colorColorAny Sass color to encode (required).

Return value

TypeMeaning
Unquoted stringA #AARRGGBB value suitable for IE filter color arguments—not a Sass color type.

📦 Loading sass:color

Prefer the module API. Official docs also document the global name ie-hex-str() for older stylesheets.

styles.scss
// Recommended — namespaced
@use "sass:color";
$ie: color.ie-hex-str(#b37399);

// Optional — bring members into the current namespace
@use "sass:color" as *;
$ie: ie-hex-str(#b37399);

// Optional — custom namespace
@use "sass:color" as c;
$ie: c.ie-hex-str(#b37399);

// Legacy global name
$ie: ie-hex-str(#b37399);
⚠️
Put @use first

Keep @use "sass:color"; near the top of the file. Built-in modules need Dart Sass (about 1.23+).

🎨 Reading #AARRGGBB

Break the string into four byte pairs. Alpha comes first—that is the whole point of this helper.

PartMeaningExample in #FFB37399
AAAlpha (opacity)FF = fully opaque
RRRedB3
GGGreen73
BBBlue99
OpacityTypical AAExample
1 (opaque)FF#FF336699
0.8CCcolor.ie-hex-str(rgba(51, 102, 153, 0.8))#CC336699
0.699#99F2ECE4 (official docs sample)
0.580color.ie-hex-str(rgba(0, 255, 0, 0.5))#8000FF00

🛠 RGB Conversion & Gamut Mapping

Official docs note: if $color is not already in the rgb space, Sass converts it to rgb and gamut-maps if necessary. The gamut-mapping algorithm may change in future Sass versions; docs currently mention local-minde.

styles.scss
@use "sass:color";

@debug color.ie-hex-str(#b37399); // #FFB37399
@debug color.ie-hex-str(rgba(242, 236, 228, 0.6)); // #99F2ECE4
// Modern color spaces also convert to rgb for the IE string (newer Dart Sass):
// @debug color.ie-hex-str(oklch(70% 10% 120deg)); // #FF9BA287

🎯 Modern CSS Instead

For new UI, skip IE filter strings. Use standard CSS that every current browser understands.

styles.scss
// Modern — no ie-hex-str needed
.hero {
  background: linear-gradient(#336699, #4caf50);
}

// Legacy IE-only pattern (maintenance only)
// filter: progid:DXImageTransform.Microsoft.gradient(...);

🛠 Compatibility

This is about Sass compilers, not modern browser color APIs. The string is meant for obsolete IE filter CSS, not for today’s color properties.

FeatureDart SassNotes
@use "sass:color" / color.ie-hex-str1.23+Preferred module API
Global ie-hex-str()Long-standingPrefer module form in new SCSS
Non-RGB inputsConverts to rgbMay gamut-map; algorithm can evolve
LibSass / Ruby SassNo modern module APIMay expose global ie-hex-str(); prefer Dart Sass

⚡ Quick Reference

GoalCode
Import color@use "sass:color";
Opaque hex → IE stringcolor.ie-hex-str(#b37399)
Transparent colorcolor.ie-hex-str(rgba(242, 236, 228, 0.6))
Shorthand hexcolor.ie-hex-str(#abc)#FFAABBCC
Legacy globalie-hex-str(#b37399)
Modern gradient (preferred)background: linear-gradient(...);

Examples Gallery

Each example uses @use "sass:color". These patterns are for legacy IE maintenance only. Open View Compiled CSS to see the #AARRGGBB strings.

📚 Getting Started

Official-style opaque and transparent encodings.

Example 1 — Official Opaque Hex

Encode a solid color as #AARRGGBB (official docs sample).

styles.scss
@use "sass:color";

@debug color.ie-hex-str(#b37399); // #FFB37399

.legacy {
  /* Not a modern CSS color property — string for IE filter tooling */
  --ie-start: #{color.ie-hex-str(#b37399)};
}

How It Works

Opaque colors get alpha FF, then the RGB bytes. The return value is a string, so interpolation with #{} is common when embedding it.

Example 2 — Transparent Colors

Alpha becomes the leading byte pair (official 0.6 sample plus more).

styles.scss
@use "sass:color";

@debug color.ie-hex-str(rgba(242, 236, 228, 0.6)); // #99F2ECE4

.alpha-samples {
  --sixty: #{color.ie-hex-str(rgba(242, 236, 228, 0.6))};
  --half-green: #{color.ie-hex-str(rgba(0, 255, 0, 0.5))};
  --eighty-blue: #{color.ie-hex-str(rgba(51, 102, 153, 0.8))};
}

How It Works

0.6 maps to 99, 0.5 to 80, and 0.8 to CC. RGB channels follow after alpha.

📈 Practical Patterns

IE gradient filters, tokens, and the global alias.

Example 3 — Legacy IE Gradient Filter

The historical reason this helper exists—maintenance only.

styles.scss
@use "sass:color";

$start: #336699;
$end: #4caf50;

.hero-legacy {
  /* Obsolete IE filter — prefer linear-gradient() in modern CSS */
  filter: progid:DXImageTransform.Microsoft.gradient(
    startColorstr='#{color.ie-hex-str($start)}',
    endColorstr='#{color.ie-hex-str($end)}',
    GradientType=0
  );
}

How It Works

Sass inserts #FF336699 and #FF4CAF50 into the proprietary filter string. Modern stylesheets should use linear-gradient($start, $end) instead.

Example 4 — Brand Tokens to IE Strings

Keep brand hexes once; derive IE filter strings when a legacy sheet still needs them.

styles.scss
@use "sass:color";

$brand: #336699;
$brand-soft: rgba(51, 102, 153, 0.8);

.ie-tokens {
  --brand-ie: #{color.ie-hex-str($brand)};
  --brand-soft-ie: #{color.ie-hex-str($brand-soft)};
  --short-ie: #{color.ie-hex-str(#abc)};
}

How It Works

Shorthand #abc expands to full RGB bytes with opaque alpha. Soft brand colors keep the same RGB with a reduced alpha byte.

Example 5 — Module vs Global ie-hex-str()

Both names return the same unquoted IE string.

styles.scss
@use "sass:color";

.names {
  --module: #{color.ie-hex-str(#6b717f)};
  --global: #{ie-hex-str(#6b717f)};
}

How It Works

Module and global calls match. Prefer color.ie-hex-str() so readers see the helper comes from sass:color.

🚀 Real-World Use Cases

  • Legacy IE gradientsprogid:DXImageTransform.Microsoft.gradient color stops.
  • Old -ms-filter sheets — maintain color args without hand-writing #AARRGGBB.
  • Migration audits — find IE filter strings while replacing them with modern CSS.
  • Brand token bridges — keep one Sass color, emit IE strings only where still required.
  • Teaching alpha-first hex — show why IE strings look “backwards” vs #RRGGBBAA.
💡
Not a use case

Do not use ie-hex-str for normal color, background, borders, or CSS variables meant for modern browsers.

🧠 How Compilation Works

1

Write SCSS

Call color.ie-hex-str($color) after @use.

Source
2

Convert to rgb

Non-RGB colors convert (and may gamut-map).

RGB
3

Build #AARRGGBB

Alpha byte first, then R, G, and B.

Encode
4

Unquoted string ships

CSS gets a string—not a modern color function call.

⚠️ Common Pitfalls

  • Using it as a normal color#AARRGGBB is for IE filters, not modern color: values.
  • Confusing with #RRGGBBAA — alpha is first here, not last.
  • Building new features on -ms-filter — that API is obsolete; use standard CSS.
  • Forgetting it returns a string — you often need #{} interpolation inside larger declarations.
  • Expecting browsers to “understand” IE strings — modern engines ignore proprietary filter progids.

💡 Best Practices

✅ Do

  • Use color.ie-hex-str() only in legacy IE maintenance
  • Keep brand colors as normal Sass colors; derive IE strings when required
  • Migrate filters to linear-gradient() and standard CSS
  • Prefer @use "sass:color" on Dart Sass
  • Document why any remaining -ms-filter block still exists

❌ Don’t

  • Introduce ie-hex-str into new design systems
  • Paste IE strings into modern color properties
  • Assume #FFRRGGBB equals CSS #RRGGBBFF
  • Rely on LibSass for the module API
  • Teach this as the default way to “export hex from Sass”

Key Takeaways

Knowledge Unlocked

Five things to remember about color.ie-hex-str()

Alpha-first IE strings—legacy only, not modern CSS colors.

5
Core concepts
📦 02

Returns

unquoted string

String
🎨 03

Format

#AARRGGBB

Alpha first
04

For

IE -ms-filter

Legacy
05

Prefer

modern CSS

Today

❓ Frequently Asked Questions

color.ie-hex-str($color) returns an unquoted #AARRGGBB string for Internet Explorer’s -ms-filter property. Example: color.ie-hex-str(#b37399) is #FFB37399.
IE’s filter format is #AARRGGBB, not the more common #RRGGBBAA. Opaque colors start with FF; rgba(242, 236, 228, 0.6) becomes #99F2ECE4.
No. It exists for legacy IE -ms-filter strings. Modern CSS should use standard gradients, colors, and filters instead.
Add @use "sass:color"; then call color.ie-hex-str($brand). Prefer the module form. The global alias is ie-hex-str().
Yes. Official docs say if $color is not already in rgb, Sass converts it to rgb and gamut-maps if needed before building the IE string.
The module form needs Dart Sass with @use (about 1.23+). LibSass/Ruby Sass may expose a global ie-hex-str() but lack the modern module API.
Did you know?

Official Sass docs still document color.ie-hex-str() because old codebases needed #AARRGGBB for IE filters—and they note that non-RGB colors are converted to rgb with possible gamut mapping. That conversion exists so the IE string can always be built, not because modern CSS needs this format.

Conclusion

color.ie-hex-str() encodes a color as an unquoted #AARRGGBB string for legacy Internet Explorer filters. Learn it so you can read old SCSS—then prefer modern CSS gradients and colors for anything new.

Continue with color.invert(), color.grayscale(), or the CSS introduction.

Explore color.invert() Next

Create compile-time color negatives with the sass:color module.

Sass color.invert() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful