5

How can I add an "Edit on CodeSandbox" button in the Stack Overflow editor?

Here's an example of a response with such a button.

2
  • 2
    Note that the presence of such a button does not mean the code does not need to be copied to Stack Overflow. See How to Ask, "If it is possible to create a live example of the problem that you can link to (for example, on sqlfiddle.com or jsbin.com) then do so - but also copy the code into the question itself." Feb 16, 2022 at 14:37
  • Also note that there's no special magic going on here– that "button" is just an image, which can then be made a link to CodeSandbox (or anything else really).
    – zcoop98
    Feb 16, 2022 at 16:01

1 Answer 1

10

Edit 50069724/how-to-add-multiple-material-ui-palette-colors

In the top right of the CodeSandbox toolbar, you have a button labeled "Embed". You click it, then you go to the Other Sharing Options, you copy Markdown and add it to your post on Stack Overflow.

Flow: Embed -> Other Sharing Options -> and you copy Markdown.

2
  • 1
    One problem with their embed code is it strips the specific file from the URL. If you wanted to link directly, you can just add &file=/main.js (for example)
    – Phil
    Feb 16, 2022 at 23:37
  • When I put the iframe in my post it doesn't show up. Do I need to wrap it in anything?
    – Sendai
    Feb 22 at 4:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .