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
AstryxButtonandAstryxIconButton. - 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-shadowdescribes it. - AstryxStyleOverrides
- CSS property overrides for one style rule, plus any pseudo-class blocks.
- AstryxSyntaxTheme
- A named syntax highlighting palette.
- AstryxTextTheme
-
Visual configuration for
AstryxTextandAstryxHeading. - 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,-weightand-leadingtoken; Phase 3 composes them into aTextStyle. - 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-schemedeclaration. - 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
remvalue 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
buttertheme, before the engine runs over it. - chocolateThemeInput → const AstryxDefineThemeInput
-
The definition of the
chocolatetheme, before the engine runs over it. - gothicThemeInput → const AstryxDefineThemeInput
-
The definition of the
gothictheme, before the engine runs over it. - matchaThemeInput → const AstryxDefineThemeInput
-
The definition of the
matchatheme, before the engine runs over it. - neutralThemeInput → const AstryxDefineThemeInput
-
The definition of the
neutraltheme, before the engine runs over it. - stoneThemeInput → const AstryxDefineThemeInput
-
The definition of the
stonetheme, before the engine runs over it. - y2kThemeInput → const AstryxDefineThemeInput
-
The definition of the
y2ktheme, before the engine runs over it.
Properties
- butterTheme → AstryxDefinedTheme
-
The
buttertheme, resolved.final - chocolateTheme → AstryxDefinedTheme
-
The
chocolatetheme, resolved.final - gothicTheme → AstryxDefinedTheme
-
The
gothictheme, resolved.final - matchaTheme → AstryxDefinedTheme
-
The
matchatheme, resolved.final - neutralTheme → AstryxDefinedTheme
-
The
neutraltheme, resolved.final - stoneTheme → AstryxDefinedTheme
-
The
stonetheme, resolved.final - y2kTheme → AstryxDefinedTheme
-
The
y2ktheme, resolved.final
Functions
-
astryxCssBlurToFlutterRadius(
double cssBlurRadius) → double -
Converts a CSS
box-shadowblur radius to Flutter's BoxShadow.blurRadius. -
cbrt(
double x) → double -
The cube root of
x, to the precision of JavaScript'sMath.cbrt. -
clampDouble(
double value, double min, double max) → double -
Clamps
valueto the inclusive rangemin–max. -
compositeOver(
AstryxRgba foreground, AstryxRgba backdrop) → AstryxRgba -
Composites a possibly translucent
foregroundover an opaquebackdrop. -
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
overridestaking 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
stepincrements fromstartToneuntil the colour reachesminRatioagainstbackground, 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
configinto colour token overrides, keyed by CSS custom property name. -
expandMotionScale(
AstryxMotionScaleConfig config) → Map< String, String> -
Expands
configinto duration and easing token overrides, keyed by CSS custom property name. -
expandRadiusScale(
AstryxRadiusScaleConfig config) → Map< String, String> -
Expands
configinto radius token overrides, keyed by CSS custom property name. -
expandTypeScale(
AstryxTypeScaleConfig config) → Map< String, String> -
Expands
configinto 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
#RRGGBBstring. -
formatNumber(
double value) → String -
Formats
valuethe 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
componentandproperty, 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
hctto a#RRGGBBhex 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
valueis alight-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
awhentis below the halfway point, otherwiseb. -
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-shadowlist into shadow layers. -
parseFloatLoose(
String input) → double -
Parses a leading decimal number the way JavaScript's
parseFloatdoes. -
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
themeunder 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 anyinputtokens applied over them. -
resolveReferences(
Map< String, String> raw) → Map<String, String> -
Resolves every reference and colour function in
rawto concrete values. -
resolveThemeToken(
AstryxDefinedTheme? theme, String name, AstryxThemeMode mode, {String fallback = ''}) → String -
Resolves one Astryx token for
themeinmode. -
resolveThemeTokens(
AstryxDefinedTheme? theme, AstryxThemeMode mode) → Map< String, String> -
Resolves every Astryx token for
themeinmode. -
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 matchingmode. -
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
inputon every top-level comma, not just the first. -
splitTopLevelSpaces(
String input) → List< String> -
Splits
inputon 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
hueandchroma.
Typedefs
-
AstryxComponentStyleMap
= Map<
String, Map< String, AstryxStyleOverrides> > - Component style overrides, keyed by component name then by style key.