withTitle
Registers this NavKey as a destination with a static title and no actions.
Use this when you want a specific title shown in the top app bar for this destination, but no contextual action buttons are needed.
This overload is a convenience for data object destinations — it delegates to the KClass overload using this::class.
Example
override val destinations = persistentMapOf(
MyDestination.Main.withTitle("My Screen")
)To also add actions, use the overload that accepts a DestinationMetadataBuilder block:
MyDestination.Main.withTitle("My Screen") {
action(icon = Icons.Rounded.Refresh) { viewModel.refresh() }
}Receiver
The NavKey instance representing the destination to register.
Return
A Pair of this destination's KClass and a DestinationMetadata with the given title and no actions, suitable for use directly inside kotlinx.collections.immutable.persistentMapOf.
Parameters
The title to display in the top app bar when this destination is active.
See also
Registers this KClass as a destination with a static title and no actions.
Prefer this overload for data class destinations, where no representative instance is available at module-construction time. The class itself is used as the map key so that the title is resolved correctly for any instance of the destination, regardless of its runtime parameters.
Example
override val destinations = persistentMapOf(
MyDestination.Main.withTitle("Overview"), // data object — instance overload
MyDestination.Detail::class.withTitle("Detail") // data class — KClass overload
)To also add actions, use the overload that accepts a DestinationMetadataBuilder block:
MyDestination.Detail::class.withTitle("Detail") {
action(icon = Icons.Rounded.Refresh) { viewModel.refresh() }
}Receiver
The KClass of the NavKey subtype representing the destination to register.
Return
A Pair of this KClass and a DestinationMetadata with the given title and no actions, suitable for use directly inside kotlinx.collections.immutable.persistentMapOf.
Parameters
The title to display in the top app bar when this destination is active.
See also
Registers this NavKey as a destination with a static title and contextual actions defined via a DestinationMetadataBuilder DSL block.
Use this when you want both a specific top app bar title and one or more contextual action buttons for this destination.
This overload is a convenience for data object destinations — it delegates to the KClass overload using this::class.
Example
override val destinations = persistentMapOf(
MyDestination.Main.withTitle("Analytics") {
action(
icon = Icons.Rounded.Delete,
popup = ModuleDestinationActionPopup(
title = "Clear Logs",
subtitle = "This will remove all logged events.",
confirmButton = "Clear",
dismissButton = "Cancel"
)
) {
logger.clear()
}
}
)To register a title without actions, use withTitle without a block.
Receiver
The NavKey instance representing the destination to register.
Return
A Pair of this destination's KClass and a DestinationMetadata with the given title and the actions registered in block, suitable for use directly inside kotlinx.collections.immutable.persistentMapOf.
Parameters
The title to display in the top app bar when this destination is active.
A DestinationMetadataBuilder DSL block in which you register actions via DestinationMetadataBuilder.action.
See also
Registers this KClass as a destination with a static title and contextual actions defined via a DestinationMetadataBuilder DSL block.
Prefer this overload for data class destinations, where no representative instance is available at module-construction time. The class itself is used as the map key so that the title and actions are resolved correctly for any instance of the destination, regardless of its runtime parameters.
Example
override val destinations = persistentMapOf(
MyDestination.Main.withTitle("Overview") { // data object — instance overload
action(icon = Icons.Rounded.Refresh) { viewModel.refresh() }
},
MyDestination.Detail::class.withTitle("Detail") { // data class — KClass overload
action(icon = Icons.Rounded.Share) { viewModel.share() }
}
)To register a title without actions, use withTitle without a block.
Receiver
The KClass of the NavKey subtype representing the destination to register.
Return
A Pair of this KClass and a DestinationMetadata with the given title and the actions registered in block, suitable for use directly inside kotlinx.collections.immutable.persistentMapOf.
Parameters
The title to display in the top app bar when this destination is active.
A DestinationMetadataBuilder DSL block in which you register actions via DestinationMetadataBuilder.action.