chakra-ui / zag
Build your design system in React, Solid, Vue or Svelte. Powered by finite state machines
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing chakra-ui/zag in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewZag Finite state machines for accessible JavaScript components • **Write once, use everywhere 🦄**: The component interactions are modelled in a framework agnostic way. We provide adapters for JS frameworks like React, Solid, Svelte, or Vue. • **Focus on accessibility ♿️**: Zag is built with accessibility in mind. We handle many details related to keyboard interactions, focus management, aria roles and attributes. • **Headless ✨**: The machine APIs are completely unstyled and gives you the control to use any styling solution you prefer. • **Powered by state machines 🌳**: Zag is built on top of the latest ideas in Statecharts. We don't follow the SCXML specifications, but we've created an API that we think will help us build more complex components fast. --- Documentation To see the documentation, visit zagjs.com/ Releases For changelog, Check CHANGELOG.md --- Problem With the rise of design systems and component-driven development, there's an endless re-implementation of common component patterns (Tabs, Menu, Modal, etc.) in multiple frameworks. Most of these implementations seem to be fairly similar in spirit, the differences being around the reactivity and effects systems for the framework (e.g. , in React.js). Framework specific solutions tend to grow in complexity over time and often become hard to understand, debug, improve or test. Solution **Zag** is a JavaScript API that implements common component patterns using the state machine methodology. Installation > represents any component machine like dialog ( ), tooltip ( ) , etc. For framework specific solutions, we provide simple wrappers to help you consume the component state machines. • ⚛️ - React hooks for consuming machines in React applications • 💚 - Vue composition for consuming machines in Vue applications • 🎷 - Solid.js utilities for consuming machines in Solid.js applications • 🎷 - Svelte utilities for consuming machines in Svelte applications Usage --- Guiding Principles • All component machines and tests are modelled according to the WAI-ARIA authoring practices • Write end-to-end tests for every component based on the WAI-ARIA spec. **Regardless of the framework, users expect component patterns to work the same way!** • All machines should be light-weight, simple, and easy to understand. Avoid using complex machine concepts like spawn, nested states, etc. --- Fun Facts **Zag** means to _take a sharp change in direction_. This clearly describes our approach of using state machines to power the logic behind UI components. Teasers • When you see someone using classic react, vue, solid or svelte to build an interactive UI component that exists in Zag, tell them to **"zag it!"** ⚡️ • Anyone using Zag will be called a **"zagger"** 💥 • The feeling you get when you use Zag will be called **"zagadat!"** 🚀 • The Zag community will be called **"zag nation"** 🔥 --- Commands Build commands Our build is managed with esbuild and turborepo to provide fast, concurrent builds across the packages. • : Build the CJS, ESM and DTS files. This is the actual production build that we run in the CI. Examples Since zag is framework agnostic, we need a way to test it within a framework. The directory includes starter projects for the frameworks we support. • : Starts the Next.js TypeScript project • : Starts the Vue 3 TypeScript project • : Starts the Solid TypeScript project • : Starts the Svelte TypeScript project E2E Tests We've setup end-to-end tests for every machine we built. We use Playwright for testing and we ensure that the component works the same way regardless of the framework. • : Starts the E2E tests for the React project • : Starts the E2E tests for the Vue project • : Starts the E2E tests for the Solid project Contributing new machines/features • : Generates a new machine package in the directory. It sets up the required files and structure for new machine. • : Generates a new utility package in the directory. Other commands • : Run the tests for all packages • : Lint all packages Website • : Starts the website --- Inspirations • Duplicate code in Chakra UI React and Vue 😅 • Thoughts on Pure UI - Guillermo Rauch • Pure UI Control - Adam Solve • Material Components Web for inspiring my first prototype • Radix UI for inspiring the dimissable and presence pattern • XState for inspiring the base implementation of the state machine • Vue.js and Lit for inspiring new patterns in the machine ( and ) • Sonner for inspiring the toast machine --- Contributions Looking to contribute? Look for the **Good First Issue** label. 🐛 Bugs Please file an issue for bugs, missing documentation, or unexpected behavior. 💡 Feature Requests Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on. --- License MIT © Chakra Systems Inc.