包详细信息

@theme-ui/mdx

system-ui136.6kMIT0.17.2

MDX utilities for Theme UI

自述文件

@theme-ui/mdx

MDX utilities for Theme UI

npm i @theme-ui/mdx

API

useThemedStylesWithMdx

Wraps an object of components provided to MDXProvider with styles from theme.styles.

Example usage:

import {
  MDXProvider,
  useMDXComponents,
  Components as MDXComponents,
  MergeComponents as MergeMDXComponents,
} from '@mdx-js/react'
import { useThemedStylesWithMdx } from '@theme-ui/mdx'
import { ThemeUIProvider, Theme } from 'theme-ui'

interface MyProviderProps {
  theme: Theme
  components?: MDXComponents | MergeMDXComponents
  children: React.ReactNode
}
function MyProvider({ theme, components, children }: MyProviderProps) {
  const componentsWithStyles = useThemedStylesWithMdx(
    useMDXComponents(components)
  )

  return (
    <ThemeUIProvider theme={theme}>
      <MDXProvider components={componentsWithStyles}>{children}</MDXProvider>
    </ThemeUIProvider>
  )
}

Themed

Use the Themed components dictionary to render UI with styles from theme.styles outside of MDX. These are primarily meant as a mechanism to use styles defined in a theme object outside of MDX, which can then be embedded in JSX>

// picks up styles from `theme.styles.h1`
<Themed.h1 />

If you’re looking to automatically hyperlink headings in MDX, check out the linked headings guide.)


Other exports

  • themed
  • defaultMdxComponents

更新日志

v0.13.0 (Mon Dec 27 2021)

Release Notes

Move Emotion and MDX packages to peerDeps (#1867)

BREAKING CHANGE: @emotion/react and @mdx-js/react were moved to peerDependencies of theme-ui, @theme-ui/mdx and @theme-ui/sidenav and must be installed separately. This is a revert of change from Theme UI v0.3, and it's meant to help solve version clashes and context mismatch bugs on user side. Connected issues: #1793, #1531, #1530, #1388, #1345, #1130.



🚀 Enhancement

  • Move Emotion and MDX packages to peerDeps #1867 (@hasparus)
  • feat(deps): move @mdx-js/react to peerDeps (@hasparus)
  • feat(deps): move Emotion to peerDeps (@hasparus)

Authors: 1


v0.12.0 (Thu Oct 28 2021)

:tada: This release contains work from a new contributor! :tada:

Thank you, William Pei (@draekien), for all your work!

🚀 Enhancement

🐛 Bug Fix

  • Merge remote-tracking branch 'upstream/develop' into fix/color-scheme-media-query-api-update #981 (@draekien)

Authors: 6


v0.11.0 (Wed Aug 25 2021)

🐛 Bug Fix

Authors: 1


v0.10.0 (Sat Jun 19 2021)

🏠 Internal

Authors: 2


v0.8.3 (Wed May 05 2021)

⚠️ Pushed to stable

  • Merge branch 'stable' into develop (@hasparus)

Authors: 1


v0.8.0 (Wed May 05 2021)

🐛 Bug Fix

⚠️ Pushed to stable

  • Merge branch 'stable' into develop (@hasparus)

Authors: 3


v0.7.5 (Wed Apr 28 2021)

⚠️ Pushed to stable

  • Merge branch 'develop' into stable (@hasparus)

Authors: 1


v0.7.0 (Thu Apr 15 2021)

🚀 Enhancement

🐛 Bug Fix

⚠️ Pushed to stable

  • Merge branch 'develop' into stable (@hasparus)

Authors: 2