mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00

Use new stencil APIs to allow ionic elements to be reused once removed from the DOM. fixes #18843 fixes #17344 fixes #16453 fixes #15879 fixes #15788 fixes #15484 fixes #17890 fixes #16364
ion-backdrop
Backdrops are full screen components that overlay other components. They are useful behind components that transition in on top of other content and can be used to dismiss that component.
Usage
Angular
<!-- Default backdrop -->
<ion-backdrop></ion-backdrop>
<!-- Backdrop that is not tappable -->
<ion-backdrop tappable="false"></ion-backdrop>
<!-- Backdrop that is not visible -->
<ion-backdrop visible="false"></ion-backdrop>
<!-- Backdrop with propagation -->
<ion-backdrop stopPropagation="false"></ion-backdrop>
<!-- Backdrop that sets dynamic properties -->
<ion-backdrop
[tappable]="enableBackdropDismiss"
[visible]="showBackdrop"
[stopPropagation]="shouldPropagate">
</ion-backdrop>
import { Component } from '@angular/core';
@Component({
selector: 'backdrop-example',
templateUrl: 'backdrop-example.html',
styleUrls: ['./backdrop-example.css'],
})
export class BackdropExample {
backdropDismiss = false;
showBackdrop = false;
shouldPropagate = false;
}
Javascript
<!-- Default backdrop -->
<ion-backdrop></ion-backdrop>
<!-- Backdrop that is not tappable -->
<ion-backdrop tappable="false"></ion-backdrop>
<!-- Backdrop that is not visible -->
<ion-backdrop visible="false"></ion-backdrop>
<!-- Backdrop with propagation -->
<ion-backdrop stop-propagation="false"></ion-backdrop>
<!-- Backdrop that sets dynamic properties -->
<ion-backdrop id="customBackdrop"></ion-backdrop>
var backdrop = document.getElementById('customBackdrop');
backdrop.visible = false;
backdrop.tappable = false;
backdrop.stopPropagation = false;
React
import React from 'react';
import { IonBackdrop, IonContent } from '@ionic/react';
export const BackdropExample: React.FC = () => (
<IonContent>
{/*-- Default backdrop --*/}
<IonBackdrop />
{/*-- Backdrop that is not tappable --*/}
<IonBackdrop tappable={false} />
{/*-- Backdrop that is not visible --*/}
<IonBackdrop visible={false} />
{/*-- Backdrop with propagation --*/}
<IonBackdrop stopPropagation={false} />
<IonBackdrop tappable={true} visible={true} stopPropagation={true} />
</IonContent>
);
Vue
<template>
<!-- Default backdrop -->
<ion-backdrop></ion-backdrop>
<!-- Backdrop that is not tappable -->
<ion-backdrop tappable="false"></ion-backdrop>
<!-- Backdrop that is not visible -->
<ion-backdrop visible="false"></ion-backdrop>
<!-- Backdrop with propagation -->
<ion-backdrop stopPropagation="false"></ion-backdrop>
<!-- Backdrop that sets dynamic properties -->
<ion-backdrop
:tappable="enableBackdropDismiss"
:visible="showBackdrop"
:stopPropagation="shouldPropagate">
</ion-backdrop>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component()
export default class Example extends Vue {
backdropDismiss = false;
showBackdrop = false;
shouldPropagate = false;
}
</script>
Properties
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
stopPropagation |
stop-propagation |
If true , the backdrop will stop propagation on tap. |
boolean |
true |
tappable |
tappable |
If true , the backdrop will can be clicked and will emit the ionBackdropTap event. |
boolean |
true |
visible |
visible |
If true , the backdrop will be visible. |
boolean |
true |
Events
Event | Description | Type |
---|---|---|
ionBackdropTap |
Emitted when the backdrop is tapped. | CustomEvent<void> |
Dependencies
Used by
Graph
graph TD;
ion-action-sheet --> ion-backdrop
ion-alert --> ion-backdrop
ion-loading --> ion-backdrop
ion-menu --> ion-backdrop
ion-modal --> ion-backdrop
ion-picker --> ion-backdrop
ion-popover --> ion-backdrop
style ion-backdrop fill:#f9f,stroke:#333,stroke-width:4px
Built with StencilJS