Responsive Popover

Overwriting the default Popover positioning styles on small screens using the updatePosition prop.

Open preview in a new tab
Edit withViteNext.js
import "./style.css";
import * as Ariakit from "@ariakit/react";
import useMedia from "./use-media.js";
export default function Example() {
const isLarge = useMedia("(min-width: 640px)", true);
const popover = Ariakit.usePopoverStore();
const updatePosition = () => {
const { popoverElement, mounted } = popover.getState();
if (!popoverElement) return;
Object.assign(, {
display: mounted ? "block" : "none",
position: "fixed",
width: "100%",
bottom: "0px",
padding: "12px",
return (
<Ariakit.PopoverDisclosure className="button">
Accept invite
backdrop={isLarge ? false : <div className="backdrop" />}
updatePosition={isLarge ? undefined : updatePosition}
{isLarge && <Ariakit.PopoverArrow className="arrow" />}
<Ariakit.PopoverHeading className="heading">
Team meeting
We are going to discuss what we have achieved on the project.
<p>12 Jan 2022 18:00 to 19:00</p>
<p>Alert 10 minutes before start</p>
<Ariakit.Button className="button">Accept</Ariakit.Button>

Follow updates

Join 1,000+ subscribers and receive monthly updates with the latest improvements on Examples.

Read latest issue

No Spam. Unsubscribe at any time.