License
- MIT
- Yesattribution
- Permissivelinking
- Permissivedistribution
- Permissivemodification
- Nopatent grant
- Yesprivate use
- Permissivesublicensing
- Notrademark grant
Downloads
Readme
Theme UI
The Design Graph Framework
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
- Theming
- The
sx
Prop - Layout
- Color Modes
- Theme Spec
- Themed
- MDX Components
- Gatsby Plugin
- API
MIT License
Contributors β¨
Thanks goes to these wonderful people (emoji key):
Brent Jackson
π€ π» π¨ π π‘ β οΈ π
Piotr Monwid-Olechnowicz
π» π β οΈ π π‘
Dany Castillo
π» π π‘ β οΈ
Jordan Overbye
π» π‘ β οΈ
Lachlan Campbell
π» π‘ β οΈ π π π¬
John Otander
π» π π β οΈ π€
David Burles
π» π β οΈ π
Max Stoiber
π» π β οΈ π‘
Atanas Stoyanov
π» π¬ β οΈ π π
Lennart
π» π π π‘
Aleksandra Sikora
π»
LB
π» β οΈ
Francis Champagne
π» π β οΈ π
Alex Page
π» π
Adam Schay
π»
Alex
π» π
James Edmonds
π» π
Florent SCHILDKNECHT
π» π
Cole Bemis
π» β οΈ π
John Letey
π
Yuraima Estevez
π»
Allan Pope
π» π
Emmanuel Pilande
π»
Justin Hall
π»
Marek
π» π
BjΓΆrn Clees
π π»
Iurii Kucherov
π
Joe Strouth
π» π
Stewart Everett
π»
Travis Arnold
π» π
Ivo Reis
π»
Benedikt RΓΆtsch
π π
Jacob Cofman
π
John Letey
π
Lawrence Gosset
π
Markos Konstantopoulos
π
Robin Millette
π»
Rodney Folz
π»
Rodrigo Pombo
π» β οΈ π
Scott Silvi
π
Shawn Allen
π
Tomas Carnecky
π» π
John Polacek
π» π
mackie
π»
Aaron Adams
π» π π
Amberley
π»
Andreea NΔstase
π
Anson Low Z.F
π π
Bernhard Gschwantner
π»
Bhanu Prakash Korthiwada
π
Bruno Lemos
π
Bryce Fischer
π»
Dan Wood
π
Debs
π
Edward O'Reilly
π» π
Eric Schaefer
π»
Felix Green
π
Gerhard Bliedung
π» π
Guayo Mena
π‘
Guilherme Lima
π
Herb Caudill
π
Jacob Bolda
π» π
Jason Lengstorf
π π
Jason Rundell (he/him)
π‘
Joe Race
π
Kanstantsin Klimashevich
π
Eka
π π
Keir Williams
π
KristΓ³f PoduszlΓ³
π» π π€
Kyle Gill
π
Kyle Holmberg
π
Jay Laiche
π»
Marc Wiest
π»
Matheus Teixeira
π»
matt-cratebind
π
Matt Zabriskie
π»
Maxime Khoy
π»
Michael Friedman
π
Michael Zetterberg fd. Lopez
π»
Nathan Knowler
π»
Neeraj Lagwankar
π
Owen Young
π»
Patrick Arminio
π» π
Pedro Duarte
π»
Ray Clanan
π»
Rich Werden
π
Rob Phoenix
π π
Robert Moggach
π» π
Anand Narayan
π» π
Sam Poder
π
Sam Rose
π
Sohrab
π»
Spencer Rinehart
π»
Steve
π
Steve Barton
π
Tim Reynolds
π» π
VinΓcius Lemes
π
Yihwan Kim
π» π
Yuriy Burychka
π
Zolwiastyl
π»
Amrish Kushwaha
π»
Joe Bell
π» π
kenny-loveholidays
π»
β¦β¦βΛβΛββ¦β¦
π» π
navsgh
π
Shane O'Neill
π
ζ±ͺη£
π» π
Carolin Maisenbacher
π» π β οΈ
Alex Chan
π π‘ β οΈ π»
Kenny
π»
Jordie Bodlay
π
Matt Gleich
π
William Pei
π π‘ π» β οΈ
Greg Poole
π
Akash
π π»
Cannon Lock
π
kamatte
π π»
Simen A. W. Olsen
π π‘ β οΈ π»
Wahid Rahim
π π‘ π»
Justin Cooper
π
CJ
π π»
This project follows the all-contributors specification. Contributions of any kind welcome!