Creates an RGB color.
If space is missing, only undefined should be used to indicate that alpha isn't passed. If null is used instead, it will be treated as a missing component. See breaking changes for details.
If space is defined and null is passed for any component, it will be treated as a missing component.
Error if alpha is set and isn't null or a number between 0 and 1.
Optional alpha?: null | number
Optional space?: "rgb"
Creates an HSL color.
If space is missing, only undefined should be used to indicate that alpha isn't passed. If null is used instead, it will be treated as a missing component. See breaking changes for details.
If space is defined and null is passed for any component, it will be treated as a missing component.
Error if alpha is set and isn't null or a number between 0 and 1.
Optional alpha?: null | number
Optional space?: "hsl"
Creates an HWB color.
If space is missing, only undefined should be used to indicate that alpha isn't passed. If null is used instead, it will be treated as a missing component. See breaking changes for details.
If space is defined and null is passed for any component, it will be treated as a missing component.
Error if alpha is set and isn't null or a number between 0 and 1.
Optional alpha?: null | number
Optional space?: "hwb"
If null is passed for any component, it will be treated as a missing component.
Error if alpha is set and isn't null or a number between 0 and 1.
Optional alpha?: null | number
Creates an LCH or Oklch color.
If null is passed for any component, it will be treated as a missing component.
Error if alpha is set and isn't null or a number between 0 and 1.
Optional alpha?: null | number
Creates a color in a predefined RGB color space.
If null is passed for any component, it will be treated as a missing component.
Error if alpha is set and isn't null or a number between 0 and 1.
Optional alpha?: null | number
Creates a color in a predefined XYZ color space.
If null is passed for any component, it will be treated as a missing component.
Error if alpha is set and isn't null or a number between 0 and 1.
Optional alpha?: null | number
This color's alpha channel, between 0 and 1.
This value as a list.
All SassScript values can be used as lists. Maps count as lists of pairs, and all other values count as single-value lists.
An immutable List from the immutable package.
A list of this color's channel values (excluding alpha), with missing channels converted to 0.
A list of this color's channel values (excluding alpha), with missing channels converted to null.
Whether this value as a list has brackets.
All SassScript values can be used as lists. Maps count as lists of pairs, and all other values count as single-value lists.
A boolean indicating whether this color is in a legacy color space (rgb, hsl, or hwb).
Whether the value counts as true in an @if statement and other contexts.
The separator for this value as a list.
All SassScript values can be used as lists. Maps count as lists of pairs, and all other values count as single-value lists.
The name of this color's space.
Throws if this isn't a SassBoolean.
Functions should generally use isTruthy rather than requiring a literal boolean.
Optional name: string
The name of the function argument this came from (without the $) if it came from an argument. Used for error reporting.
Throws if this isn't a SassCalculation.
Optional name: string
The name of the function argument this came from (without the $) if it came from an argument. Used for error reporting.
Throws if this isn't a SassFunction.
Optional name: string
The name of the function argument this came from (without the $) if it came from an argument. Used for error reporting.
Throws if this isn't a SassNumber.
Optional name: string
The name of the function argument this came from (without the $) if it came from an argument. Used for error reporting.
Throws if this isn't a SassString.
Optional name: string
The name of the function argument this came from (without the $) if it came from an argument. Used for error reporting.
Returns a new color that's the result of changing one or more of this color's HSL channels.
Error if space is missing and this color is not in a legacy color space (rgb, hsl, or hwb).
Error if alpha is set and isn't null or a number between 0 and 1.
Returns a new color that's the result of changing one or more of this color's HWB channels.
Error if space is missing and this color is not in a legacy color space (rgb, hsl, or hwb).
Error if alpha is set and isn't null or a number between 0 and 1.
Returns a new color that's the result of changing one or more of this color's Lab channels.
Error if space is missing and this color is not in the Lab or Oklab color spaces.
Error if alpha is set and isn't null or a number between 0 and 1.
Returns a new color that's the result of changing one or more of this color's LCH channels.
Error if space is missing and this color is not in the LCH or Oklch color spaces.
Error if alpha is set and isn't null or a number between 0 and 1.
Returns a new color that's the result of changing one or more of this color's RGB channels.
Error if space is missing and this color is not in a legacy color space (rgb, hsl, or hwb).
Error if alpha is set and isn't null or a number between 0 and 1.
Returns a new color that's the result of changing one or more of this color's XYZ channels.
Error if space is missing and this color is not in an XYZ color space.
Error if alpha is set and isn't null or a number between 0 and 1.
Returns the value of a single specified channel of this color, with missing channels converted to 0.
Error if channel is not alpha or a channel in this color's space.
Returns the value of a single specified channel of this color after converting this color to the specified space, with missing channels converted to 0.
Error if channel is not alpha or a channel in space.
Returns the value at index index in this value as a list, or undefined if index isn't valid for this list.
All SassScript values can be used as lists. Maps count as lists of pairs, and all other values count as single-value lists.
This is a shorthand for this.asList.get(index), although it may be more efficient in some cases.
This method uses the same indexing conventions as the immutable package: unlike Sass the index of the first element is 0, but like Sass negative numbers index from the end of the list.
Returns a hash code that can be used to store this in a hash map.
Returns a color partway between this color and color2 according to method, as defined by the CSS Color 4 color interpolation procedure.
If method is missing and this color is in a rectangular color space (Lab, Oklab, RGB, and XYZ spaces), method defaults to the color space of this color. Otherwise, method defaults to a space separated list containing the color space of this color and the string "shorter".
The weight is a number between 0 and 1 that indicates how much of this color should be in the resulting color. If omitted, it defaults to 0.5.
Optional options: { Optional method?: HueInterpolationMethod
Optional weight?: number
Returns a boolean indicating whether a given channel value is a missing channel.
Returns a boolean indicating whether a given channel is powerless in this color. This is a special state that's defined for individual color spaces, which indicates that a channel's value won't affect how a color is displayed.
Optional options: { Optional options: { Optional options: { Optional options: { Optional options: { Optional options: { Returns a boolean indicating whether this color is in-gamut (as opposed to having one or more of its channels out of bounds) for the specified space, or its current color space if space is not specified.
Optional space: KnownColorSpace
Converts sassIndex into a JavaScript-style index into the list returned by asList.
Sass indexes are one-based, while JavaScript indexes are zero-based. Sass indexes may also be negative in order to index from the end of the list.
Error If sassIndex isn't a number, if that number isn't an integer, or if that integer isn't a valid index for asList.
The Sass-style index into this as a list.
Optional name: string
The name of the function argument sassIndex came from (without the $) if it came from an argument. Used for error reporting.
Returns a copy of this color, modified so it is in-gamut for the specified space—or the current color space if space is not specified—using method to map out-of-gamut colors into the desired gamut.
Optional space?: KnownColorSpace
Returns a new color that's the result of converting this color to the specified space.
© 2006–2025 the Sass team, and numerous contributors
Licensed under the MIT License.
https://sass-lang.com/documentation/js-api/classes/SassColor
Sass's color type.
No matter what representation was originally used to create this color, all of its channels are accessible.