# Popup Control

Name

Type

Default Value

Description

bindPopup

{

show: boolean,

popup: {

message: string,

placementOnTop: boolean,

primaryButton?: {

value: string,

action: ()=>void

},

secondaryButton?:{

value: string,

action: () =>void

},

onStateChange?: (isVisible: boolean) => void

}

}

-

show: whether to display the current popup message. The default value is false.

message: content of the popup message.

placementOnTop: whether to display the popup message above the component. The default value is false.

primaryButton: first button.

secondaryButton: second button.

onStateChange: callback for the popup window status change event. The argument is the visibility status of the current popup window.

## Example ``` @Entry @Component struct PopupExample { @State noHandlePopup: boolean = false @State handlePopup: boolean = false build() { Column({ space: 160 }) { Button('no handle popup') .onClick(() => { this.noHandlePopup = !this.noHandlePopup }) .bindPopup(this.noHandlePopup, { message: 'content content content ...', placementOnTop: false, onStateChange: (e) => { console.info(e.isVisible.toString()) if (!e.isVisible) { this.noHandlePopup = false } } }) Button('with handle popup') .onClick(() => { this.handlePopup = !this.handlePopup }) .bindPopup(this.handlePopup, { message: 'content content content ...', placementOnTop: true, secondaryButton: { value: 'ok', action: () => { this.handlePopup = !this.handlePopup console.info('secondaryButton click') } }, onStateChange: (e) => { console.info(e.isVisible.toString()) } }) }.width('100%').padding({ top: 5 }) } } ``` ![](figures/popup.gif)