Questions tagged [theme-ui]

Theme UI is a library for creating themeable user interfaces based on constraint-based design principles. Build custom component libraries, design systems, web applications, Gatsby themes, and more with a flexible API for best-in-class developer ergonomics.

Home page

https://theme-ui.com/

Docs

https://theme-ui.com/getting-started

Github

https://github.com/system-ui/theme-ui

Demo

https://theme-ui.com/demo

Syntax

// example theme.js
export default {
  fonts: {
    body: 'system-ui, sans-serif',
    heading: '"Avenir Next", sans-serif',
    monospace: 'Menlo, monospace',
  },
  colors: {
    text: '#000',
    background: '#fff',
    primary: '#33e',
  },
}

// basic usage
import React from 'react'
import { ThemeProvider } from 'theme-ui'
import theme from './theme'
export default props => (
  <ThemeProvider theme={theme}>{props.children}</ThemeProvider>
)

/** @jsx jsx */
import { jsx } from 'theme-ui'
export default props => (
  <div
    sx={{
      fontWeight: 'bold',
      fontSize: 4, // picks up value from `theme.fontSizes[4]`
      color: 'primary', // picks up value from `theme.colors.primary`
    }}>
    Hello
  </div>
)
31 questions
5
votes
1 answer

Next.js 12 breaks when used with theme-ui giving "code: 'ERR_REQUIRE_ESM'"

I'm using Next.js 12 and this error pops up after I created a theme using theme-ui Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: E:\fm-nextjs\node_modules\@mdx-js\react\index.js require() of ES modules is not supported. require() of…
cmgchess
  • 7,996
  • 37
  • 44
  • 62
5
votes
2 answers

How to fix 'Types of property 'color' are incompatible' on Box component using typescript and emotion

I'm attempting to make a general Box react component on a new project. This will be the base of all other components. I'm using styled-system, emotion, and eventually theme-ui to handle themeing and styling of all my components. My root Box…
4
votes
0 answers

how to hide both axis lines in chartJs(options isn't working)

I am using bar chart and want to hide the both axis line. I've tried the following but it doesn't work. =>> Actually, I'm making a chart using ChartJS. Everything has gone smoothly, with one exception: Although the X-axis line (the line that runs…
4
votes
1 answer

Use local custom fonts with Theme-UI

i want to load a local font in my site, where im using theme-ui. My theme-ui config looks like this: const theme = { fonts: { body: 'CircularBlack', heading: 'CircularBlack', monospace: 'Menlo, monospace', }, ... "CircularBlack" is…
3
votes
1 answer

Why using Rebass over Theme UI?

I chose Rebass as a component library for my app. Because Rebass is unopinionated about theming, it needs a theming library. Fine, I chose Theme UI to define my theme and then I started to build my app. I quickly noticed that all the React…
ncuillery
  • 14,308
  • 2
  • 22
  • 31
2
votes
1 answer

References to theme object aren't working within the Theme UI theme

TLDR References in my Theme UI theme are being output as static values instead of resolving to the object property/value, meaning I get CSS output such as font-family: heading; where font-family should actually be mapping to text.heading and resolve…
onebc
  • 398
  • 2
  • 10
2
votes
2 answers

Theme UI sx prop ignored when importing a storybook component

I have setup and published to a private server a StoryBook design system using ThemeUI that contains components. One such component is the button shown below. import React, { FC } from "react"; import { Button as ButtonUI, SxStyleProp } from…
2
votes
4 answers

How to adjust body background color with gatsby-plugin-theme-ui

When building a Gatsby theme with gatsby-plugin-theme-ui, the documentation states that you can adjust the background color of the body by adding it to your theme object in the nested colors object. This appears to have no effect. Other variables…
Shane Fisher
  • 41
  • 1
  • 3
1
vote
0 answers

pragma and pragmaFrag cannot be set when runtime is automatic. when add storybook to theme-ui project

work with a project using theme-ui library which make use of the jsx paragma so in the beginning of every file I have /** @jsx jsx */ import { jsx } from '@theme-ui/core'; I want to add storybook 6 to my project, when I add storybook I always get an…
1
vote
3 answers

How can I use Local fonts in theme UI in next JS?

I am building an app with the next JS using [theme-UI][1]. But in my project, I have to use local fonts or custom fonts. But I have no idea how can I do that. Here is my theming const theme = { fonts: { body: 'CircularBlack', …
user16993687
1
vote
1 answer

theme-ui and is there a way to dynamically calculate a height of a fixed header and as such add padding to the following div?

So, I have a theme that a user can pass in. If the user passes in a "logo component", then I will then slot that into a fixed header. That logo component can be 50 - 100pixels tall. Since its fixed, then I need the content after it to come below the…
james emanon
  • 11,185
  • 11
  • 56
  • 97
1
vote
3 answers

Style Chakra UI FormControl and label at application theme level

Have been using Chakra for a while but I can not get my head around styling all my components, in this case, FormControl at a global level with the theme file. For example if i want to add margin bottom to my FormControl and FormLabel elements I…
RyanP13
  • 7,413
  • 27
  • 96
  • 166
1
vote
1 answer

Theme-ui/prism won't work for gatsbyjs markdown files

I'm using @theme-ui/prism to format code block text in markdown files. The markdown plugin im using is gatsby-plugin-mdx. It doesn't seem to be working because I don't get the dark background in the code block. Here's what I did: yarn add…
doctopus
  • 5,349
  • 8
  • 53
  • 105
1
vote
0 answers

Can I style the Netlify CMS preview with Theme UI and/or Emotion?

I have a Gatsby project that uses Theme UI and Netlify CMS. How can I style the Netlify CMS preview pane with my Theme UI styles? Netlify CMS doesn't support CSS-in-JS libraries: https://github.com/netlify/netlify-cms/issues/793 Unlike Styled…
Aaron Adams
  • 1,657
  • 16
  • 23
1
vote
1 answer

Why is sx props unable to access theme object?

I am trying to use the theme-ui for a new gatsby project I am working on. After following the instructions on the theme-ui documentation, I am still unable to get theming to work properly. The sx props doesn't seem to have access to the theme object…
mbappai
  • 557
  • 1
  • 5
  • 22
1
2 3