import { Backdrop, Button, Stack, Text } from "@vortexlabs/vortex-native";
import { useState } from "react";
export const BackdropTicketExample = () => {
const [open, setOpen] = useState(false);
return (
<>
<Button onPress={() => setOpen(true)}>View ticket</Button>
<Backdrop active={open} onClose={() => setOpen(false)} attributes={{ "aria-label": "Ticket" }}>
<Stack padding={4} gap={3} backgroundColor="surface" borderRadius="md">
<Text>Seat 12A</Text>
<Button onPress={() => setOpen(false)}>Close ticket</Button>
</Stack>
</Backdrop>
</>
);
};Features
- Blocks presses from reaching the screen behind the overlay.
- Supports dim, transparent, and blurred backdrops.
- Provides open and close transition callbacks.
Backdrop Presses
Set closeOnBackdropClick={false} to keep the overlay open when someone taps the dimmed area. Android Back still calls onClose.
import { Backdrop, Button, Stack, Text } from "@vortexlabs/vortex-native";
import { useState } from "react";
export const PickupCode = () => {
const [open, setOpen] = useState(false);
return (
<>
<Button onPress={() => setOpen(true)}>Show pickup code</Button>
<Backdrop active={open} closeOnBackdropClick={false} onClose={() => setOpen(false)}>
<Stack padding={4} gap={2} backgroundColor="surface" borderRadius="md">
<Text>Pickup code: B27</Text>
<Button onPress={() => setOpen(false)}>Done</Button>
</Stack>
</Backdrop>
</>
);
};Transparency
Set transparent to keep the screen visible while blocking touches behind the overlay.
import { Backdrop, Button, Stack, Text } from "@vortexlabs/vortex-native";
import { useState } from "react";
export const BackdropTransparentExample = () => {
const [open, setOpen] = useState(false);
return (
<>
<Button onPress={() => setOpen(true)}>View ticket</Button>
<Backdrop active={open} onClose={() => setOpen(false)} attributes={{ "aria-label": "Ticket" }} transparent>
<Stack padding={4} gap={3} backgroundColor="surface" borderRadius="md">
<Text>Seat 12A</Text>
<Button onPress={() => setOpen(false)}>Close ticket</Button>
</Stack>
</Backdrop>
</>
);
};Blur
Set blurred and supply a blur adapter. Without an adapter, or with Reduce Transparency enabled, the backdrop stays dim.
<Backdrop active={open} blurred onClose={close} attributes={{ "aria-label": "Boarding pass" }}>
<Stack backgroundColor="surface" borderRadius="md" padding={4} gap={3}>
<Text weight="medium">Sydney to Melbourne</Text>
<Text>Gate 12 · Seat 4A</Text>
<Button onPress={close}>Close pass</Button>
</Stack>
</Backdrop>Accessibility
Description
Set
initialFocusRef to move screen reader focus to a particular element when the backdrop opens.Set
returnFocusRef to move focus back to the opening control after dismissal.