Skip to content

NavigationRail

NavigationRail is a side navigation component in Miuix, suitable for wide screens. It offers different display modes (icon only, text only, icon and text, icon with selected label).

Import

kotlin
import top.yukonga.miuix.kmp.basic.NavigationRail
import top.yukonga.miuix.kmp.basic.NavigationRailItem
import top.yukonga.miuix.kmp.basic.NavigationDisplayMode

Basic Usage

The NavigationRail component can be used to create side navigation menus:

kotlin
var selectedIndex by remember { mutableStateOf(0) }
val items = listOf("Home", "Profile", "Settings")
val icons = listOf(MiuixIcons.VerticalSplit, MiuixIcons.Contacts, MiuixIcons.Settings)

Row {
    NavigationRail {
        items.forEachIndexed { index, label ->
            NavigationRailItem(
                selected = selectedIndex == index,
                onClick = { selectedIndex = index },
                icon = icons[index],
                label = label
            )
        }
    }
    // Content area
}

Component States

Selected State

NavigationRailItem automatically handles the visual style of the selected item, displaying it with bold text and highlighting the icon/text.

Properties

Property NameTypeDescriptionDefault ValueRequired
modifierModifierModifier applied to the railModifierNo
header@Composable (ColumnScope.() -> Unit)?Header content (e.g. FAB or Logo)nullNo
colorColorBackground color of the railMiuixTheme.colorScheme.surfaceNo
showDividerBooleanShow divider line between rail and contenttrueNo
defaultWindowInsetsPaddingBooleanApply default window insets paddingtrueNo
minWidthDpMinimum width of the rail80.dpNo
modeNavigationDisplayModeDisplay mode for itemsNavigationDisplayMode.IconAndTextNo
content@Composable ColumnScope.()The content of the rail-Yes
Property NameTypeDescriptionDefault ValueRequired
selectedBooleanWhether the item is selected-Yes
onClick() -> UnitCallback when the item is clicked-Yes
iconImageVectorIcon of the item-Yes
labelStringLabel of the item-Yes
modifierModifierModifier applied to the itemModifierNo
enabledBooleanWhether the item is enabledtrueNo
ValueDescription
IconAndTextDisplay both icon and text.
IconOnlyDisplay only icon.
TextOnlyDisplay only text.
IconWithSelectedLabelDisplay icon always, and text only when selected.

Changelog

Released under the Apache-2.0 License