"" ""

Embed Tritium as an HTML Element


Embed the Tritium Legal IDE in your existing web platform with a small code snippet.

<input type="file">
<canvas id="tritium-canvas"></canvas>

<script type="module">
    const tritium = await import("https://tritium.legal/static/init.js");

    // Attach a save handler to receive saved files.
    window.tritium.set_save_handler((file) => {
        window.alert(`Saving ${file.size} bytes to: ${file.name}`);
    });

    // Open files in the IDE or by passing a `File` object to `open_file`.
    const input = document.querySelector("input[type=file]");
    input.addEventListener("change", async () => {
        await tritium.open_file(input.files?.[0]);
    });
    
    // Start Tritium with no arguments for launch view.
    tritium.start();
</script>

That's it! The snippet gives you this: