Skip to content

Instantly share code, notes, and snippets.

@iambriansreed
Created October 21, 2024 18:46
Show Gist options
  • Select an option

  • Save iambriansreed/4ed8329494224eb68a28dd82108d63e5 to your computer and use it in GitHub Desktop.

Select an option

Save iambriansreed/4ed8329494224eb68a28dd82108d63e5 to your computer and use it in GitHub Desktop.
export default function CustomAddon({ children, id }: PropsWithChildren<{ id: string }>) {
const element =
document.getElementById(id) ||
(() => {
const addonsContainer = document.querySelector(".ladle-addons > ul");
const element = document.createElement("li");
element.id = id;
addonsContainer?.prepend(element);
return element;
})();
return <>{createPortal(children, element)}</>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment