Choose Theme

Beautiful Markdown Styling

· 3 min read · #CSS #Design #Tailwind
--

Markdown is wonderful for writing content, but default styles can be… bland. Let’s explore how to make your markdown content truly shine with Tailwind Typography.

The Typography Plugin

The @tailwindcss/typography plugin provides a set of prose classes that style your markdown beautifully with sensible defaults.

Terminal window
npm install -D @tailwindcss/typography

Then add it to your Tailwind config:

tailwind.config.js
module.exports = {
plugins: [
require('@tailwindcss/typography'),
],
}

Basic Usage

Simply wrap your content in a prose class:

<article class="prose lg:prose-xl">
{{ content }}
</article>

Customizing Typography

The real power comes from customization. Here’s how you can tailor the typography to match your brand:

Color Schemes

You can customize colors for different elements:

// Example configuration
typography: {
DEFAULT: {
css: {
'--tw-prose-body': theme('colors.zinc.700'),
'--tw-prose-headings': theme('colors.zinc.900'),
'--tw-prose-links': theme('colors.primary.DEFAULT'),
'--tw-prose-code': theme('colors.zinc.900'),
}
}
}

Links should be interactive and inviting. Here’s a beautiful link example that shows how subtle styling can make a big difference.

For inline code like const example = true, we want it to stand out without being jarring. A subtle background and rounded corners work wonders.

Design principle: Good typography is invisible. It should enhance readability without drawing attention to itself.

Headings Hierarchy

Proper heading hierarchy is crucial for both readability and SEO. Let’s look at different levels:

This is an H3

Good for sub-sections within your content.

This is an H4

Perfect for detailed breakdowns.

This is an H5

For when you need even more granularity.

Lists and Structure

Markdown supports both ordered and unordered lists:

Unordered lists for non-sequential items:

  • Design with intention
  • Code with purpose
  • Ship with confidence

Ordered lists for step-by-step content:

  1. Plan your content structure
  2. Write in markdown
  3. Style with Tailwind
  4. Deploy and share

Nested Lists

You can nest lists for complex information:

  • Frontend Technologies
    • React
      • State management with hooks
      • Component composition
    • Vue
      • Reactive data
      • Single file components
  • Backend Technologies
    • Node.js
    • Python
    • Go

Code Examples

Different programming languages, all beautifully highlighted:

TypeScript

interface User {
id: string;
name: string;
email: string;
}
async function fetchUser(id: string): Promise<User> {
const response = await fetch(`/api/users/${id}`);
return response.json();
}

CSS

.gradient-text {
background: linear-gradient(
to right,
#4d9375,
#3a7a5e
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}

Python

def fibonacci(n):
"""Calculate fibonacci number recursively"""
if n <= 1:
return n
return fibonacci(n - 1) + fibonacci(n - 2)
# Generate first 10 fibonacci numbers
fib_sequence = [fibonacci(i) for i in range(10)]
print(fib_sequence)

Tables

Tables can present data clearly:

FeatureBasicProEnterprise
Users550Unlimited
Storage10GB100GB1TB
SupportEmailPriorityDedicated
Price$10/mo$50/moCustom

Blockquotes

Sometimes you need to highlight important information:

The details are not the details. They make the design.

— Charles Eames

Or share code wisdom:

Premature optimization is the root of all evil.

— Donald Knuth

Final Thoughts

Great typography makes content:

  1. Readable - Easy on the eyes
  2. Scannable - Clear hierarchy
  3. Accessible - Works for everyone
  4. Beautiful - Pleasure to read

With Tailwind Typography, you get all of this out of the box, with endless customization possibilities.


Remember: Content is king, but typography is the crown.