Code at the Speed of Design in Chakra UI Vue

Rate this content
Bookmark

With Chakra UI, we are able to override component styles to express custom design systems with accessible Vue components. This talk explores the new theme API in v1 and how you can use it to quickly build custom UIs for your application.

FAQ

Chakra UI View is a component library focused on accessibility, built with WAI-ARIA-spec compliance for authored components. It allows developers to easily extend themes, define custom variants and sizes, and create custom components themed using Chakra UI.

Chakra UI View V1 features a full TypeScript rewrite, a re-implemented theming API, the integration of composables, and a factory API that provides component primitives which can be styled directly or used to enhance non-Chakra UI styled components.

The Theming API in Chakra UI View V1 allows for component overrides, creation of custom variants, and defining custom sizes for components. This flexibility helps bridge the gap between design and code, facilitating more efficient implementation of UIs directly within the browser.

Chakra UI View enhances Vue.js projects by providing accessible, customizable components that are easy to theme and adapt. It supports efficient coding with less boilerplate, facilitating rapid UI development that aligns closely with design specifications.

The factory function API in Chakra UI View V1 allows developers to provide a component that is not initially styled with Chakra UI. The API then returns the same component with added style props, enabling it to work natively with Chakra UI styles.

Yes, Chakra UI View is compatible with various build tools including Vite and Webpack. For Vue 3 projects, using Vite is highly recommended for optimal performance and ease of use.

Future plans for Chakra UI View include implementing a zero-runtime build to optimize CSS management and using state machines for logic-heavy components like accordions, enhancing component reusability and state management.

Jonathan Bakebwa
Jonathan Bakebwa
23 min
21 Oct, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Jonathan Bakebwa introduces Chakra UI View, a component library focused on accessibility, with features like extending themes and defining custom variants. The upcoming versions of Chakra UI V1 will introduce a zero-runtime build and a theming API with component overrides, custom variants, and custom sizes. The Talk demonstrates how to implement a button design using Chakra UI, customize button styles, create custom button sizes, and use icons from external libraries. Chakra UI allows for quick implementation of UI designs and is recommended for developers looking to enhance their designs.

1. Introduction to Chakra UI View

Short description:

Jonathan Bakebwa introduces Chakra UI View, a component library focused on accessibility. It allows for extending themes, defining custom variants, sizes, and components. The V1 release includes a full TypeScript rewrite, a new theming API, composables, and a factory API for styling components. The community's support with tools like Volar and Vite makes it easier to use with Vue 3.

Hi, everybody. My name is Jonathan Bakebwa. I am the creator and one of the maintainers of Chakra UI View, and I'm also a UI engineer and engineering manager at RCT.ai. During day, that's what I do. I am also a final year computer science major at Beijing Institute of Technology, and I am excited to be here today at Vue.js London talking to us about coding at the speed of design with Chakra UI View.

I'm going to start by introducing Chakra UI as a component library. Chakra UI is a component library with focus on accessibility. And what that means is that all components in the Chakra UI library have been built from the ground up with WAI-ARIA-spec compliance for authored components.

We've also built in the ability to extend the theme of the Chakra UI components, and this becomes so much easier inside of V1, and the way that we've made it more convenient is that you can now override the initial rendered styles for components that are natively inside Chakra UI. And we've also added more features that allow you to define custom variants, custom sizes, and even create your own custom components and theme them using Chakra UI. And what this allows for is that you have a lot more concise code and you have a bit more speed when it comes to implementing UIs. So we see this as a step towards bridging the gap between design and code, especially for within the browser context.

So for V1, we did a full TypeScript rewrite. And what we did was that we re-implemented the theming API, and I want to talk about the theming API because that's going to be the focus of this talk. And we also were able to implement some composables. And so what we did was that when we were writing the components for V1 was that we split a of the logic out into composables, and the component only had to deal with the styles for that component. So this allows you to be able to consume some of the hooks that are commonly used. So that means you don't need to import another third-party library for hooks that we are exposing.

The other thing that we've added inside of V1 is a factory API. So this factory API provides some component primitives that you can style directly. And you can also, since it's a function, you can also use it to...you can also provide it a component that's not initially styled with Chakra UI. And this component will be able to... The return value will now be the same component, with the same props, everything will be the same. With the differences, you can now add some style props to it, and it will work natively. So with the new Theming API, you can also define custom components. And we've also provided a new API that will...with the use style config. And what this allows you to do is to define styles within your theme, and you can then consume those values when you create your own custom components. And since it's a full TypeScript rewrite, we have spent a lot of work and effort trying to make sure that all the style props are accessible to you within your Vue templates. And thanks to the community for working with different tools like Volar and with Vite, all this becomes a lot more easier if you're going into Vue 3. We definitely recommend using Vite for Chakra UI Vue, Vue V1.

2. Upcoming Features in Chakra UI V1

Short description:

The upcoming versions of Chakra UI V1 will introduce a zero-runtime build, state machines for logic-heavy components, and a theming API with component overrides, custom variants, and custom sizes. The component overrides allow for overriding base styles for specific components, while custom variants and sizes provide flexibility in styling. These features make it easier to create unique UI designs using Chakra UI.

If you have Webpack, it's also possible to use it. Some of the ideas we're exploring inside of probably the later versions of V1 would be a zero-runtime build. And what this would allow for is that we would walk through your entire template context because we realized most of our users are using Chakra UI to define maybe static properties, static style props onto the components. And so, what we can also do is that we can walk through the entire your template and we can then extract those style props into CSS that we'll then inject into your single file component styles.

We're also planning to, in the future, we're also planning to use state machines for logic heavy components. For example, the accordion has a lot of logic that we have to compute and a lot of states that we have to manage. And the best way to deal with this that we discovered as a team was to use state machines. And for this, what this allows us to do is that the state machine only returns the current state that we then destructure into the components that are then rendered on the page. So this makes it a lot more convenient to use, and it's certainly a good way for us to share logic. And so, in the future, if somebody decides to build ChakraUI for Svelte, they don't have to rewrite all this logic and use side effects for things that would probably already exist inside a state machine, they just need to access that state and then provide it to their components, which is really, really convenient.

So what's coming inside of the V1 theming API? As I mentioned before, we're going to be providing component overrides, which we'll then look at today. We're also providing a custom variants API. We're also providing the ability to create custom sizes for your components. We're also providing the factory function API and custom components. So for today's talk, I want to focus on three attributes that the theming API will cover inside of V1. The one, among so many, by the way, since we're going to have some time, we can only talk about three of them. The first one will be component overrides. So inside of the theme object, for those of us that are quite familiar with the V1, of V0.x of chakray y, within the plugin options, there's a value called extend theme. And on the extend theme, for V1 we've added a key called the components key. So this component key allows you to now override the base styles for the component that you are then choosing to override within the extend theme. So when you define the base styles, those styles get applied to all the buttons. So you don't need to create a custom button so it can do that. The second thing we have allowed for you to do is to define custom variants. So now within Chakra UI, you can then create a custom variant within for that component that you are, are hoping to consume the variant. And finally, you can then define custom sizes, which is really convenient for creating an extra large button. If you need a button that's 100 meters wide, you can certainly now do that with Chakra UI view, I wouldn't advise you creating a 100 meter wide button, it wouldn't fit on the screen. But it's certainly possible.

So let's look at all of this in action, what's going to, how we're going to implement this, this, how we're going to see these things in action. So for starters, I went online and I tried to collect you know, a bit of a user interface with a few custom, which has components that are not implemented inside of, whose designs are not implemented inside of Chakra UI. So looking very quickly at this, this UI, I can see there's a button here and this button appears to have a different theme compared to the default styles that are provided inside of Chakra UI.

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

Everything Beyond State Management in Stores with Pinia
Vue.js London Live 2021Vue.js London Live 2021
34 min
Everything Beyond State Management in Stores with Pinia
Top Content
When we think about Vuex, Pinia, or stores in general we often think about state management and the Flux patterns but not only do stores not always follow the Flux pattern, there is so much more about stores that make them worth using! Plugins, Devtools, server-side rendering, TypeScript integrations... Let's dive into everything beyond state management with Pinia with practical examples about plugins and Devtools to get the most out of your stores.
Welcome to Nuxt 3
Vue.js London Live 2021Vue.js London Live 2021
29 min
Welcome to Nuxt 3
Top Content
Explain about NuxtJS codebase refactor and challenges facing to implement Vue 3, Vite and other packages.
One Year Into Vue 3
Vue.js London Live 2021Vue.js London Live 2021
20 min
One Year Into Vue 3
Top Content
Vue 3 may still sound new to many users, but it's actually been released for over a year already. How did Vue 3 evolve during this period? Why did it take so long for the ecosystem to catch up? What did we learn from this process? What's coming next? We will discuss these questions in this talk!
Utilising Rust from Vue with WebAssembly
Vue.js London Live 2021Vue.js London Live 2021
8 min
Utilising Rust from Vue with WebAssembly
Top Content
Rust is a new language for writing high-performance code, that can be compiled to WebAssembly, and run within the browser. In this talk you will be taken through how you can integrate Rust, within a Vue application, in a way that's painless and easy. With examples on how to interact with Rust from JavaScript, and some of the gotchas to be aware of.
Vue: Feature Updates
Vue.js London 2023Vue.js London 2023
44 min
Vue: Feature Updates
Top Content
The creator of Vue js gives an update on the new features of the technology.
Local State and Server Cache: Finding a Balance
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
How many times did you implement the same flow in your application: check, if data is already fetched from the server, if yes - render the data, if not - fetch this data and then render it? I think I've done it more than ten times myself and I've seen the question about this flow more than fifty times. Unfortunately, our go-to state management library, Vuex, doesn't provide any solution for this.For GraphQL-based application, there was an alternative to use Apollo client that provided tools for working with the cache. But what if you use REST? Luckily, now we have a Vue alternative to a react-query library that provides a nice solution for working with server cache. In this talk, I will explain the distinction between local application state and local server cache and do some live coding to show how to work with the latter.

Workshops on related topic

Vue3: Modern Frontend App Development
Vue.js London Live 2021Vue.js London Live 2021
169 min
Vue3: Modern Frontend App Development
Top Content
Featured WorkshopFree
Mikhail Kuznetcov
Mikhail Kuznetcov
The Vue3 has been released in mid-2020. Besides many improvements and optimizations, the main feature of Vue3 brings is the Composition API – a new way to write and reuse reactive code. Let's learn more about how to use Composition API efficiently.

Besides core Vue3 features we'll explain examples of how to use popular libraries with Vue3.

Table of contents:
- Introduction to Vue3
- Composition API
- Core libraries
- Vue3 ecosystem

Prerequisites:
IDE of choice (Inellij or VSC) installed
Nodejs + NPM
Using Nitro – Building an App with the Latest Nuxt Rendering Engine
Vue.js London Live 2021Vue.js London Live 2021
117 min
Using Nitro – Building an App with the Latest Nuxt Rendering Engine
Top Content
Workshop
Daniel Roe
Daniel Roe
We'll build a Nuxt project together from scratch using Nitro, the new Nuxt rendering engine, and Nuxt Bridge. We'll explore some of the ways that you can use and deploy Nitro, whilst building a application together with some of the real-world constraints you'd face when deploying an app for your enterprise. Along the way, fire your questions at me and I'll do my best to answer them.
TresJS create 3D experiences declaratively with Vue Components
Vue.js London 2023Vue.js London 2023
137 min
TresJS create 3D experiences declaratively with Vue Components
Workshop
Alvaro Saburido
Alvaro Saburido
- Intro 3D - Intro WebGL- ThreeJS- Why TresJS- Installation or Stackblitz setup - Core Basics- Setting up the Canvas- Scene- Camera- Adding an object- Geometries- Arguments- Props- Slots- The Loop- UseRenderLoop composable- Before and After rendering callbacks- Basic Animations- Materials- Basic Material- Normal Material- Toon Material- Lambert Material- Standard and Physical Material- Metalness, roughness - Lights- AmbientLight- DirectionalLight- PointLights- Shadows- Textures- Loading textures with useTextures- Tips and tricks- Misc- Orbit Controls- Loading models with Cientos- Debugging your scene- Performance
Building Vue forms with VeeValidate
Vue.js London Live 2021Vue.js London Live 2021
176 min
Building Vue forms with VeeValidate
Workshop
Abdelrahman Awad
Abdelrahman Awad
In this workshop, you will learn how to use vee-validate to handle form validation, manage form values and handle submissions effectively. We will start from the basics with a simple login form all the way to using the composition API and building repeatable and multistep forms.

Table of contents:
- Introduction to vee-validate
- Building a basic form with vee-validate components
- Handling validation and form submissions
- Building validatable input components with the composition API
- Field Arrays and repeatable inputs
- Building a multistep form
Prerequisites:
VSCode setup and an empty Vite + Vue project.
Building full-stack GraphQL applications with Hasura and Vue 3
Vue.js London Live 2021Vue.js London Live 2021
115 min
Building full-stack GraphQL applications with Hasura and Vue 3
WorkshopFree
Gavin Ray
Gavin Ray
The frontend ecosystem moves at a breakneck pace. This workshop is intended to equip participants with an understanding of the state of the Vue 3 + GraphQL ecosystem, exploring that ecosystem – hands on, and through the lens of full-stack application development.

Table of contents
- Participants will use Hasura to build out a realtime GraphQL API backed Postgres. Together we'll walk through consuming it from a frontend and making the front-end reactive, subscribed to data changes.
- Additionally, we will look at commonly-used tools in the Vue GraphQL stack (such as Apollo Client and Urql), discuss some lesser-known alternatives, and touch on problems frequently encountered when starting out.
- Multiple patterns for managing stateful data and their tradeoffs will be outlined during the workshop, and a basic implementation for each pattern discussed will be shown.
Workshop level

NOTE: No prior experience with GraphQL is necessary, but may be helpful to aid understanding. The fundamentals will be covered.
A Different Vue into Web Performance
Vue.js London Live 2021Vue.js London Live 2021
72 min
A Different Vue into Web Performance
Workshop
Abhijeet Prasad
Abhijeet Prasad
Solving your front-end performance problems can be hard, but identifying where you have performance problems in the first place can be even harder. In this workshop, Abhijeet Prasad, software engineer at Sentry.io, dives deep into UX research, browser performance APIs, and developer tools to help show you the reasons why your Vue applications may be slow. He'll help answer questions like, "What does it mean to have a fast website?" and "How do I know if my performance problem is really a problem?". By walking through different example apps, you'll be able to learn how to use and leverage core web vitals, navigation-timing APIs, and distributed tracing to better understand your performance problems.