Compose SwiftUIv0.4.0
esc
GuideAPIGitHub
View

Label

A title next to an icon, laid out the way the platform expects.

iOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+
fun Label(title: String, image: String, modifier: Modifier = Modifier)

Overview

Lists, menus and toolbars adapt a label automatically: they may show the title, the icon or both.

Label("Favorites", systemImage = SFSymbol.starFill)

This is the Kotlin form of SwiftUI Label.init(_:image:): SwiftUI documentation. In Swift it reads:

nonisolated init<S>(_ title: S, image name: String) where S : StringProtocol

Topics

Creating a Label

fun Label(modifier: Modifier = Modifier, title: @Composable () -> Unit, icon: @Composable () -> Unit)
SwiftUI Label.init(title:icon:)
fun Label(title: String, systemImage: SFSymbol, modifier: Modifier = Modifier)
SwiftUI Label.init(_:systemImage:)
fun Label(title: String, image: String, modifier: Modifier = Modifier)
SwiftUI Label.init(_:image:)
fun Label(titleResource: LocalizedKey, systemImage: SFSymbol, modifier: Modifier = Modifier)
SwiftUI Label.init(_:systemImage:)
fun Label(titleResource: LocalizedKey, image: String, modifier: Modifier = Modifier)
SwiftUI Label.init(_:image:)
fun Label(titleKey: LocalizedKey? = null, systemImage: SFSymbol? = null, image: String? = null, modifier: Modifier = Modifier)
SwiftUI Label · (e.g. Image(systemName = SFSymbol.star)).

Methods

fun LabelSystemImage(titleKey: LocalizedKey, systemImage: SFSymbol, modifier: Modifier = Modifier)
SwiftUI Label.init(_:systemImage:)
fun LabelImage(titleKey: LocalizedKey, image: String, modifier: Modifier = Modifier)
SwiftUI Label.init(_:image:)