I'm working on a React project using Ant Design and I need to make a modal full-screen when viewed on an iPad. I've tried several approaches to achieve this, but I'm still facing issues with getting the modal to properly scale to full-screen on iPad devices.
// ... imports
const StyledModal = styled(Modal)`
.ant-modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100vw;
height: 100vh;
}
`;
function CustomListTable({ dataList, query, itemId }: { dataList: DataType[]; query: string; itemId: string }) {
const [data, setData] = useState<DataType[]>([]);
const [isModalVisible, setModalVisible] = useState(false);
const [selectedItem, setSelectedItem] = useState<DataType | null>(null);
const router = useRouter();
useEffect(() => {
// Filtering logic
if (itemId) {
...
}
}, [dataList, query, itemId]);
const handleItemClick = (item: DataType) => {
...
};
const handleCloseModal = () => {
...
};
// Columns setup for CustomTable
const columns = [
// ... column definitions
];
return (
<>
<CustomTable data={data} columns={columns} />
<StyledModal open={isModalVisible} onCancel={handleCloseModal} footer={null}>
{selectedItem && <FullScreenComponent item={selectedItem} />}
</StyledModal>
</>
);
}
export default CustomListTable;
Try this
You can use the
useBreakpointto make modal fullscreen in iPad onlyhttps://ant.design/components/grid#components-grid-demo-usebreakpoint
https://ant.design/components/layout#breakpoint-width
Full code:
https://codesandbox.io/p/sandbox/customize-footer-buttons-props-antd-5-13-3-forked-jqpfjz?file=%2Fdemo.tsx%3A20%2C1-20%2C11
Preview: https://jqpfjz.csb.app/