Thread
#compose
    John O'Reilly

    John O'Reilly

    1 year ago
    Next up on SwiftUI/Compose comparison 🙂 ....in SwiftUI I can apply a font to all
    Text
    elements within something like
    HStack
    as shown below. Is anything similar possible right now with Compose (or planned)?
    HStack {
        Text("some text")
        Text("some more text")
    }
    .font(.caption)
    Bryan Herbst

    Bryan Herbst

    1 year ago
    Yeah, you can use Ambients (https://developer.android.com/reference/kotlin/androidx/compose/runtime/Ambient) for that. There are a few ambients built into Material, including text style, content color, etc TextStyles are a little bit of an oddball in that you should use
    ProvideTextStyle
    instead of the usual
    Providers
    , so the Compose equivalent would look something like:
    ProvideTextStyle(MaterialTheme.typography.caption) {
      Column {
        Text("some text")
        Text("some more text")
      }
    }
    John O'Reilly

    John O'Reilly

    1 year ago
    ah, interesting, thanks!
    k

    Kirill Grouchnikov

    1 year ago
    Probably it'd be best to start with reading on what Compose has, and then ask about specific things that are missing
    John O'Reilly

    John O'Reilly

    1 year ago
    I do try and keep up with what's in Compose but clearly I missed a few things 🙂
    k

    Kirill Grouchnikov

    1 year ago