openharmony 鸿蒙 ts-basic-components-select-sys

2026-08-25 浏览 (1)

Select (System API)

The Select component provides a drop-down menu that allows users to select among multiple options.

NOTE

  • This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.

  • This topic describes only system APIs provided by the module. For details about its public APIs, see Select.

menuSystemMaterial23+

menuSystemMaterial(material:Optional<SystemUiMaterial>)

Sets the system material of the drop-down menu. Different system materials correspond to different attribute effects. This API affects paramters of the drop-down menu, such as menuBackgroundColor, borderColor, borderWidth, and shadow. It is not recommended to use this API together with the preceding APIs.

System API: This is a system API.

System capability: SystemCapability.ArkUI.ArkUI.Full

Atomic service API: This API can be used in atomic services since API version 23.

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
materialOptional<SystemUiMaterial>YesSets the system material of the drop-down menu. If the material is set to an invalid value or undefined, no system material is set.

Examples

Example 1 Setting System Material for the Select Component and Drop-down Menu

This example uses the menuSystemMaterial API to apply the system material effect to the drop-down menu, and the systemMaterial API to apply the system material effect to the Select component.

The menuSystemMaterial and systemMaterial APIs are added since API version 23.

import { uiMaterial } from '@kit.ArkUI';

@Entry
@Component
struct Index {
  build() {
    Column() {
      Select([{ value: 'SelectOption' },
        { value: 'SelectOption' },
        { value: 'SelectOption' },
        { value: 'SelectOption' },
        { value: 'SelectOption' }])
        .value('Click Show Options')
        .systemMaterial(new uiMaterial.Material({ type: uiMaterial.MaterialType.SEMI_TRANSPARENT }))
        .menuSystemMaterial(new uiMaterial.Material({ type: uiMaterial.MaterialType.SEMI_TRANSPARENT }))
    }
    // Replace $r('app.media.img') with the image resource file you use.
    .backgroundImage($r('app.media.img'))
  }
}

System material not set

select-without-menu-new-material

System material set

select-menu-new-material

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 ts-drawing-components-shape

openharmony 鸿蒙 ts-universal-attributes-sharp-clipping

openharmony 鸿蒙 ts-universal-attributes-toolbar

openharmony 鸿蒙 ts-container-lazyvgridlayout

openharmony 鸿蒙 ohos-arkui-advanced-FoldSplitContainer

openharmony 鸿蒙 ts-methods-calendarpicker-dialog

openharmony 鸿蒙 ts-uicommonevent

openharmony 鸿蒙 ts-basic-gestures-tapgesture

openharmony 鸿蒙 ohos-arkui-advanced-DialogV2

openharmony 鸿蒙 ts-components-canvas-canvas

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/AnHRqi5V