### Install @theme-ui/style-guide
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/style-guide/README.md
Command to install the package via npm.
```sh
npm i @theme-ui/style-guide
```
--------------------------------
### Install @theme-ui/color
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/color/README.md
Install the package using npm.
```sh
npm i @theme-ui/color
```
--------------------------------
### Install @theme-ui/preset-sketchy
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-sketchy/README.md
Install the package using npm.
```sh
npm i @theme-ui/preset-sketchy
```
--------------------------------
### Install the package
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/match-media/README.md
Command to install the match-media package via npm.
```sh
npm i @theme-ui/match-media
```
--------------------------------
### Install @theme-ui/custom-properties
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/custom-properties/README.md
Install the package using npm.
```bash
npm i @theme-ui/custom-properties
```
--------------------------------
### Install @theme-ui/preset-funk
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-funk/README.md
Use npm to install the preset package in your project.
```sh
npm i @theme-ui/preset-funk
```
--------------------------------
### Install @theme-ui/presets
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/presets/README.md
Use npm to install the presets package into your project.
```sh
npm i @theme-ui/presets
```
--------------------------------
### Install @theme-ui/mdx
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/mdx/README.md
Command to install the package via npm.
```sh
npm i @theme-ui/mdx
```
--------------------------------
### Install @theme-ui/core
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/core/README.md
Install the core package along with the required @emotion/react dependency.
```sh
npm i @theme-ui/core @emotion/react
```
--------------------------------
### Install @theme-ui/css
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/css/README.md
Install the core package along with the required emotion dependency.
```sh
npm i @theme-ui/css @emotion/react
```
--------------------------------
### Install the Bootstrap preset
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-bootstrap/README.md
Use npm to install the package as a dependency in your project.
```sh
npm i @theme-ui/preset-bootstrap
```
--------------------------------
### Install @theme-ui/css
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/test-utils/README.md
Use this command to install the package via npm.
```sh
npm i @theme-ui/css
```
--------------------------------
### Install @theme-ui/preset-tosh
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-tosh/README.md
Use npm to install the preset package into your project.
```sh
npm i @theme-ui/preset-tosh
```
--------------------------------
### Install @theme-ui/components
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/components/README.md
Install the components package along with its required peer dependency.
```sh
npm i @theme-ui/components @emotion/react
```
--------------------------------
### Install @theme-ui/typography
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/packages/typography.mdx
Install the package via npm.
```sh
npm i @theme-ui/typography
```
--------------------------------
### Install @theme-ui/tachyons
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/tachyons/README.md
Install the package via npm.
```bash
npm i @theme-ui/tachyons
```
--------------------------------
### Install @theme-ui/preset-base
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-base/README.md
Use npm to install the base preset package in your project.
```sh
npm i @theme-ui/preset-base
```
--------------------------------
### Install @theme-ui/tailwind
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/tailwind/README.md
Use npm to install the package as a dependency.
```sh
npm i @theme-ui/tailwind
```
--------------------------------
### Install @theme-ui/color-modes
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/color-modes/README.md
Command to install the package via npm.
```sh
npm i @theme-ui/color-modes
```
--------------------------------
### Install @theme-ui/preset-deep
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-deep/README.md
Use npm to install the preset package into your project.
```sh
npm i @theme-ui/preset-deep
```
--------------------------------
### Install @theme-ui/preset-swiss
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-swiss/README.md
Use npm to install the preset package into your project.
```sh
npm i @theme-ui/preset-swiss
```
--------------------------------
### Render Style Guide Components
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/style-guide/README.md
Example usage of ColorPalette, TypeScale, and TypeStyle components within a React component.
```jsx
import { Themed } from '@theme-ui/mdx'
import { TypeScale, TypeStyle, ColorPalette } from '@theme-ui/style-guide'
export default (props) => (
<>
Style Guide
>
)
```
--------------------------------
### Start documentation development server
Source: https://github.com/system-ui/theme-ui/blob/develop/CONTRIBUTING.md
Launches the Gatsby development server for documentation with hot reloading.
```sh
pnpm run dev:docs
```
--------------------------------
### Install Theme UI dependencies
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/getting-started/index.mdx
Install the core library and the required emotion peer dependency.
```sh
npm install theme-ui @emotion/react
```
--------------------------------
### Install gatsby-theme-ui-blog
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/packages/gatsby-theme-ui-blog.mdx
Install the theme package via npm.
```sh
npm i gatsby-theme-ui-blog
```
--------------------------------
### Install @theme-ui/preset-polaris
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-polaris/README.md
Use npm to install the preset package in your project.
```sh
npm i @theme-ui/preset-polaris
```
--------------------------------
### Install dependencies
Source: https://github.com/system-ui/theme-ui/blob/develop/CONTRIBUTING.md
Run this command in the root directory to install dependencies and link local packages.
```sh
pnpm i
```
--------------------------------
### Install gatsby-theme-style-guide
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/gatsby-theme-style-guide/README.md
Install the package via npm to begin using the theme.
```sh
npm i gatsby-theme-style-guide
```
--------------------------------
### Install @theme-ui/preset-dark
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-dark/README.md
Use npm to install the preset package in your project.
```sh
npm i @theme-ui/preset-dark
```
--------------------------------
### Install the Tailwind preset
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-tailwind/README.md
Use npm to install the package as a dependency in your project.
```sh
npm i @theme-ui/preset-tailwind
```
--------------------------------
### Install Theme UI Prism component
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/mdx/syntax-highlighting.mdx
Install the required package via npm.
```sh
npm i @theme-ui/prism
```
--------------------------------
### Install @theme-ui/global dependencies
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/global/README.md
Install the necessary packages to use the global component in a project.
```sh
npm i @theme-ui/global @theme-ui/core @emotion/react
```
--------------------------------
### Install the preset package
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-system/README.md
Use this command to install the preset-2019 package via npm.
```sh
npm i @theme-ui/preset-2019
```
--------------------------------
### Install Theme UI dependencies
Source: https://github.com/system-ui/theme-ui/blob/develop/MIGRATING.md
Install the umbrella package along with required peer dependencies to resolve context mismatch issues.
```bash
npm install theme-ui @emotion/react @emotion/styled @mdx-js/react
```
--------------------------------
### Install @theme-ui/preset-future
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-future/README.md
Use npm to add the preset package to your project dependencies.
```sh
npm i @theme-ui/preset-future
```
--------------------------------
### Install gatsby-plugin-theme-ui
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/packages/gatsby-theme-ui-blog.mdx
Install the theme UI plugin to enable theme customization.
```sh
npm i gatsby-plugin-theme-ui
```
--------------------------------
### Install MDX dependencies
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/mdx/index.mdx
Install the necessary packages to enable MDX support in a Theme UI project.
```sh
npm i @theme-ui/mdx @mdx-js/react
```
--------------------------------
### Install Typography.js package
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/mdx/styling.mdx
Install the necessary packages to use Typography.js themes with Theme UI.
```sh
npm i @theme-ui/typography typography-theme-wordpress-2016
```
--------------------------------
### Install the Roboto preset
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-roboto/README.md
Use npm to add the preset package to your project dependencies.
```sh
npm i @theme-ui/preset-roboto
```
--------------------------------
### JSX Syntax Example
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/guides/jsx-pragma.mdx
A basic example of JSX syntax used for rendering components.
```jsx
// example JSX
```
--------------------------------
### Install gatsby-theme-ui-layout
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/gatsby-theme-ui-layout/README.md
Use npm to install the theme package in your Gatsby project.
```sh
npm i gatsby-theme-ui-layout
```
--------------------------------
### Install the Bulma preset
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-bulma/README.md
Use npm to add the preset package to your project dependencies.
```sh
npm i @theme-ui/preset-bulma
```
--------------------------------
### Install Theme UI dependencies for Gatsby
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/getting-started/gatsby.mdx
Run this command to install the required packages for Theme UI, MDX support, and the Gatsby plugin.
```sh
npm i theme-ui @theme-ui/mdx gatsby-plugin-theme-ui @emotion/react @mdx-js/react
```
--------------------------------
### Run the typecheck script
Source: https://github.com/system-ui/theme-ui/blob/develop/scripts/typecheck-built-files/README.md
Execute these commands to build the packages, install dependencies, and run the typecheck process.
```sh
# ensure Theme UI packages are built
cd ../.. && pnpm build
# install dependencies -- package.json contains relative paths to package directories
pnpm install
# run the script
pnpm start
```
--------------------------------
### Rendering a Box component
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/components/box.mdx
Basic usage example demonstrating padding and color properties.
```jsx
Beep
```
--------------------------------
### Header A5 Live Example
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/recipes/header-a5.mdx
A centered header layout using Theme UI sx prop for styling and layout control.
```jsx
Home
Work
Blog
About
Contact
```
--------------------------------
### CSS Grid Component Implementation
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/recipes/css-grid.mdx
A full component example using the @jsxImportSource pragma to define a responsive grid layout with theme-aware spacing.
```jsx
/** @jsxImportSource theme-ui */
export default (props) => (
{props.children}
Sidebar
)
```
--------------------------------
### Render Theme UI components
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/components/index.mdx
Example of using Box, Flex, Heading, and Button components with the sx prop.
```jsx
Components
```
--------------------------------
### Define a custom theme object
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/theming.mdx
Provides a full example of a theme configuration based on the @theme-ui/presets structure.
```javascript
// example base theme from @theme-ui/presets
export const theme = {
breakpoints: ['40em', '52em', '64em'],
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
fonts: {
body:
'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif',
heading: 'inherit',
monospace: 'Menlo, monospace',
},
fontSizes: [12, 14, 16, 20, 24, 32, 48, 64, 96],
fontWeights: {
body: 400,
heading: 700,
bold: 700,
},
lineHeights: {
body: 1.5,
heading: 1.125,
},
colors: {
text: '#000',
background: '#fff',
primary: '#07c',
secondary: '#30c',
muted: '#f6f6f6',
},
text: {
heading: {
fontFamily: 'heading',
lineHeight: 'heading',
fontWeight: 'heading',
},
},
styles: {
root: {
fontFamily: 'body',
lineHeight: 'body',
fontWeight: 'body',
},
h1: {
variant: 'text.heading',
fontSize: 5,
},
h2: {
variant: 'text.heading',
fontSize: 4,
},
h3: {
variant: 'text.heading',
fontSize: 3,
},
h4: {
variant: 'text.heading',
fontSize: 2,
},
h5: {
variant: 'text.heading',
fontSize: 1,
},
h6: {
variant: 'text.heading',
fontSize: 0,
},
pre: {
fontFamily: 'monospace',
overflowX: 'auto',
code: {
color: 'inherit',
},
},
code: {
fontFamily: 'monospace',
fontSize: 'inherit',
},
table: {
width: '100%',
borderCollapse: 'separate',
borderSpacing: 0,
},
th: {
textAlign: 'left',
borderBottomStyle: 'solid',
},
td: {
textAlign: 'left',
borderBottomStyle: 'solid',
},
},
}
```
--------------------------------
### Responsive CSS Grid with sx prop
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/recipes/css-grid.mdx
A live example demonstrating a two-column grid layout that switches from stacked to side-by-side based on screen size.
```jsx
Main
```
--------------------------------
### Configure gatsby-theme-style-guide
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/gatsby-theme-style-guide/README.md
Add the theme to your gatsby-config.js file to enable the style guide generation.
```js
// gatsby-config.js
module.exports = {
plugins: ['gatsby-plugin-theme-ui', 'gatsby-theme-style-guide'],
}
```
--------------------------------
### Full Gatsby Link component implementation
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/recipes/gatsby-link.mdx
A complete example showing the required JSX pragma and component structure for a styled Gatsby Link.
```jsx
/** @jsxImportSource theme-ui */
import { Link } from 'gatsby'
export default (props) => (
)
```
--------------------------------
### Basic Flexbox layout
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/components/flex.mdx
Example of using the Flex component to arrange child Box elements.
```jsx
Flex
Box
```
--------------------------------
### Define a Theme Object
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/theme-spec.mdx
Example structure of a theme object containing color, font, font weight, and line height scales.
```js
// example theme
{
colors: {
text: '#000',
background: '#fff',
primary: '#07c',
secondary: '#05a',
accent: '#609',
muted: '#f6f6f6',
},
fonts: {
body: 'system-ui, sans-serif',
heading: 'system-ui, sans-serif',
monospace: 'Menlo, monospace',
},
fontWeights: {
body: 400,
heading: 700,
bold: 700,
},
lineHeights: {
body: 1.5,
heading: 1.125,
},
}
```
--------------------------------
### Apply Syntax Themes
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/prism/README.md
Import a preset and add the styles to theme.styles.code.
```javascript
// theme.js
import nightOwl from '@theme-ui/prism/presets/night-owl.json'
const theme = {
// ...theme
styles: {
code: {
...nightOwl,
},
},
}
```
--------------------------------
### Define theme variants
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/components/paragraph.mdx
Example structure for defining text variants within the theme object.
```js
// example theme variants
{
text: {
block: {
variant: 'paragraph',
my: 2,
textAlign: 'justify',
textAlignLast: 'start',
textJustify: 'auto',
},
}
}
```
--------------------------------
### Create a styled layout component with InvertedBanner
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/mdx/layout-components.mdx
An example of augmenting the theme prop and applying sx styles to create an inverted color effect.
```jsx
/** @jsxImportSource theme-ui */
import { ThemeUIProvider } from 'theme-ui'
const InvertedBanner = (props) => (
)
export default InvertedBanner
```
--------------------------------
### Create theme file
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/getting-started/gatsby.mdx
Define your theme configuration in the specified directory to customize colors and other design tokens.
```js
// example theme file
const theme = {
colors: {
text: '#000',
background: '#fff',
},
}
export default theme
```
--------------------------------
### invert
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/color/README.md
Gets the inverted color.
```APIDOC
## invert(color)
### Description
Get the inverted color.
### Signature
`invert(color)`
```
--------------------------------
### complement
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/color/README.md
Gets the complement of a color.
```APIDOC
## complement(color)
### Description
Get the complement of a color.
### Signature
`complement(color)`
```
--------------------------------
### Initialize Theme UI with a Typography.js theme
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/packages/typography.mdx
Use the toTheme function to convert a Typography.js theme object for use with ThemeUIProvider.
```js
import { ThemeUIProvider } from 'theme-ui'
import { toTheme } from '@theme-ui/typography'
import wp2016 from 'typography-theme-wordpress-2016'
const theme = toTheme(wp2016)
export default (props) => (
{props.children}
)
```
--------------------------------
### Use ThemeProvider and sx prop
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/core/README.md
Wrap your application with ThemeProvider and use the sx prop for styling elements based on the theme.
```js
/** @jsxImportSource @theme-ui/core */
import { ThemeProvider } from '@theme-ui/core'
export function App() {
return (
Hello
)
}
```
--------------------------------
### Create a basic layout component with ThemeUIProvider
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/mdx/layout-components.mdx
A foundational component structure using ThemeUIProvider to wrap content in a div.
```jsx
/** @jsxImportSource theme-ui */
import { ThemeUIProvider } from 'theme-ui'
export default (props) => (
)
```
--------------------------------
### Configure remark-slug in contentlayer.config.js
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/mdx/linked-headings.mdx
Integrate remark-slug into the mdx configuration object within the contentlayer source setup.
```js
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import remarkSlug from 'remark-slug'
export const Post = defineDocumentType(() => ({
name: 'Post',
filePathPattern: '*.mdx',
contentType: 'mdx',
fields: {},
}))
export default makeSource({
contentDirPath: 'posts',
documentTypes: [Post],
mdx: {
remarkPlugins: [remarkSlug],
rehypePlugins: [],
},
})
```
--------------------------------
### Radio component usage
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/components/radio.mdx
Example of using Radio components within Label wrappers to create a selection group.
```jsx
```
--------------------------------
### Create a basic layout component
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/guides/layouts.mdx
Define a wrapper component using the sx prop for default layout styles.
```javascript
// example src/layout.js
/** @jsxImportSource theme-ui */
export default (props) => (
Header content
{props.children}
)
```
--------------------------------
### Extend the system theme
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/preset-system/README.md
Import the preset-system and spread its properties into your custom theme configuration.
```jsx
// example theme
import theme from '@theme-ui/preset-system'
export default {
...theme,
styles: {
...theme,
},
}
```
--------------------------------
### Configure Highlight Styling
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/prism/README.md
Control highlight appearance in styles.pre under .highlight.
```json
".highlight": {
"background": "hsla(0, 0%, 30%, .5)"
}
```
--------------------------------
### Accessing optional theme properties
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/guides/typescript.mdx
Demonstrates the type error when accessing optional properties directly versus using the get utility.
```tsx
/** @jsxImportSource theme-ui */
import { Theme } from 'theme-ui'
const theme: Theme = {
space: [0, 8, 16, 32, 64, 128, 256],
sizes: [0, 8, 16, 32, 64, 128, 256],
}
// Type error on `theme.space` and `theme.sizes`.
// Object is possibly 'undefined'.ts(2532)
return
t.space[3] + t.sizes[5] }} />
```
```tsx
/** @jsxImportSource theme-ui */
import { Theme, get } from 'theme-ui'
// No error
return
get(t, 'space.3') + get(t, 'sizes.5') }} />
```
--------------------------------
### Cycle through multiple color modes
Source: https://github.com/system-ui/theme-ui/blob/develop/packages/docs/src/pages/guides/color-mode-toggles.mdx
Cycles through an array of defined color modes using the modulo operator to loop back to the start.
```jsx
/** @jsxImportSource theme-ui */
import { useColorMode } from 'theme-ui'
const modes = ['light', 'dark', 'purple', 'pink']
export default (props) => {
const [mode, setMode] = useColorMode()
return (