Walking the Line Between Flexibility and Consistency in Component Libraries

Rate this content
Bookmark

Design systems aim to bring consistency to a brand's design and make the UI development productive. Component libraries with well thought API can make this a breeze. But, sometimes an API choice can accidentally overstep and slow the team down! There's a balance there... somewhere. Let's explore some of the problems and possible creative solutions.

This talk has been presented at React Summit 2022, check out the latest edition of this React Conference.

FAQ

Primer is a React component library used by GitHub's design system team to create consistent and flexible user interfaces across the platform.

Primer, compared to Shopify's Polaris, offers a balance between flexibility and consistency tailored to GitHub's specific needs. Polaris is highly opinionated with a strict API for predictable results, while Material UI offers extensive flexibility and customization options, suitable for a wide range of applications.

The design of a component library like Primer is influenced by whether it is built for a specific product or is open source, the centralization of design decisions, the maturity of design patterns, and the specific needs and context of the company or product it is intended for.

An action list in GitHub's component library is a configurable component used to display a list of items or actions, where each item can trigger a specific function, and additional properties like icons or dividers can be included.

GitHub ensures flexibility in their component API by allowing for composition over configuration, enabling users to customize components by assembling them from smaller, configurable parts. This approach allows for better adaptation to various use cases while maintaining control over the components.

Slots in GitHub's component design allow for inserting specific types of child components into predefined places within a parent component. This technique ensures that components maintain a consistent structure while allowing for flexibility and customization in the content they display.

GitHub handles the integration of user-defined content through the use of slots, which provide designated areas for custom content while maintaining the structural integrity and design consistency of the component.

Siddharth Kshetrapal
Siddharth Kshetrapal
27 min
17 Jun, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk discusses the comparison between Polaris and Material UI component libraries in terms of consistency and flexibility. It highlights the use of the action list pattern and the customization options available for the action list component. The Talk also emphasizes the introduction of a composite component to improve API flexibility. Additionally, it mentions the importance of finding the right balance between flexibility and consistency and the use of types to enforce specific child components.

1. Introduction to Component Libraries

Short description:

I'm Sid, a maintainer of Primer, the React component library used by GitHub. I'll discuss consistency and flexibility in component libraries by comparing Polaris and Material UI. Polaris provides a descriptive way to create banners with various components and actions. Material UI, on the other hand, uses alerts instead of banners with different severity levels and customizable icons.

So, let's go. I'm Sid. I work on the design system team at GitHub, and I am one of the maintainers of Primer which is the React component library that other teams at GitHub use to build the things that you actually like to use.

So before I start, I kind of want to give a warning. So GitHub is part of Microsoft now, so I have to say this, these opinions are my own and not of my employer yet. I'm trying to change them, I'm working on it. I haven't been there long enough, so give me a while. All right.

So let's talk about consistency and flexibility when it comes to component libraries. So the thing with component libraries is that there's no one true answer, and it really depends on a bunch of context. So when I started, I started looking at other component libraries, so that's big enough. I looked at Polaris, which is Shopify's design system, and I looked at Material UI, which is an open source component library, and this is one component that they have both, like So with Polaris, how you create this banner is you say I want a banner. The status of this banner is critical. And here's the title. And it renders all of that. The icon is there. The cross button is there. All of that is there. And if you want to add an action, you say action object where you say this is the content, and if this is clicked, this is the function that you should call. So very, very descriptive. There's a lot of config here. If I have to build the same thing with Material UI, that looks something like this. I have an alert. They don't call it banner, they call it alert. Doesn't matter. And you give it a severity of error. And then you can pass it an icon. So it could be any icon. It doesn't have to be this icon. You could basically give any icon.

2. Flexibility in Component Libraries

Short description:

Material UI and Polaris have different levels of flexibility in their component APIs. Polaris is highly opinionated with a strict API, leading to consistent outcomes. Material UI, as an open-source library, offers a highly flexible API that depends on the company and context. When considering a component library, factors such as product type, design decision centralization, and pattern maturity determine the appropriate level of flexibility.

It's very flexible. And then it also lets you overwrite some of the CSS. So I can actually change the border color here like I have. And then finally... Ouch. Okay. Finally, if I want some content inside it, there is an alert title. But if I want a button, I can just bring my own button and put it there. And then I'm responsible for this margin that you see here. Okay.

So if you compare these two component APIs, they're creating the same component, but there's a lot of difference between what the API looks like and how much flexibility do you have. And that brings me to the spectrum of flexibility. So, when I think of Shopify as Polaris, I think Polaris is somewhere here, where it's very opinionated, it has an extremely strict API, and that leads to these predictable, consistent outcomes. You can use the alert wherever you want, you get something similar. But of course, it can get a bit rigid and restricting if you're experimenting with it. On the other hand, Material UI is probably all the way here. It's open source, so there is no assumption of context. It has to have a very flexible API, because the Material team cannot really guess what you'll use it for. Which means it kind of depends on your company, your context. And if you're not careful, if you use Material UI as your design system, it can become messy or fragmented or you just need a lot of guardrails in place.

So, when I was looking at Primer React, I was like, okay, where do we lie? Or if you're thinking about it for your component library? The answer of course always is it depends. And it depends on these factors too. Is it built for a specific product or is it open source? Is the design decision centralized because you have a certain design team or do individual products have their own design team? So is it scattered? How old is the product? How mature are the patterns? If you already have established patterns, then it's easier to be more consistent, versus If you're still finding the patterns, then it's better to be more flexible. And I looked at this and I was like, we built for a specific product. We do have a centralized design team. We have established patterns. So GitHub is like super old. So probably somewhere here, like this is how much flexibility we probably should allow. So to showcase this, I looked at this component. This is a, this is kind of a common pattern that you've seen a bunch of places.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Design Systems: Walking the Line Between Flexibility and Consistency
React Advanced Conference 2021React Advanced Conference 2021
47 min
Design Systems: Walking the Line Between Flexibility and Consistency
Top Content
The Talk discusses the balance between flexibility and consistency in design systems. It explores the API design of the ActionList component and the customization options it offers. The use of component-based APIs and composability is emphasized for flexibility and customization. The Talk also touches on the ActionMenu component and the concept of building for people. The Q&A session covers topics such as component inclusion in design systems, API complexity, and the decision between creating a custom design system or using a component library.
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
There is a need for a standard library of APIs for JavaScript runtimes, as there are currently multiple ways to perform fundamental tasks like base64 encoding. JavaScript runtimes have historically lacked a standard library, causing friction and difficulty for developers. The idea of a small core has both benefits and drawbacks, with some runtimes abusing it to limit innovation. There is a misalignment between Node and web browsers in terms of functionality and API standards. The proposal is to involve browser developers in conversations about API standardization and to create a common standard library for JavaScript runtimes.
Build a Design System with React and Tailwind CSS
React Summit 2022React Summit 2022
27 min
Build a Design System with React and Tailwind CSS
Top Content
This Talk discusses design systems and how to build one using React and Tailwind CSS. Tailwind CSS provides utility classes for building complex layouts without writing CSS rules. Custom colors can be added to the Tailwind CSS config file, and font styles and text sizes can be customized. The entire Tailwind CSS configuration can be customized to meet specific requirements. Base styles can be added to the config file itself using a plugin. Reusable components can be created with Tailwind CSS, allowing for easy customization of size and color.
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
React Summit 2022React Summit 2022
17 min
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
Top Content
Today's Talk discusses building flexible, resilient, and future-proof React components using composition and configuration approaches. The composition approach allows for flexibility without excessive conditional logic by using multiple components and passing props. The context API can be used for variant styling, allowing for appropriate styling and class specification. Adding variants and icons is made easy by consuming the variant context. The composition and configuration approaches can be combined for the best of both worlds.
Building Cross-Platform Component Libraries for Web and Native with React
React Advanced Conference 2021React Advanced Conference 2021
21 min
Building Cross-Platform Component Libraries for Web and Native with React
Top Content
This Talk discusses building cross-platform component libraries for React and React Native, based on a successful project with a large government-owned news organization. It covers the requirements for React Native knowledge, building cross-platform components, platform-specific components, styling, and the tools used. The Talk also highlights the challenges of implementing responsive design in React Native.
Find Out If Your Design System Is Better Than Nothing
React Summit 2022React Summit 2022
20 min
Find Out If Your Design System Is Better Than Nothing
Building a design system without adoption is a waste of time. Grafana UI's adoption is growing consistently over time. The factors affecting design system adoption include the source mix changing, displacement of Homebrew components by Grafana UI, and the limitations of Grafana UI's current state. Measuring adoption is important to determine the success of a design system. The analysis of code through static code analysis tools is valuable in detecting and tracking component usage.

Workshops on related topic

Build a Data-Rich Beautiful Dashboard With MUI X's Data Grid and Joy UI
React Summit 2023React Summit 2023
137 min
Build a Data-Rich Beautiful Dashboard With MUI X's Data Grid and Joy UI
Top Content
WorkshopFree
Sam Sycamore
Siriwat (Jun) Kunaporn
2 authors
Learn how to put MUI’s complete ecosystem to use to build a beautiful and sophisticated project management dashboard in a fraction of the time that it would take to construct it from scratch. In particular, we’ll see how to integrate the MUI X Data Grid with Joy UI, our newest component library and sibling to the industry-standard Material UI.
Table of contents:- Introducing our project and tools- App setup and package installation- Constructing the dashboard- Prototyping, styling, and themes - Joy UI features- Filtering, sorting, editing - Data Grid features- Conclusion, final thoughts, Q&A
Learn To Use Composables: The Swiss Army Knife Of Vue Developers
Vue.js Live 2024Vue.js Live 2024
163 min
Learn To Use Composables: The Swiss Army Knife Of Vue Developers
Workshop
Juan Andrés Núñez Charro
Juan Andrés Núñez Charro
Composables (composition functions) are stateful/stateless functions that can leverage Vue's reactivity API, decoupling it from components.This shift in perspective opens the possibility for tackling common scenarios in a new and creative way. In this workshop, you will learn how to solve typical problems every Vue developer faces, using composables:
- Data store;- Component cross-communication;- Utility functions (DOM, API, etc);And more.
Rapid UI Development in React: Harnessing Custom Component Libraries & Design Systems
React Advanced Conference 2022React Advanced Conference 2022
118 min
Rapid UI Development in React: Harnessing Custom Component Libraries & Design Systems
Workshop
Richard Moss
Richard Moss
In this workshop, we'll take a tour through the most effective approaches to building out scalable UI components that enhance developer productivity and happiness :-) This will involve a mix of hands-on exercises and presentations, covering the more advanced aspects of the popular styled-components library, including theming and implementing styled-system utilities via style props for rapid UI development, and culminating in how you can build up your own scalable custom component library.
We will focus on both the ideal scenario---where you work on a greenfield project---along with tactics to incrementally adopt a design system and modern approaches to styling in an existing legacy codebase with some tech debt (often the case!). By the end of the workshop, you should feel that you have an understanding of the tradeoffs between different approaches and feel confident to start implementing the options available to move towards using a design system based component library in the codebase you work on.
Prerequisites: - Familiarity with and experience working on large react codebases- A good understanding of common approaches to styling in React