<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr" -->

---
title: Introducing <mermaid-element>, a custom element to...
description: A developer built <mermaid-element>, a zero-config, dependency-free web component that renders Mermaid diagrams inside an open Shadow DOM. It auto-loads...
canonical: https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Introducing <mermaid-element>, a custom element to display Mermaid diagrams | daily.dev
og:description: A developer built <mermaid-element>, a zero-config, dependency-free web component that renders Mermaid diagrams inside an open Shadow DOM. It auto-loads...
og:url: https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr
og:image: https://api.daily.dev/og/posts/N0bvSFcXR.png
og:image:alt: Introducing <mermaid-element>, a custom element to display Mermaid diagrams
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Introducing <mermaid-element>, a custom element to display Mermaid diagrams

**[Bram.us](https://daily.dev/sources/bram)** · 2 min read · 12 upvotes · 1 comments

## Summary

A developer built <mermaid-element>, a zero-config, dependency-free web component that renders Mermaid diagrams inside an open Shadow DOM. It auto-loads Mermaid version 12 on demand via jsDelivr, supports pinning a different Mermaid version or custom endpoint through a mermaid attribute, and caches downloads in memory so multiple diagrams on a page only fetch Mermaid once. Apps that already bundle Mermaid can assign their own copy to MermaidElement.defaultMermaid to skip CDN requests. It's available on npm along with an interactive playground and documentation site.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.bram.us/2026/09/10/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams>

## Questions this post answers

### Is there a custom HTML element to render Mermaid diagrams without writing JavaScript?

Yes, a web component called <mermaid-element> renders Mermaid diagrams declaratively inside an open Shadow DOM. It is zero-config and dependency-free: import the script as a module and place Mermaid syntax directly inside the tag. It defaults to loading Mermaid version 12 on demand from jsDelivr and is also published on npm.

_Developers evaluating lightweight diagram components can track web component releases like this one on daily.dev._

### How do I use a specific version of Mermaid with the mermaid-element web component instead of the default?

Set the mermaid attribute on the <mermaid-element> tag to a version string, such as mermaid="10.9.8", or to a full URL pointing at a custom Mermaid build. By default the component loads Mermaid version 12 automatically from jsDelivr, but this attribute overrides that behavior for pinning or custom endpoints.

_Anyone configuring diagram tooling can keep tabs on component options like this via daily.dev._

### How does the mermaid-element web component avoid downloading Mermaid multiple times on a page with several diagrams?

It uses a built-in in-memory cache so that when multiple diagrams appear on the same page, Mermaid downloads only once and is reused across all instances. Additionally, if an app already bundles Mermaid itself, it can assign its own copy to MermaidElement.defaultMermaid to skip external CDN requests entirely.

_Developers optimizing page load for diagram-heavy sites follow practical component patterns like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@markojr** · 2 upvotes

> behold .. a single dev comes up with something incredibly usefull yet here is Atlassian a multi milion $ company and they still did not manage to add mermaid into their stupid paid solutions

## Similar posts on daily.dev

- [This tool replaced every diagramming app I've ever used](https://daily.dev/posts/this-tool-replaced-every-diagramming-app-i-ve-ever-used-bp8r9djhw) · XDA Developers · 1 upvotes · 3 comments
- [lukilabs/beautiful-mermaid](https://daily.dev/posts/lukilabs-beautiful-mermaid-mnq05qf1z) · Hacker News · 6 upvotes · 0 comments
- [Pele – Mermaid diagrams as themeable SVG](https://daily.dev/posts/pele-mermaid-diagrams-as-themeable-svg-tsmiyab5v) · Hacker News · 274 upvotes · 8 comments
- [Diagrams as Code: Mermaid Support on the new Foojay](https://daily.dev/posts/diagrams-as-code-mermaid-support-on-the-new-foojay-onkdjmmjl) · Foojay.io · 2 upvotes · 0 comments
- [Animated, interactive And visuals Mermaid Diagrams](https://daily.dev/posts/animated-interactive-and-visuals-mermaid-diagrams-dvfqnnec7) · Hacker News · 1 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#html](https://daily.dev/tags/html), [#web-components](https://daily.dev/tags/web-components)

[View this post on daily.dev](https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Introducing \u003cmermaid-element\u003e, a custom element to display Mermaid diagrams","url":"https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr"},"datePublished":"2026-09-10T12:51:10.530Z","dateModified":"2026-09-14T07:09:34.936Z","description":"A developer built \u003cmermaid-element\u003e, a zero-config, dependency-free web component that renders Mermaid diagrams inside an open Shadow DOM. It auto-loads...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f13f90164197465e4d17e3037f95cd9a?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f13f90164197465e4d17e3037f95cd9a?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Bram.us","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Bram.us","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/3db2116954be44df873ec24cf0e03d14","url":"https://daily.dev/sources/bram"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":12},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"webdev,javascript,html,web-components","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Bram.us","item":"https://daily.dev/sources/bram"},{"@type":"ListItem","position":3,"name":"Introducing \u003cmermaid-element\u003e, a custom element to display Mermaid diagrams"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr","comment":[{"@type":"Comment","text":"behold … a single dev comes up with something incredibly usefull yet here is Atlassian a multi milion $ company and they still did not manage to add mermaid into their stupid paid solutions","datePublished":"2026-09-10T13:07:49.925Z","url":"https://daily.dev/posts/N0bvSFcXR#c-mXoNqDKY7","author":{"@type":"Person","name":"Marko Jozic-Reyes","url":"https://daily.dev/markojr","image":"https://media.daily.dev/image/upload/s--TvIfWcng--/f_auto/v1769558803/avatars/avatar_x9cfuU5ai02W3BPEbroGK?_a=BAMAMiiu0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/introducing-mermaid-element-a-custom-element-to-display-mermaid-diagrams-n0bvsfcxr#faq","mainEntity":[{"@type":"Question","name":"Is there a custom HTML element to render Mermaid diagrams without writing JavaScript?","acceptedAnswer":{"@type":"Answer","text":"Yes, a web component called \u003cmermaid-element\u003e renders Mermaid diagrams declaratively inside an open Shadow DOM. It is zero-config and dependency-free: import the script as a module and place Mermaid syntax directly inside the tag. It defaults to loading Mermaid version 12 on demand from jsDelivr and is also published on npm. Developers evaluating lightweight diagram components can track web component releases like this one on daily.dev."}},{"@type":"Question","name":"How do I use a specific version of Mermaid with the mermaid-element web component instead of the default?","acceptedAnswer":{"@type":"Answer","text":"Set the mermaid attribute on the \u003cmermaid-element\u003e tag to a version string, such as mermaid=\"10.9.8\", or to a full URL pointing at a custom Mermaid build. By default the component loads Mermaid version 12 automatically from jsDelivr, but this attribute overrides that behavior for pinning or custom endpoints. Anyone configuring diagram tooling can keep tabs on component options like this via daily.dev."}},{"@type":"Question","name":"How does the mermaid-element web component avoid downloading Mermaid multiple times on a page with several diagrams?","acceptedAnswer":{"@type":"Answer","text":"It uses a built-in in-memory cache so that when multiple diagrams appear on the same page, Mermaid downloads only once and is reused across all instances. Additionally, if an app already bundles Mermaid itself, it can assign its own copy to MermaidElement.defaultMermaid to skip external CDN requests entirely. Developers optimizing page load for diagram-heavy sites follow practical component patterns like this on daily.dev."}}]}
```

