Displays rendered Markdown and facilitates interaction.
  • Deprecated
  • Not reviewed for accessibility
import {MarkdownViewer} from '@primer/react/drafts'

The MarkdownViewer displays rendered Markdown and handles interaction (link clicking and checkbox checking/unchecking) with that content.


Simple Example

Checkbox Interaction Example




The markdown the HTML was rendered from. This is not used for viewing, only as a source for change events.

{ __html: string }

Set the rendered HTML of the viewer. To prevent XSS, ensure that the source of this HTML is trusted!


Show a loading spinner instead of content.

(event: MouseEvent) => void

Called when the user clicks a link element. This can be used to intercept the click and provide custom routing. Note that this is a native HTML MouseEvent and not a React.ClickEvent.

(markdown: string) => void | Promise<void>

Called when the user interacts and updates the Markdown. The rendered Markdown is updated eagerly - if the request fails, a rejected Promise should be returned by this handler. In that case, the viewer will revert the visual change. If the change is handled by an async API request (as it typically will be in production code), the viewer should be disabled while the request is pending to avoid conflicts. To allow users to check multiple boxes rapidly, the API request should be debounced (an ideal debounce duration is about 1 second).


Control whether interaction is disabled.



  • Component props and basic example usage of the component are documented on
  • Component does not have any unnecessary third-party dependencies.
  • Component can adapt to different themes.
  • Component can adapt to different screen sizes.
  • Component has robust unit test coverage (100% where achievable).
  • Component has visual regression coverage of its default and interactive states.
  • Component does not introduce any axe violations.
  • Component has been manually reviewed by the accessibility team and any resulting issues have been addressed.


  • Component is used in a production application.
  • Common usage examples are documented on
  • Common usage examples are documented in storybook stories.
  • Component has been reviewed by a systems designer and any resulting issues have been addressed.
  • Component does not introduce any performance regressions.


  • Component API has been stable with no breaking changes for at least one month.
  • Feedback on API usability has been sought from developers using the component and any resulting issues have been addressed.
  • Component has corresponding design guidelines documented in the interface guidelines.
  • Component has corresponding Figma component in the Primer Web library.
  • Tooling (such as linters, codemods, etc.) exists to prevent further use of alternatives.