Skip to content

Markdown ​

The Markdown component renders Markdown in the terminal with headings, lists, code blocks, tables, and more. Use props to style each element.

Basic Usage ​

vue
<template>
  <Markdown content="# Hello World\n\nThis is **bold** and _italic_ text." />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Props ​

Markdown colors are theme-aware. They default to theme.components.markdown.* and fall back to the legacy defaults below when the theme doesn’t define them.

NameTypeDefaultDescription
contentstring''Markdown content to render
h1ColorstringthemeColor for H1 headings
h2ColorstringthemeColor for H2 headings
h3ColorstringthemeColor for H3 headings
h4ColorstringthemeColor for H4 headings
h5ColorstringthemeColor for H5 headings
h6ColorstringthemeColor for H6 headings
codeColorstringthemeCode text color
codeBgstringthemeCode background color
linkColorstringthemeLink color
emphasisColorstringthemeEmphasis (italic) color
strongColorstringthemeStrong (bold) color
blockquoteColorstringthemeBlockquote text color
blockquoteBorderColorstringthemeBlockquote border color
listBulletColorstringthemeList bullet color
listNumberColorstringthemeList number color
hrColorstringthemeHorizontal rule color
hrCharstring'─'Horizontal rule character
hrLengthnumber60Horizontal rule length
tableHeaderColorstringthemeTable header color
tableBorderColorstringthemeTable border color
colorstring-Base text color
bgstring-Background color
boldbooleanfalseBold text
italicbooleanfalseItalic text
dimbooleanfalseDimmed text

Layout Props (Box Props) ​

NameTypeDefaultDescription
flexnumber | stringnullFlex shorthand when inside a flex container
flexGrownumbernullFlex grow factor
flexShrinknumbernullFlex shrink factor
flexBasisnumber | stringnullFlex basis
alignSelfstringnullSelf alignment: 'auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline'
widthnumber | stringnullWidth (chars or %)
heightnumber | stringnullHeight (rows)
minWidthnumbernullMinimum width
maxWidthnumbernullMaximum width
minHeightnumbernullMinimum height
maxHeightnumbernullMaximum height
paddingnumber0Padding
paddingLeftnumbernullLeft padding
paddingRightnumbernullRight padding
paddingTopnumbernullTop padding
paddingBottomnumbernullBottom padding
marginnumbernullMargin
marginLeftnumbernullLeft margin
marginRightnumbernullRight margin
marginTopnumbernullTop margin
marginBottomnumbernullBottom margin

Basic Markdown Elements ​

Headings ​

vue
<template>
  <Markdown content="# Heading 1\n## Heading 2\n### Heading 3" />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Paragraphs and Text Styling ​

vue
<template>
  <Markdown content="This is a paragraph with **bold**, _italic_, and `code` text." />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Lists ​

vue
<template>
  <Markdown content="- Item 1\n- Item 2\n- Item 3\n\n1. First\n2. Second\n3. Third" />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Code Blocks ​

vue
<template>
  <Markdown content="```javascript\nconst x = 10;\nconsole.log(x);\n```" />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Tables ​

vue
<template>
  <Markdown content="| Name | Age |\n|------|-----|\n| John | 30 |\n| Jane | 25 |" />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Blockquotes ​

vue
<template>
  <Markdown content="> This is a blockquote.\n> It can span multiple lines." />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Horizontal Rules ​

vue
<template>
  <Markdown content="Content above\n\n---\n\nContent below" />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Custom Styling ​

Heading Colors ​

vue
<template>
  <Markdown
    content="# Red Heading\n## Green Subheading"
    h1Color="red"
    h2Color="green"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Code Block Styling ​

vue
<template>
  <Markdown
    content="```\ncode here\n```"
    codeColor="magenta"
    codeBg="black"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>
vue
<template>
  <Markdown
    content="[Visit Vuetty](https://vuetty.js.org)"
    linkColor="cyan"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

List Styling ​

vue
<template>
  <Markdown
    content="- Item 1\n- Item 2"
    listBulletColor="yellow"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Width and Layout ​

Fixed Width ​

vue
<template>
  <Markdown
    content="# Title\n\nContent here"
    :width="50"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Auto Width ​

vue
<template>
  <Markdown
    content="# Title\n\nContent here"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

With Padding ​

vue
<template>
  <Markdown
    content="# Title\n\nContent here"
    :padding="2"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Usage with Other Components ​

With Box ​

vue
<template>
  <Box :padding="1" color="cyan">
    <Markdown content="# Documentation\n\nThis is markdown inside a box." />
  </Box>
</template>

<script setup>
import { Box, Markdown } from 'vuetty';
</script>

With Row and Col ​

vue
<template>
  <Row gap="2">
    <Col flex="1">
      <Markdown content="# Left Column\n\nContent here" />
    </Col>
    <Col flex="1">
      <Markdown content="# Right Column\n\nMore content" />
    </Col>
  </Row>
</template>

<script setup>
import { Row, Col, Markdown } from 'vuetty';
</script>

Common Patterns ​

Documentation Page ​

vue
<template>
  <Markdown :content="docs" :padding="1" />
</template>

<script setup>
import { Markdown } from 'vuetty';

const docs = `# Getting Started

## Installation

\`\`\`bash
npm install vuetty
\`\`\`

## Usage

Import components and start building!`;
</script>

README Display ​

vue
<template>
  <Box :padding="1" color="white">
    <Markdown
      content="# Project Title\n\nA brief description of your project.\n\n## Features\n\n- Feature 1\n- Feature 2\n- Feature 3\n\n## Installation\n\n```bash\nnpm install my-project\n```"
    />
  </Box>
</template>

<script setup>
import { Box, Markdown } from 'vuetty';
</script>

Help Section ​

vue
<template>
  <Markdown
    content="# Help\n\n## Commands\n\n- `start`: Start the server\n- `build`: Build for production\n- `test`: Run tests\n\n## Options\n\n| Option | Description |\n|--------|-------------|\n| --port | Server port |\n| --env | Environment |"
    :padding="1"
  />
</template>

<script setup>
import { Markdown } from 'vuetty';
</script>

Released under the MIT License.