Return to Sky UI homepage
import { Markdown } from '@sky-uk/ui-core';

The Markdown component renders markdown into Sky UI components. The component supports standard markdown syntax and HTML elements. For example, you could use <br/> for soft line breaks or empty lines.

The spacing around markdown elements components is significant. If you encounter any errors, make sure to verify that your markdown syntax and surrounding whitespace are correctly formatted.

Props

  • content – markdown content
  • components - component overrides for HTML tags

Inline and Block elements

The component renders markdown content inside of React.Fragment, so you can wrap it with an inline or block element of your choice, if needed.

As we are providing just a simple string, without new lines or any block elements, the content is not parsed as paragraph and could be wrapped in a Text element to be rendered as a span by default.

If you add new lines or block elements such as h2, the strings with new lines will be parsed as paragraphs (and h2 in this case), so the wrapper Text is not needed.

Component Overrides

The Markdown component uses Text and Text Link components with default styles. However you can override default components using the components prop. E.g. substitute generic unordered list with Icon List.

You would also need to use components override if you need to add data-test-id or other custom attributes.

On Dark Background

Easiest way of changing content color for dark background would be wrapping it with Text component with $color="white", however some component will still need overrides e.g. Text Link would need $appearance='light', see example below.