底部弹出面板组件
| Files | Last commit | Last update |
|---|---|---|
| 7 months ago | ||
| 5 months ago | ||
| 6 months ago | ||
| 5 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 5 months ago | ||
| 11 years ago | ||
| 6 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 5 months ago | ||
| 5 months ago | ||
| 5 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 6 months ago |
bottomsheet
This project is developed based on bottomsheet.
Introduction
BottomSheet is a dismissible view component that slides up from the bottom of the screen.
Demo

Installation
ohpm install @ohos/bottomsheet
For more information about OpenHarmony ohpm environment configuration, please refer to How to Install OpenHarmony ohpm Packages.
Constraints and Limitations
Compatibility
Verified on the following versions:
- DevEco Studio: DevEco Studio 6.0.2 Release(6.0.2.640), SDK: API22(6.0.2.130)
- DevEco Studio: NEXT Developer Beta1(5.0.3.122), SDK: API12(5.0.0.18)
Permissions Required
None
Usage Example
Complete Example
import { router } from '@kit.ArkUI';
import { BottomSheetComponent, BottomSheetCtrl } from '@ohos/bottomsheet';
/**
* 底部弹窗演示页面
*/
@Entry
@Component
struct BottomSheetFragmentPage {
private bottomSheetCtrl: BottomSheetCtrl = new BottomSheetCtrl();
build() {
Column() {
// 顶部导航栏
this.TopComponent();
// 传递 @Builder 方法给子组件
BottomSheetComponent({
bottomSheetController: this.bottomSheetCtrl,
bottomSheetLayout: this.BottomSheetLayout.bind(this),
backgroundLayout: this.BackgroundLayout.bind(this)
});
}
.height('100%')
.width('100%')
.backgroundColor('#F5F5F5');
}
/**
* 顶部导航栏组件
*/
@Builder
TopComponent() {
Row() {
Row() {
Text('←')
.fontSize(20)
.fontColor('#FFFFFF')
.fontWeight(FontWeight.Bold)
.padding({
left: 16,
top: 16,
bottom: 16,
right: 16
})
.onClick(() => {
router.back();
});
Text('BottomSheet Fragment')
.fontSize(20)
.fontColor('#FFFFFF')
.fontWeight(FontWeight.Bold)
.padding({ left: 16, top: 16, bottom: 16 });
}
.width('100%')
.backgroundColor('#FFE12828');
}
.width('100%')
.backgroundColor('#ffb81f1f')
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]);
}
@Builder
BackgroundLayout() {
Column() {
Button('SHOW')
.type(ButtonType.Normal)
.width('100%')
.backgroundColor('#ffd7d7d7')
.fontColor('#ff050505')
.onClick(() => {
this.bottomSheetCtrl.toTop();
});
}
.padding(16);
}
/**
* 底部弹窗内容布局
*/
@Builder
BottomSheetLayout() {
Column() {
Text('Hello, World!')
.width('100%')
.fontColor('#ff918787')
.padding(10);
}
.width('100%');
}
}
Notes
None
Usage Instructions
1. Import Components in Relevant
import { BottomSheetComponent, BottomSheetCtrl } from '@ohos/bottomsheet';
2. Create Components Where Needed
Create components where needed, passing required parameters during creation.
BottomSheetComponent({
bottomSheetController: this.bottomSheetCtrl,
bottomSheetLayout: this.BottomSheetLayout.bind(this),
backgroundLayout: this.BackgroundLayout.bind(this)
});
API Reference
Components
| Name | Description | Main Parameters | Required | HarmonyOS Support |
|---|---|---|---|---|
| BottomSheetComponent | Basic bottom sheet component with drag interaction and dynamic background transparency | bottomSheetController: BottomSheetCtrl bottomSheetLayout: @BuilderParam backgroundLayout: @BuilderParam |
Yes | Yes |
| MenuSheetComponent | Menu bottom sheet component supporting list and grid display modes | title: string menus: MenuItem[] menuType: MenuType (LIST/GRID) onMenuItemClick: (item: MenuItem) => void bottomSheetController?: BottomSheetController backgroundLayout?: @BuilderParam |
No | Yes |
| ImagePickerSheetComponent | Image picker bottom sheet component supporting camera, album, and image selection | title: string imageItemView: string[] onImageItemClick: (item: string) => void onCameraPickerClick: () => void onImagePickerClick: () => void bottomSheetController?: BottomSheetController backgroundLayout?: @BuilderParam |
No | Yes |
| IntentPickerSheetComponent | Intent picker bottom sheet component for displaying app list for user selection | title: string apps: APPInfo[] onAppPickedClick: (item: APPInfo) => void bottomSheetController?: BottomSheetController backgroundLayout?: @BuilderParam |
No | Yes |
Controllers
| Name | Description | Method | Description | HarmonyOS Platform Support |
|---|---|---|---|---|
| BottomSheetCtrl | Bottom sheet controller | toTop(): void | Expand the bottom sheet to the top | Yes |
| toBottom(): void | Collapse the bottom sheet to the bottom | |||
| toCenter(): void | Move the bottom sheet to the center |
About Obfuscation
- For code obfuscation, please see Introduction to Code Obfuscation.
- If you want the bottomsheet library to be excluded from obfuscation, you need to add exclusion rules in the obfuscation-rules.txt configuration file.
-keep
./oh_modules/@ohos/bottomsheet
Directory Structure
/bottomsheet # Project root directory
├── entry # Example code folder
├── library # bottomsheet library folder
│ └─ src/main/ets # Core code
│ └─ components # Core components
│ └─ BottomSheetComponent.ets
│ └─ BottomSheetController.ets
│ └─ MenuSheetComponent.ets
│ └─ IntentPickerSheetComponent.ets
│ └─ ImagePickerSheetComponent.ets
├── README.md # Installation and usage guide
├── README_zh.md # Installation and usage guide (Chinese)
Contributing
If you find any issues during usage, you are welcome to submit Issues. Of course, Pull Requests are also highly appreciated.
License
This project is licensed under the BSD-3-Clause.