Title style for ActionSheetState

Even though the title on ActionSheetState accepts a Text, it doesn't seem to be possible to style that title using functions like .bold() and .font(...).

Is there a way to do this that doesn't require implementing our own version of ActionSheet?

According to the docs for ComposableArchitecture - ActionSheetState

The title property is a ComposableArchitecture - TextState rather than just Text.

Which shows adding bold() in the code example...

state.label = TextState("Hello, ") + TextState(name).bold() + TextState("!")

Is that something you have tried? I would assume that this was also possible for the ActionSheetState.title too.

Oh, I just read a bit further on the TextState docs and they mention working with ActionSheets there too. :smiley:

Despite taking Text, none of the alert and action sheet APIs appear to allow the stylization of text, even in vanilla SwiftUI. Last time I tried in Xcode 13 I even got a purple runtime issue saying it's unsupported. Do you have some vanilla code to share that works? If we have a bug in TextState we'd love to fix it.

Thanks @Fogmeister, we did try that and it didn't work.
We could style the ActionSheet buttons, but not the title.

Thanks @stephencelis, we haven't tried it in Xcode 13 yet. I'm not surprised that it now says that's not supported, given our attempts yesterday.

However, thinking about it: we started down this path because we couldn't implement an action sheet without a title as shown here.
Unfortunately, SwiftUI doesn't seem to support an ActionSheet without a title.

I'm guessing we'll need to drop down into UIKit.

1 Like

The latest confirmationDialog APIs in iOS 15, etc., do allow you to turn off titleVisibility, but assuming you have earlier deployment targets, you may need to drop down to UIKit. We have UIKit helpers for AlertState and ActionSheetState added awhile back, but if there's anything we can do to support your use case, we'd love to help!