theme library

The astryx_ui theme layer, without any components.

Import this when you need tokens, AstryxThemeData, or the theme engine but not the widget set — build-time theme adapters, chart configuration, canvas or custom painting, and tests.

import 'package:astryx_ui/theme.dart';

This mirrors Astryx's @astryxdesign/core/theme entry point.

Classes

AstryxButtonTheme
Visual configuration for AstryxButton and AstryxIconButton.
AstryxColorScaleConfig
Configuration for the colour scale.
AstryxColorValue
A token value that differs between light and dark mode.
AstryxDefinedTheme
A defined theme, ready to hand to the theme runtime.
AstryxDefineThemeInput
The input to defineTheme.
AstryxDerivedVar
One derived-variable mapping: a theme-author property and where it lands.
AstryxDividerTheme
Visual configuration for AstryxDivider.
AstryxFontStack
A CSS font stack translated into what Flutter's text layer accepts.
AstryxHct
A colour expressed as hue, chroma and tone.
AstryxIconTheme
Visual configuration for AstryxIcon.
AstryxMotionScaleConfig
Configuration for the motion scale.
AstryxOnMediaOverrides
Theme-supplied overrides for one surface context.
AstryxRadiusScaleConfig
Configuration for the radius scale.
AstryxResolvedOnMedia
Resolved on-media overrides, as stored on a defined theme.
AstryxResolvedTokenSet
Every token name mapped to a concrete light value and a concrete dark value.
AstryxRgba
A colour decomposed into 0–255 RGB channels and a 0–1 alpha.
AstryxShadow
One shadow layer, as CSS box-shadow describes it.
AstryxStyleOverrides
CSS property overrides for one style rule, plus any pseudo-class blocks.
AstryxSyntaxTheme
A named syntax highlighting palette.
AstryxTextTheme
Visual configuration for AstryxText and AstryxHeading.
AstryxTheme
Makes an AstryxThemeData available to the widgets beneath it.
AstryxThemeData
Every Astryx token for one colour mode, as a Flutter value.
AstryxToken
A design token, identified by its upstream CSS custom property name.
AstryxTokenValue
A token value: either one CSS string, or a light/dark pair.
AstryxTypeScaleConfig
Configuration for the type scale.
AstryxTypeScaleSpec
The type scale portion of a typography configuration: base size and ratio.
AstryxTypeScaleWeights
Per-level and per-type font weight overrides for a type scale.
AstryxTypographyConfig
A theme's typography configuration.
AstryxTypographyRole
One typography role — body, heading or code.

Enums

AstryxBorderToken
Border widths, in logical pixels.
AstryxColorMode
The colour mode a consumer asks for, which may defer to the platform.
AstryxColorToken
Semantic colour tokens.
AstryxContrastLevel
The contrast level applied to text and UI tone assignments.
AstryxDerivedExpansion
A named expansion strategy for a derived property.
AstryxDurationToken
Animation durations.
AstryxEaseToken
Animation easing curves, as CSS cubic-bezier expressions.
AstryxFontWeightToken
Font weights.
AstryxNeutralStyle
How much of the seed hue bleeds into neutral and background colours.
AstryxRadiusToken
Corner radii, in logical pixels.
AstryxShadowToken
Elevation shadows. Values are compound CSS box-shadow strings.
AstryxSizeToken
Interactive element heights, in logical pixels.
AstryxSpacingToken
Spacing scale, in logical pixels. A 4 px grid with 2 px half-steps.
AstryxSurface
Which surface luminance an override set applies to.
AstryxTextSizeToken
Raw font sizes, in logical pixels.
AstryxThemeMode
The colour mode a theme is resolved for.
AstryxTypeRole
A semantic typography role — one row of the type scale.
AstryxTypeToken
Semantic type-scale tokens. Each role has a -size, -weight and -leading token; Phase 3 composes them into a TextStyle.
AstryxTypographyToken
Font family stacks.

Extension Types

AstryxFontWeight
A named font weight, or a raw CSS weight as an escape hatch.

Constants

astryxColorSchemeKey → const String
The key upstream uses for the CSS color-scheme declaration.
astryxDefaultAccentSeed → const String
The hue source for accent-less configurations — the light half of the default --color-accent.
astryxDefaultOnDarkTokens → const Map<String, String>
Default token overrides for content on a dark surface.
astryxDefaultOnLightTokens → const Map<String, String>
Default token overrides for content on a light surface.
astryxDerivedVarRegistry → const Map<String, List<AstryxDerivedVar>>
Component name to its derived-variable mappings.
astryxHeadingSteps → const Map<int, int>
Heading level to step offset from the base. h4 sits at the anchor.
astryxNamedColors → const Map<String, AstryxRgba>
The named colours the design system relies on in token expressions.
astryxNonTextMinContrast → const double
The WCAG 1.4.11 minimum contrast for non-text UI boundaries.
astryxPaletteTones → const List<int>
The tones a tonal palette is sampled at.
astryxRootFontSize → const double
The CSS root font size every rem value is measured against.
astryxStepToSizeToken → const Map<int, String>
Step offset to raw size token name.
astryxSyntaxTokenKeys → const List<String>
The fourteen syntax token keys upstream defines.
astryxSyntaxTokenPrefix → const String
The CSS custom property prefix for syntax tokens.
astryxTextSteps → const Map<String, int>
Text type to step offset from the base.
astryxTokenDefaults → const Map<String, String>
Astryx's default token values, keyed by CSS custom property name.
butterThemeInput → const AstryxDefineThemeInput
The definition of the butter theme, before the engine runs over it.
chocolateThemeInput → const AstryxDefineThemeInput
The definition of the chocolate theme, before the engine runs over it.
gothicThemeInput → const AstryxDefineThemeInput
The definition of the gothic theme, before the engine runs over it.
matchaThemeInput → const AstryxDefineThemeInput
The definition of the matcha theme, before the engine runs over it.
neutralThemeInput → const AstryxDefineThemeInput
The definition of the neutral theme, before the engine runs over it.
stoneThemeInput → const AstryxDefineThemeInput
The definition of the stone theme, before the engine runs over it.
y2kThemeInput → const AstryxDefineThemeInput
The definition of the y2k theme, before the engine runs over it.

Properties

butterTheme AstryxDefinedTheme
The butter theme, resolved.
final
chocolateTheme AstryxDefinedTheme
The chocolate theme, resolved.
final
gothicTheme AstryxDefinedTheme
The gothic theme, resolved.
final
matchaTheme AstryxDefinedTheme
The matcha theme, resolved.
final
neutralTheme AstryxDefinedTheme
The neutral theme, resolved.
final
stoneTheme AstryxDefinedTheme
The stone theme, resolved.
final
y2kTheme AstryxDefinedTheme
The y2k theme, resolved.
final

Functions

astryxCssBlurToFlutterRadius(double cssBlurRadius) double
Converts a CSS box-shadow blur radius to Flutter's BoxShadow.blurRadius.
cbrt(double x) double
The cube root of x, to the precision of JavaScript's Math.cbrt.
clampDouble(double value, double min, double max) double
Clamps value to the inclusive range minmax.
compositeOver(AstryxRgba foreground, AstryxRgba backdrop) AstryxRgba
Composites a possibly translucent foreground over an opaque backdrop.
contrastRatio(Object foreground, Object background) double
The WCAG 2.x contrast ratio between a foreground and an opaque background, in the range 1–21.
deepEquals(Object? a, Object? b) bool
Whether two nullable collections are deeply equal.
deepHash(Object? value) int
A deep hash for a nullable collection, pairing with deepEquals.
deepMergeComponents(AstryxComponentStyleMap? base, AstryxComponentStyleMap? overrides) AstryxComponentStyleMap?
Deep-merges two component style maps, with overrides taking precedence.
defineTheme(AstryxDefineThemeInput input) AstryxDefinedTheme
Creates an Astryx theme.
ensureContrastTone(double hue, double chroma, double startTone, int step, String background, double minRatio) String
Walks tone in step increments from startTone until the colour reaches minRatio against background, and returns the resulting hex.
evaluateColorFunctions(String expr) String
Evaluates every supported colour function in expr, innermost first.
evaluateColorMix(String body) String?
Evaluates color-mix(in <space>, c1 [p1], c2 [p2]) to a concrete colour.
expandColorScale(AstryxColorScaleConfig config) Map<String, String>
Expands config into colour token overrides, keyed by CSS custom property name.
expandMotionScale(AstryxMotionScaleConfig config) Map<String, String>
Expands config into duration and easing token overrides, keyed by CSS custom property name.
expandRadiusScale(AstryxRadiusScaleConfig config) Map<String, String>
Expands config into radius token overrides, keyed by CSS custom property name.
expandTypeScale(AstryxTypeScaleConfig config) Map<String, String>
Expands config into typography token overrides, keyed by CSS custom property name.
formatColor(AstryxRgba color) String
Serialises a colour to a compact, CSS-usable string.
formatHex(double r, double g, double b) String
Formats RGB channels (0–255) as an uppercase #RRGGBB string.
formatNumber(double value) String
Formats value the way JavaScript stringifies a number.
generateTypeScaleComponents(AstryxTypeScaleConfig config) Map<String, Map<String, Map<String, String>>>
Builds the component style overrides that pair with a type scale.
getDerivedVars(String component, String property) List<AstryxDerivedVar>
The derived-variable entries for component and property, in priority order.
getRegisteredTheme(String? name) AstryxDefinedTheme?
Returns the theme registered under name, or null if there is none.
getRegisteredThemes() Map<String, AstryxDefinedTheme>
Returns every registered theme, keyed by name.
hctToHex(AstryxHct hct) String
Converts hct to a #RRGGBB hex string, gamut-mapping into sRGB.
hexToHct(String hex) AstryxHct
Converts a hex colour to AstryxHct.
hexWithAlpha(String hex, double alpha) String
Appends alpha (0–1) to a hex colour as a two-digit uppercase suffix.
isLightDark(String value) bool
Whether value is a light-dark() expression.
lerpBorderSide(BorderSide? a, BorderSide? b, double t) BorderSide?
Interpolates two nullable BorderSide values.
lerpColor(Color? a, Color? b, double t) Color?
Interpolates two nullable Color values.
lerpDiscrete<T>(T? a, T? b, double t) → T?
Returns a when t is below the halfway point, otherwise b.
lerpDuration(Duration? a, Duration? b, double t) Duration?
Interpolates two nullable Duration values.
lerpInsets(EdgeInsetsGeometry? a, EdgeInsetsGeometry? b, double t) EdgeInsetsGeometry?
Interpolates two nullable EdgeInsetsGeometry values.
lerpNullableDouble(double? a, double? b, double t) double?
Interpolates two nullable doubles.
lerpRadius(BorderRadiusGeometry? a, BorderRadiusGeometry? b, double t) BorderRadiusGeometry?
Interpolates two nullable BorderRadiusGeometry values.
lerpShadows(List<AstryxShadow>? a, List<AstryxShadow>? b, double t) List<AstryxShadow>?
Interpolates two nullable shadow lists.
lerpTextStyle(TextStyle? a, TextStyle? b, double t) TextStyle?
Interpolates two nullable TextStyle values.
mergeMaps<K, V>(Map<K, V>? base, Map<K, V>? other) Map<K, V>?
Merges two nullable maps, with other's entries winning.
oklabToRgba({required double l, required double aLab, required double bLab, double alpha = 1}) AstryxRgba
Converts OKLab to sRGB.
oklchToRgba({required double l, required double c, required double h, double a = 1}) AstryxRgba
Converts OKLCH to sRGB.
parseColor(String value) AstryxRgba?
Parses a concrete CSS colour string.
parseCssColor(String value, AstryxThemeMode mode) Color?
Parses a CSS colour to a Flutter Color.
parseCssCurve(String value) Curve?
Parses a CSS easing function to a Flutter Curve.
parseCssDuration(String value) Duration?
Parses a CSS time to a Duration.
parseCssFontWeight(String value) FontWeight?
Parses a CSS font weight to a Flutter FontWeight.
parseCssLength(String value, {double rootFontSize = astryxRootFontSize}) double?
Parses a CSS length to logical pixels.
parseCssShadows(String value, AstryxThemeMode mode) List<AstryxShadow>
Parses a CSS box-shadow list into shadow layers.
parseFloatLoose(String input) double
Parses a leading decimal number the way JavaScript's parseFloat does.
parseHex(String hex) AstryxRgba?
Parses a hex colour.
parseLightDark(String value) AstryxColorValue?
Parses a CSS light-dark(light, dark) expression into its two sides.
parseOklch(String value) AstryxRgba?
Parses an oklch() colour into AstryxRgba.
parseRgb(String value) AstryxRgba?
Parses an rgb() / rgba() colour.
registerTheme(AstryxDefinedTheme theme) → void
Registers theme under its own name.
relativeLuminance(AstryxRgba color) double
The WCAG 2.x relative luminance of an sRGB colour, ignoring alpha.
resetThemes() → void
Empties the registry.
resolveFontStack(String stack, {TargetPlatform? platform}) AstryxFontStack
Resolves a CSS font stack for platform.
resolveOnMedia(AstryxSurface surface, [AstryxOnMediaOverrides? input]) AstryxResolvedOnMedia
Resolves the on-media overrides for surface: the defaults for that surface, with any input tokens applied over them.
resolveReferences(Map<String, String> raw) Map<String, String>
Resolves every reference and colour function in raw to concrete values.
resolveThemeToken(AstryxDefinedTheme? theme, String name, AstryxThemeMode mode, {String fallback = ''}) String
Resolves one Astryx token for theme in mode.
resolveThemeTokens(AstryxDefinedTheme? theme, AstryxThemeMode mode) Map<String, String>
Resolves every Astryx token for theme in mode.
resolveTokenValueForMode(String value, AstryxThemeMode mode) String
Resolves a token value for mode.
resolveTokenValueObjectForMode(AstryxTokenValue value, AstryxThemeMode mode) String
Resolves an AstryxTokenValue for mode.
selectMode(String value, AstryxThemeMode mode) String
Selects the half of a light-dark() expression matching mode.
splitTopLevelComma(String input) → ({String after, String before})?
Splits the arguments of a CSS function body on the first top-level comma.
splitTopLevelCommas(String input) List<String>
Splits input on every top-level comma, not just the first.
splitTopLevelSpaces(String input) List<String>
Splits input on runs of top-level whitespace.
toFlutterColor(AstryxRgba rgba) Color
Converts an AstryxRgba to a Flutter Color.
tonalPalette(double hue, double chroma) Map<int, String>
Builds a tonal palette: one hex colour per tone in astryxPaletteTones, at the given hue and chroma.

Typedefs

AstryxComponentStyleMap = Map<String, Map<String, AstryxStyleOverrides>>
Component style overrides, keyed by component name then by style key.