Quick Facts
- Category: Web Development
- Published: 2026-05-04 07:36:57
- 7 Critical Facts About Google's Gemini CLI Patch: From CVSS 10 to Cursor Flaws
- How to Become a NASA Astronaut and Prepare for a Spaceflight Mission: A Step-by-Step Guide Inspired by Dr. Anil Menon
- Python 3.15 Alpha 4: Unveiling New Features and Improvements
- Venus Volcanic Activity: Hawaiian Eruption Provides New Clues for Scientists
- 10 Critical Facts About Alzheimer’s Drugs and the Risks You Should Know
Astro offers two primary ways to supercharge your Markdown: using MDX or a dedicated Markdown component. This guide focuses on the latter—the Markdown component—which simplifies content creation by reducing HTML markup and automatically handling typographic symbols like smart quotes. Below, we answer common questions about why and how to use it effectively.
Why use a Markdown component in Astro?
The Markdown component streamlines writing by cutting down on repetitive HTML tags. Instead of manually adding <p>, <strong>, <ul>, and <a>, you write pure Markdown, and the component converts it into proper HTML. It also automatically transforms typographic symbols—like turning straight quotes (‘) into curly opening/closing quotes (‘’). This saves time and keeps your code clean. For example, a card that previously required multiple opening and closing tags can now be written as a simple Markdown block inside a <div>. Check the installation section to get started.

How do you install the Markdown component?
In Astro’s early days, the <Markdown> component came built-in. However, starting with version 1 it moved to a separate plugin, and by version 3 it was fully removed. To bring it back, install the @splendidlabz/astro package from the official documentation. Afterwards, import it in your file: import { Markdown } from '@splendidlabz/astro'. Then wrap your Markdown text in <Markdown> ... </Markdown> tags. The component will handle the conversion. Remember to add the comment <!-- prettier-ignore --> before the component if you use Prettier, to avoid formatting issues.
Does the component respect existing indentation?
Yes, the Markdown component automatically detects the indentation level of your content and outputs clean HTML without wrapping it in <pre> or <code> tags. For example, if you nest a Markdown block inside two <div>s, each paragraph will still be correctly indented in the final HTML. This means you can write naturally without worrying about extra whitespace or markup. The component intelligently strips the leading whitespace from each line, so you get exactly the paragraphs you intended. See the original article’s example with nested <div>s for a practical demonstration.
What is the inline option and when should you use it?
The inline option tells the component not to generate paragraph tags around the content. This is useful when you want to embed Markdown inside an inline element like a heading or a span. For instance, inside a <h2> tag, you can write <Markdown inline> Ain't this cool? </Markdown> and the output will be plain text without <p> wrappers. This preserves the heading’s semantic structure while still allowing Markdown syntax like smart quotes or bold text. Use it sparingly for small snippets that need inline formatting.
What gotchas should you watch out for?
The main gotcha is Prettier or other formatters interfering with the Markdown block’s formatting. The solution is to add <!-- prettier-ignore --> right before the <Markdown> component. This tells Prettier not to reflow the content, which is critical because Markdown relies on specific spacing and indentation. Also, ensure you import the correct package version that works with your Astro version. Finally, remember that the component only handles a subset of Markdown—complex HTML or frontmatter inside the block may not render as expected. Stick to basic elements (headings, lists, links, bold/italic) for best results.
When should you choose MDX over this component?
MDX allows you to mix Markdown with interactive JSX components, making it ideal for dynamic content like charts, forms, or live examples. The Markdown component, on the other hand, is purely static—great for typographic polish and reducing markup overhead. If your content requires custom React or Astro components embedded inline, go with MDX. If you just want cleaner Markdown with smart quotes and indentation support, stick with the dedicated component. Both can coexist in the same project, so you’re not forced to choose one exclusively.