Introduction to Theme UI

John Otander
InstructorJohn Otander
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

Theme UI is a library created by Brent Jackson for building themeable React apps with Gatsby. It's built with Styled System which provides a constrained set of styling APIs based on props. It uses Emotion underneath which abstracts us away from a lot of the challenges when dealing with global CSS.

Theme UI uses "presentational context" to allow a component to apply styling to child elements without introducing global styles. You can use a styles object in your configuration to apply theme-aware styles to ensure consistency.

John Otander: [00:00] Theme UI is a library for building themeable React apps. It's built with Styled System, which provides a constrained set of styling APIs based on props. You can think of it as Tachyons or Tailwind, but it's on steroids because style as a function is much more flexible than classes when it comes to component-based design.

[00:19] React prop can return multiple CSS declarations. They can also be dynamic in nature. Theme UI uses Emotion underneath the covers. It's a CSS and JS library that abstracts us away from a lot of the challenges of dealing with global CSS. This is particularly important with Theme UI because we don't want to leak styles.

[00:40] Theme UI is built to work with MDX out of the box. It uses presentational context in order to apply styling to child elements without leaking styles. It's inspired by Typography.js, but brings it to the next level. With Theme UI, you can use a Styles object in your configuration to apply theme-aware styles to ensure consistency. This allows you to target theme-aware styles different objects that will be rendered from your markdown, just like an h1.

[01:09] Theme UI adheres to the System UI Theme Specification. This ensures interoperability amongst other tools and improving the developer experience with reduced cognitive overhead. This ensures the implementation can be shared amongst things like an editor for the theme itself in the style guide, which displays its values.

[01:30] Theme UI also introduces the SX prop. It's similar to Emotion CSS prop, but it's theme-aware. This means you can references something like color primary in order to reach into your theme, look in colors, and try and find a primary value.

[01:46] All in all, Theme UI is a great fit for something that needs to be themeable or is content heavy. It has built-in color mode support, forces your styles to be consistent based on constraints, and doesn't leak global styles.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today