Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
Custom styling for Tiktok Embed in NextJS

I'm building a site that can use Tiktok oEmbed, so far so good but I have a problem that how can I custom style it like the body background is transparent?

I had already added styles, MutationObserver to detect change but it not working because all of my styles are overwritten by the embed.js of Tiktok. Can anybody help me in this case? Thank you.

.feature-frame {
  padding: 8px;

  iframe {
    min-width: initial !important;
    body {
      background-color: transparent !important;
      & * {
        color: $white !important;
      }
    }
  }

  blockquote {
    margin: 0;
    min-width: initial !important;
    body {
      background-color: transparent !important;
      & * {
        color: $white !important;
      }
    }
  }
}

const ObserverConfig = {
  childList: true,
  attributes: true,
  subtree: true,
};
const ref = useRef(null);

function mutationCallback(mutationList: MutationRecord[]) {
  // Get the iframe from the mutation that has added it
  const iframeAdded = mutationList.reduce<Node | undefined>((acc, curr) => {
    const iframe = Array.from(curr.addedNodes).find(
      (node) => node.nodeName === "IFRAME"
    ) as HTMLIFrameElement;

    if (iframe) {
      acc = iframe;
    }
    return acc;
  }, undefined);

  if (iframeAdded) {
    iframeAdded.addEventListener("load", () => {
      // Do something
    });
  }
  mutationList.forEach(function (mutation) {
    // Do something
  });
}

useEffect(() => {
  /**
   * MutationObserver:
   * https://stackoverflow.com/questions/3219758/detect-changes-in-the-dom
   */
  if (!("MutationObserver" in window)){
    // Window load
  }

  /**
   * TODO: Check bugs for MutationObserver
   * https://caniuse.com/#feat=mutationobserver
   */
  const elem = ref.current;

  const observer = new MutationObserver(mutationCallback);

  if (elem) {
    observer.observe(elem!, ObserverConfig);
  }
  return () => {
    observer.disconnect();
  };
}, [ref]);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The iframe embed is cross domain, you cannot influence its background color as its set by Tiktok on their body - unless Tiktok provides a parameter to style elements within that you can configure, it would not be possible to modify contents within a third party iframe.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda