Skip to content

system-ui/theme-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Theme UI logo Theme UI logo

Theme UI

The Design Graph Framework

Β 

GitHub GitHub Stars npm (latest) npm (develop)
Contributors
Size Tree Shaking MIT license Join our Discord community
This project is using Cypress for end-to-end tests. This project is using Percy.io for visual regression testing.


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.

stable docs: https://theme-ui.com
develop (prerelease) docs: https://dev.theme-ui.com


Built for design systems, white-labels, themes, and other applications where customizing colors, typography, and layout are treated as first-class citizens and based on a standard Theme Specification, Theme UI is intended to work in a variety of applications, libraries, and other UI components. Colors, typography, and layout styles derived from customizable theme-based design scales help you build UI rooted in constraint-based design principles.

  • The next evolution of Styled System
  • From the creators of utility-based, atomic CSS methodologies
  • Theme-based styling with the sx prop
  • Compatible with virtually any UI component library
  • Works with existing Styled System components
  • Quick mobile-first responsive styles
  • Built-in support for dark modes
  • Primitive page layout components
  • Completely customizable with robust theming
  • Built with a standard Theme Specification for interoperability
  • Built with Emotion for scoped styles
  • Plugin for use in Gatsby sites and themes
  • Style MDX content with a simple, expressive API
  • Works with Typography.js themes

Getting Started

npm install theme-ui @emotion/react

If you don't need color modes or components you can install @theme-ui/core.

Any styles in your app can reference values from the global theme object. To provide the theme in context, wrap your application with the ThemeUIProvider component and pass in a custom theme object.

// basic usage
import { ThemeUIProvider } from 'theme-ui'
import theme from './theme'

export default (props) => (
  <ThemeUIProvider theme={theme}>{props.children}</ThemeUIProvider>
)

The theme object follows the System UI Theme Specification, which lets you define custom color palettes, typographic scales, fonts, and more. Read more about theming.

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

sx prop

The sx prop works similarly to Emotion's css prop, accepting style objects to add CSS directly to an element in JSX, but includes extra theme-aware functionality. Using the sx prop for styles means that certain properties can reference values defined in your theme object. This is intended to make keeping styles consistent throughout your app the easy thing to do.

The sx prop only works in modules that have defined a custom pragma at the top of the file, which replaces the default React JSX functions. This means you can control which modules in your application opt into this feature without the need for a Babel plugin or additional configuration.

/** @jsxImportSource 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>
)

Read more about how the custom pragma works.

Responsive styles

The sx prop also supports using arrays as values to change properties responsively with a mobile-first approach. This API originated in Styled System and is intended as a terser syntax for applying responsive styles across a singular dimension.

/** @jsxImportSource theme-ui */

export default (props) => (
  <div
    sx={{
      // applies width 100% to all viewport widths,
      // width 50% above the first breakpoint,
      // and 25% above the next breakpoint
      width: ['100%', '50%', '25%'],
    }}
  />
)

Documentation

MIT License

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Image
Brent Jackson

πŸ€” πŸ’» 🎨 πŸ“– πŸ’‘ ⚠️ πŸ‘€
Image
Piotr Monwid-Olechnowicz

πŸ’» πŸ“– ⚠️ πŸ‘€ πŸ’‘
Image
Dany Castillo

πŸ’» πŸ“– πŸ’‘ ⚠️
Image
Jordan Overbye

πŸ’» πŸ’‘ ⚠️
Image
Lachlan Campbell

πŸ’» πŸ’‘ ⚠️ πŸ‘€ πŸ“– πŸ’¬
Image
John Otander

πŸ’» πŸ‘€ πŸ“– ⚠️ πŸ€”
Image
David Burles

πŸ’» πŸ‘€ ⚠️ πŸ“–
Image
Max Stoiber

πŸ’» πŸ‘€ ⚠️ πŸ’‘
Image
Atanas Stoyanov

πŸ’» πŸ’¬ ⚠️ πŸ› πŸ“–
Image
Lennart

πŸ’» πŸ› πŸ“– πŸ’‘
Image
Aleksandra Sikora

πŸ’»
Image
LB

πŸ’» ⚠️
Image
Francis Champagne

πŸ’» πŸ› ⚠️ πŸ“–
Image
Alex Page

πŸ’» πŸ“–
Image
Adam Schay

πŸ’»
Image
Alex

πŸ’» πŸ“–
Image
James Edmonds

πŸ’» πŸ“–
Image
Florent SCHILDKNECHT

πŸ’» πŸ“–
Image
Cole Bemis

πŸ’» ⚠️ πŸ“–
Image
John Letey

πŸ“–
Image
Yuraima Estevez

πŸ’»
Image
Allan Pope

πŸ’» πŸ“–
Image
Emmanuel Pilande

πŸ’»
Image
Justin Hall

πŸ’»
Image
Marek

πŸ’» πŸ›
Image
BjΓΆrn Clees

πŸ“– πŸ’»
Image
Iurii Kucherov

πŸ“–
Image
Joe Strouth

πŸ’» πŸ›
Image
Stewart Everett

πŸ’»
Image
Travis Arnold

πŸ’» πŸ“–
Image
Ivo Reis

πŸ’»
Image
Benedikt RΓΆtsch

πŸ› πŸ“–
Image
Jacob Cofman

πŸ“–
Image
John Letey

πŸ“–
Image
Lawrence Gosset

πŸ“–
Image
Markos Konstantopoulos

πŸ“–
Image
Robin Millette

πŸ’»
Image
Rodney Folz

πŸ’»
Image
Rodrigo Pombo

πŸ’» ⚠️ πŸ“–
Image
Scott Silvi

πŸ“–
Image
Shawn Allen

πŸ“–
Image
Tomas Carnecky

πŸ’» πŸ›
Image
John Polacek

πŸ’» πŸ›
Image
mackie

πŸ’»
Image
Aaron Adams

πŸ’» πŸ› πŸ“–
Image
Amberley

πŸ’»
Image
Andreea Năstase

πŸ“–
Image
Anson Low Z.F

πŸ› πŸ“–
Image
Bernhard Gschwantner

πŸ’»
Image
Bhanu Prakash Korthiwada

πŸ“–
Image
Bruno Lemos

πŸ“–
Image
Bryce Fischer

πŸ’»
Image
Dan Wood

πŸ“–
Image
Debs

πŸ“–
Image
Edward O'Reilly

πŸ’» πŸ›
Image
Eric Schaefer

πŸ’»
Image
Felix Green

πŸ“–
Image
Gerhard Bliedung

πŸ’» πŸ›
Image
Guayo Mena

πŸ’‘
Image
Guilherme Lima

πŸ“–
Image
Herb Caudill

πŸ“–
Image
Jacob Bolda

πŸ’» πŸ›
Image
Jason Lengstorf

πŸ› πŸ“–
Image
Jason Rundell (he/him)

πŸ’‘
Image
Joe Race

πŸ“–
Image
Kanstantsin Klimashevich

πŸ“–
Image
Eka

πŸ“– πŸ›
Image
Keir Williams

πŸ“–
Image
KristΓ³f PoduszlΓ³

πŸ’» πŸ› πŸ€”
Image
Kyle Gill

πŸ“–
Image
Kyle Holmberg

πŸ“–
Image
Jay Laiche

πŸ’»
Image
Marc Wiest

πŸ’»
Image
Matheus Teixeira

πŸ’»
Image
matt-cratebind

πŸ“–
Image
Matt Zabriskie

πŸ’»
Image
Maxime Khoy

πŸ’»
Image
Michael Friedman

πŸ“–
Image
Michael Zetterberg fd. Lopez

πŸ’»
Image
Nathan Knowler

πŸ’»
Image
Neeraj Lagwankar

πŸ“–
Image
Owen Young

πŸ’»
Image
Patrick Arminio

πŸ’» πŸ›
Image
Pedro Duarte

πŸ’»
Image
Ray Clanan

πŸ’»
Image
Rich Werden

πŸ“–
Image
Rob Phoenix

πŸ“– πŸ›
Image
Robert Moggach

πŸ’» πŸ›
Image
Anand Narayan

πŸ’» πŸ›
Image
Sam Poder

πŸ“–
Image
Sam Rose

πŸ“–
Image
Sohrab

πŸ’»
Image
Spencer Rinehart

πŸ’»
Image
Steve

πŸ“–
Image
Steve Barton

πŸ“–
Image
Tim Reynolds

πŸ’» πŸ›
Image
VinΓ­cius Lemes

πŸ“–
Image
Yihwan Kim

πŸ’» πŸ›
Image
Yuriy Burychka

πŸ“–
Image
Zolwiastyl

πŸ’»
Image
Amrish Kushwaha

πŸ’»
Image
Joe Bell

πŸ’» πŸ›
Image
kenny-loveholidays

πŸ’»
Image
β¦‡β¦€βˆ™Λ‡βˆŽΛ‡βˆ™β¦€β¦ˆ

πŸ’» πŸ›
Image
navsgh

πŸ“–
Image
Shane O'Neill

πŸ“–
Image
ζ±ͺ磊

πŸ’» πŸ›
Image
Carolin Maisenbacher

πŸ’» πŸ“– ⚠️
Image
Alex Chan

πŸ“– πŸ’‘ ⚠️ πŸ’»
Image
Kenny

πŸ’»
Image
Jordie Bodlay

πŸ“–
Image
Matt Gleich

πŸ“–
Image
William Pei

πŸ“– πŸ’‘ πŸ’» ⚠️
Image
Greg Poole

πŸ“–
Image
Akash

πŸ“– πŸ’»
Image
Cannon Lock

πŸ“–
Image
kamatte

πŸ“– πŸ’»
Image
Simen A. W. Olsen

πŸ“– πŸ’‘ ⚠️ πŸ’»
Image
Wahid Rahim

πŸ“– πŸ’‘ πŸ’»
Image
Justin Cooper

πŸ“–
Image
CJ

πŸ“– πŸ’»
Image
Sam Marxz

πŸ“–

This project follows the all-contributors specification. Contributions of any kind welcome!