sass_api library

We strongly recommend importing this library with the prefix sass.

Classes

Argument AST
An argument declared as part of an ArgumentDeclaration.
ArgumentDeclaration AST Parsing
An argument declaration, as for a function or mixin definition.
ArgumentInvocation AST
A set of arguments passed in to a function or mixin.
AstNode AST
A node in an abstract syntax tree.
AsyncCallable Compile
An interface for functions and mixins that can be invoked from Sass by passing in arguments.
AsyncImportCache Dependencies
An in-memory cache of parsed stylesheets that have been imported by Sass.
AsyncImporter Importer
An interface for importers that resolves URLs in @imports to the contents of Sass files.
AtRootRule AST
An @at-root rule.
AtRule AST
An unknown at-rule.
AttributeSelector AST
An attribute selector.
BinaryOperationExpression AST
A binary operator, as in 1 + 2 or $this and $other.
BooleanExpression AST
A boolean literal, true or false.
CalculationInterpolation Value
A deprecated representation of a string injected into a SassCalculation using interpolation.
CalculationOperation Value
A binary operation that can appear in a SassCalculation.
Callable Compile
An interface for functions and mixins that can be invoked from Sass by passing in arguments.
CallableDeclaration AST
An abstract class for callables (functions or mixins) that are declared in user code.
CallableInvocation AST
An abstract class for invoking a callable (a function or mixin).
ClassSelector AST
A class selector.
ColorExpression AST
A color literal.
CompileResult Compile
The result of compiling a Sass document to CSS, along with metadata about the compilation process.
ComplexSelector AST Parsing
A complex selector.
ComplexSelectorComponent AST
A component of a ComplexSelector.
CompoundSelector AST Parsing
A compound selector.
ConfiguredVariable AST
A variable configured by a with clause in a @use or @forward rule.
ContentBlock AST
An anonymous block of code that's invoked for a ContentRule.
ContentRule AST
A @content rule.
DebugRule AST
A @debug rule.
Declaration AST
A declaration (that is, a name: value pair).
DependencyReport
A struct of different types of dependencies a Sass stylesheet can contain.
DynamicImport AST
An import that will load a Sass file at runtime.
EachRule AST
An @each rule.
ElseClause AST
An @else clause in an @if rule.
ErrorRule AST
An @error rule.
Expression AST Parsing
A SassScript expression in a Sass syntax tree.
ExpressionVisitor<T> Visitor
An interface for visitors that traverse SassScript expressions.
ExtendRule AST
An @extend rule.
FilesystemImporter Importer
An importer that loads files from a load path on the filesystem.
ForRule AST
A @for rule.
ForwardRule AST
A @forward rule.
FunctionExpression AST
A function invocation.
FunctionRule AST
A function declaration.
IDSelector AST
An ID selector.
IfClause AST
An @if or @else if clause in an @if rule.
IfExpression AST
A ternary expression.
IfRule AST
An @if rule.
IfRuleClause AST
The superclass of @if and @else clauses.
Import AST
An abstract superclass for different types of import.
ImportCache Dependencies
An in-memory cache of parsed stylesheets that have been imported by Sass.
Importer Importer
An interface for importers that resolves URLs in @imports to the contents of Sass files.
ImporterResult Importer
The result of importing a Sass stylesheet, as returned by Importer.load.
ImportRule AST
An @import rule.
IncludeRule AST
A mixin invocation.
InterpolatedFunctionExpression AST
An interpolated function invocation.
Interpolation AST
Plain text interpolated with Sass expressions.
InterpolationMap
A map from locations in a string generated from an Interpolation to the original source code in the interpolation.
ListExpression AST
A list literal.
Logger Compile
An interface for loggers that print messages produced by Sass stylesheets.
LoudComment AST
A loud CSS-style comment.
MapExpression AST
A map literal.
MediaRule AST
A @media rule.
MixinRule AST
A mixin declaration.
NullExpression AST
A null literal.
NumberExpression AST
A number literal.
PackageImporter Importer
An importer that loads stylesheets from package: imports.
ParenthesizedExpression AST
An expression wrapped in parentheses.
ParentSelector AST
A selector that matches the parent in the Sass stylesheet.
ParentStatement<T extends List<Statement>?> AST
A Statement that can have child statements.
PlaceholderSelector AST
A placeholder selector.
PseudoSelector AST
A pseudo-class or pseudo-element selector.
QualifiedName AST
A qualified name.
ReturnRule AST
A @return rule.
SassArgumentList Value
A SassScript argument list.
SassBoolean Value
A SassScript boolean value.
SassCalculation Value
A SassScript calculation.
SassColor Value
A SassScript color.
SassDeclaration AST
A common interface for any node that declares a Sass member.
SassDependency AST
A common interface for UseRules, ForwardRules, and DynamicImports.
SassFunction Value
A SassScript function reference.
SassList Value
A SassScript list.
SassMap Value
A SassScript map.
SassMixin Value
A SassScript mixin reference.
SassNode AST
A node in the abstract syntax tree for an unevaluated Sass or SCSS file.
SassNumber Value
A SassScript number.
SassReference AST
A common interface for any node that references a Sass member.
SassString Value
A SassScript string.
Selector AST
A node in the abstract syntax tree for a selector.
SelectorExpression AST
A parent selector reference, &.
SelectorList AST Parsing
A selector list.
SelectorVisitor<T> Visitor
An interface for visitors that traverse selectors.
SilentComment AST
A silent Sass-style comment.
SimpleSelector AST Parsing
An abstract superclass for simple selectors.
Statement AST
A statement in a Sass syntax tree.
StatementVisitor<T> Visitor
An interface for visitors that traverse Sass statements.
StaticImport AST
An import that produces a plain CSS @import rule.
StringExpression AST
A string literal.
StyleRule AST
A style rule.
Stylesheet AST Parsing
A Sass stylesheet.
SupportsAnything AST
A supports condition that represents the forwards-compatible <general-enclosed> production.
SupportsCondition AST
An abstract class for defining the condition a @supports rule selects.
SupportsDeclaration AST
A condition that selects for browsers where a given declaration is supported.
SupportsExpression AST
An expression-level @supports condition.
SupportsFunction AST
A function-syntax condition.
SupportsInterpolation AST
An interpolated condition.
SupportsNegation AST
A negated condition.
SupportsOperation AST
An operation defining the relationship between two conditions.
SupportsRule AST
A @supports rule.
TypeSelector AST
A type selector.
UnaryOperationExpression AST
A unary operator, as in +$var or not fn().
UniversalSelector AST
Matches any element in the given namespace.
UseRule AST
A @use rule.
Value Value
A SassScript value.
ValueExpression AST
An expression that directly embeds a Value.
VariableDeclaration AST
A variable declaration.
VariableExpression AST
A Sass variable.
WarnRule AST
A @warn rule.
WhileRule AST
A @while rule.

Enums

AttributeOperator
An operator that defines the semantics of an AttributeSelector.
BinaryOperator AST
A binary operator constant.
CalculationOperator Value
An enumeration of possible operators for CalculationOperation.
Combinator AST
A combinator that defines the relationship between selectors in a ComplexSelector.
Deprecation
A deprecated feature in the language.
ListSeparator Value
An enum of list separator types.
OutputStyle Compile
An enum of generated CSS styles.
Syntax Compile
An enum of syntaxes that Sass can parse.
UnaryOperator AST
A unary operator constant.

Mixins

AstSearchVisitor<T> Visitor
A visitor that recursively traverses each statement and expression in a Sass AST whose visit* methods default to returning null, but which returns the first non-null value returned by any method.
RecursiveAstVisitor Visitor
A visitor that recursively traverses each statement and expression in a Sass AST.
RecursiveSelectorVisitor Visitor
A visitor that recursively traverses each component of a Selector AST.
RecursiveStatementVisitor Visitor
A visitor that recursively traverses each statement in a Sass AST.
ReplaceExpressionVisitor Visitor
A visitor that recursively traverses each expression in a SassScript AST and replaces its contents with the values returned by nested recursion.
SelectorSearchVisitor<T> Visitor
A SelectorVisitor whose visit* methods default to returning null, but which returns the first non-null value returned by any method.
StatementSearchVisitor<T> Visitor
A StatementVisitor whose visit* methods default to returning null, but which returns the first non-null value returned by any method.

Extensions

ExpressionExtensions on Expression
SassApiColor on SassColor Value
Extension methods that are only visible through the sass_api package.
SassApiValue on Value Value
Extension methods that are only visible through the sass_api package.

Constants

sassFalse → const SassBoolean Value
The SassScript false value.
sassNull → const Value Value
The SassScript null value.
sassTrue → const SassBoolean Value
The SassScript true value.

Functions

compile(String path, {bool color = false, Logger? logger, Iterable<Importer>? importers, Iterable<String>? loadPaths, PackageConfig? packageConfig, Iterable<Callable>? functions, OutputStyle? style, bool quietDeps = false, bool verbose = false, void sourceMap(SingleMapping map)?, bool charset = true}) String Compile
Like compileToResult, but returns CompileResult.css rather than returning CompileResult directly.
compileAsync(String path, {bool color = false, Logger? logger, Iterable<AsyncImporter>? importers, PackageConfig? packageConfig, Iterable<String>? loadPaths, Iterable<AsyncCallable>? functions, OutputStyle? style, bool quietDeps = false, bool verbose = false, void sourceMap(SingleMapping map)?}) Future<String> Compile
Like compile, except it runs asynchronously.
compileString(String source, {Syntax? syntax, bool color = false, Logger? logger, Iterable<Importer>? importers, PackageConfig? packageConfig, Iterable<String>? loadPaths, Iterable<Callable>? functions, OutputStyle? style, Importer? importer, Object? url, bool quietDeps = false, bool verbose = false, void sourceMap(SingleMapping map)?, bool charset = true, bool indented = false}) String Compile
Like compileStringToResult, but returns CompileResult.css rather than returning CompileResult directly.
compileStringAsync(String source, {Syntax? syntax, bool color = false, Logger? logger, Iterable<AsyncImporter>? importers, PackageConfig? packageConfig, Iterable<String>? loadPaths, Iterable<AsyncCallable>? functions, OutputStyle? style, AsyncImporter? importer, Object? url, bool quietDeps = false, bool verbose = false, void sourceMap(SingleMapping map)?, bool charset = true, bool indented = false}) Future<String> Compile
Like compileString, except it runs asynchronously.
compileStringToResult(String source, {Syntax? syntax, bool color = false, Logger? logger, Iterable<Importer>? importers, PackageConfig? packageConfig, Iterable<String>? loadPaths, Iterable<Callable>? functions, OutputStyle? style, Importer? importer, Object? url, bool quietDeps = false, bool verbose = false, bool sourceMap = false, bool charset = true, Iterable<Deprecation>? fatalDeprecations, Iterable<Deprecation>? futureDeprecations}) CompileResult Compile
Compiles source to CSS and returns a CompileResult containing the CSS and additional metadata about the compilation..
compileStringToResultAsync(String source, {Syntax? syntax, bool color = false, Logger? logger, Iterable<AsyncImporter>? importers, PackageConfig? packageConfig, Iterable<String>? loadPaths, Iterable<AsyncCallable>? functions, OutputStyle? style, AsyncImporter? importer, Object? url, bool quietDeps = false, bool verbose = false, bool sourceMap = false, bool charset = true, Iterable<Deprecation>? fatalDeprecations, Iterable<Deprecation>? futureDeprecations}) Future<CompileResult> Compile
Like compileStringToResult, except it runs asynchronously.
compileToResult(String path, {bool color = false, Logger? logger, Iterable<Importer>? importers, Iterable<String>? loadPaths, PackageConfig? packageConfig, Iterable<Callable>? functions, OutputStyle? style, bool quietDeps = false, bool verbose = false, bool sourceMap = false, bool charset = true, Iterable<Deprecation>? fatalDeprecations, Iterable<Deprecation>? futureDeprecations}) CompileResult Compile
Loads the Sass file at path, compiles it to CSS, and returns a CompileResult containing the CSS and additional metadata about the compilation.
compileToResultAsync(String path, {bool color = false, Logger? logger, Iterable<AsyncImporter>? importers, PackageConfig? packageConfig, Iterable<String>? loadPaths, Iterable<AsyncCallable>? functions, OutputStyle? style, bool quietDeps = false, bool verbose = false, bool sourceMap = false, bool charset = true, Iterable<Deprecation>? fatalDeprecations, Iterable<Deprecation>? futureDeprecations}) Future<CompileResult>
Like compileToResult, except it runs asynchronously.
fakeFromImport<T>(T callback()) → T
Runs callback in a context where AsyncImporter.fromImport returns true.
findDependencies(Stylesheet stylesheet) DependencyReport Dependencies
Returns stylesheet's statically-declared dependencies.
isIdentifier(String text) bool Parsing
Returns whether text is a valid CSS identifier.
parseIdentifier(String text) String Parsing
Parses text as a CSS identifier and returns the result.
warn(String message, {bool deprecation = false}) → void Compile
Prints a warning message associated with the current @import or function call.

Typedefs

AsyncCanonicalizeResult = (AsyncImporter, Uri, {Uri originalUrl})
A canonicalized URL and the importer that canonicalized it.
CanonicalizeResult = (Importer, Uri, {Uri originalUrl})
A canonicalized URL and the importer that canonicalized it.

Exceptions / Errors

SassException Compile
An exception thrown by Sass.
SassFormatException Parsing
An exception thrown when Sass parsing has failed.