跳转到内容

SuperDropdown

SuperDropdown 是 Miuix 中的下拉菜单组件,提供了标题、摘要和下拉选项列表,支持点击交互,常用于选项设置和列表选择中。

使用前提

此组件依赖 Scaffold 提供的 MiuixPopupHost 以显示弹出内容。必须在 Scaffold 中使用,否则弹出内容无法正常渲染。

引入

kotlin
import top.yukonga.miuix.kmp.extra.SuperDropdown

基本用法

SuperDropdown 组件提供了基础的下拉菜单功能:

kotlin
var selectedIndex by remember { mutableStateOf(0) }
val options = listOf("选项 1", "选项 2", "选项 3")

Scaffold {
    SuperDropdown(
        title = "下拉菜单",
        items = options,
        selectedIndex = selectedIndex,
        onSelectedIndexChange = { selectedIndex = it }
    )
}

带摘要的下拉菜单

kotlin
var selectedIndex by remember { mutableStateOf(0) }
val options = listOf("中文", "English", "日本語")

Scaffold {
    SuperDropdown(
        title = "语言设置",
        summary = "选择您的首选语言",
        items = options,
        selectedIndex = selectedIndex,
        onSelectedIndexChange = { selectedIndex = it }
    )
}

组件状态

禁用状态

kotlin
SuperDropdown(
    title = "禁用下拉菜单",
    summary = "此下拉菜单当前不可用",
    items = listOf("选项 1"),
    selectedIndex = 0,
    onSelectedIndexChange = {},
    enabled = false
)

属性

SuperDropdown 属性

属性名类型说明默认值是否必须
itemsList<String>下拉选项列表-
selectedIndexInt当前选中项的索引-
titleString下拉菜单的标题-
modifierModifier应用于组件的修饰符Modifier
titleColorBasicComponentColors标题文本的颜色配置BasicComponentDefaults.titleColor()
summaryString?下拉菜单的摘要说明null
summaryColorBasicComponentColors摘要文本的颜色配置BasicComponentDefaults.summaryColor()
dropdownColorsDropdownColors下拉菜单的颜色配置DropdownDefaults.dropdownColors()
startAction@Composable (() -> Unit)?左侧显示的自定义内容null
bottomAction@Composable (() -> Unit)?底部显示的自定义内容null
insideMarginPaddingValues组件内部内容的边距BasicComponentDefaults.InsideMargin
maxHeightDp?下拉菜单的最大高度null
enabledBoolean组件是否可交互true
showValueBoolean是否显示当前选中的值true
onSelectedIndexChange((Int) -> Unit)?选中项变化时的回调-
属性名类型说明
contentColorColor选项文本颜色
containerColorColor选项背景颜色
selectedContentColorColor选中项文本颜色
selectedContainerColorColor选中项背景颜色

变更日志

基于 Apache-2.0 许可发布