Skip to content

Android / Compose

The android() builder renders Kotlin code for Jetpack Compose. Output includes type-safe Color, Dp, FontWeight, and more. KDoc is generated from $description.

import { android } from 'dispersa'
OptionTypeDefaultDescription
namestringUnique output identifier
filestring or functionOutput path (supports {*context*} interpolation for modifiers)
preset'standalone' | 'bundle''standalone'Output preset
packageNamestringKotlin package name (required)
objectNamestring’DesignTokens’Top-level object name
structure'nested' | 'flat''nested'Token structure in output
colorFormat'argb_hex' | 'argb_float' | 'argb8' | 'argb_floats''argb_hex'Color format (argb8 and argb_floats are aliases)
colorSpace'sRGB' | 'displayP3''sRGB'Target color space
visibility'public' | 'internal'Kotlin visibility (omitted by default; Kotlin defaults to public)
indentnumber4Spaces per indentation level
transformsTransform[]Per-output transforms
filtersFilter[]Per-output filters
package com.example.tokens
public object Tokens {
public object Color {
public object Brand {
/**
* Primary brand color
*/
public val primary: Color = Color(0xFF0066CC)
}
}
public object Spacing {
public val medium: Dp = 16.dp
}
}
Token TypeKotlin Type
colorColor
dimensionDp
fontFamilyFontFamily
fontWeightFontWeight
durationDuration
numberDouble
shadowShadowToken
borderBorderStroke
cubicBezierCubicBezierEasing
typographyTextStyle

Token $description values are emitted as KDoc:

/**
* Primary brand color used for CTAs
*/
public val primary: Color = Color(0xFF0066CC)
  • argb_hexColor(0xFF0066CC) (default, 32-bit ARGB hex)
  • argb_floatColor(red = 0f, green = 0.4f, blue = 0.8f, alpha = 1f)
  • argb8 — alias for argb_hex
  • argb_floats — alias for argb_float
android({
name: 'tokens',
file: 'Tokens.kt',
colorFormat: 'argb_float',
})