Skip to content

Instantly share code, notes, and snippets.

@ajtransak
Last active December 20, 2024 13:05
Show Gist options
  • Save ajtransak/bd6d219e9f0caf090fbdb8066ae154fb to your computer and use it in GitHub Desktop.
Save ajtransak/bd6d219e9f0caf090fbdb8066ae154fb to your computer and use it in GitHub Desktop.
Customising the Widget using containerId - Transak SDK
import React, { useEffect } from "react";
import { Transak } from "@transak/transak-sdk";
import Stack from "@mui/material/Stack";
import Box from "@mui/material/Box";
import config from "../config";
// add the following lines to your css file to target the Transak Widget Container
// #transakMount {
// height: 650px;
// width: 400px;
// border: 1px solid #1461da;
// }
export default function ContainerIdSDK() {
const transakConfig = {
apiKey: config.apiKeyGlobalStaging,
environment: Transak.ENVIRONMENTS.STAGING,
containerId: "transakMount",
};
useEffect(() => {
const transak = new Transak(transakConfig);
transak.init();
return () => {
transak.close();
};
}, []);
return (
<Stack direction="column" alignItems="center" sx={{ p: "4px" }}>
<Box
sx={{
width: "100%",
minHeight: "100px",
p: "16px",
border: "1px dashed grey",
}}
>
<Stack direction="column" justifyContent="center" alignItems="center">
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
flexDirection: "column",
}}
>
<div id="transakMount" />
</div>
</Stack>
</Box>
</Stack>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment