code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

[Compose] Mapping Colors and Dimensions

Open Woermachine opened this issue 7 months ago • 0 comments

Hello 👋 I'm trying to figure out how to pass color and dimensions (dp) as properties in my Figma mapping file.

Context:

  • I'm an Android Developer and I'm trying to do this with Jetpack Compose
  • I have Colors and Dimensions set up as Variables in my design system in Figma

Here is an example of the button I'm trying to map:

The parameters I'm having trouble with are backgroundColor, textColor, and borderWidth.

@Composable
fun MyButton(
    text: String,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    backgroundColor: Color = MyColor.Blue,
    textColor: Color = MyColor.White,
    borderWidth: Dp = 1.dp,
) { ... }
object MyColor {
     val Blue = Color(0xFF0070C8)
     val White = Color(0xFFFFFFFF)
     val Green = Color(0xFF057E54)
}

Woermachine avatar Jul 17 '25 20:07 Woermachine