Gathering detailed insights and metrics for @zag-js/core
Gathering detailed insights and metrics for @zag-js/core
Gathering detailed insights and metrics for @zag-js/core
Gathering detailed insights and metrics for @zag-js/core
Finite state machines for building accessible design systems and UI components. Works with modern frameworks, and even just Vanilla JS
npm install @zag-js/core
@zag-js/text-selection@0.78.0
Published on 27 Nov 2024
@zag-js/stringify-state@0.78.0
Published on 27 Nov 2024
@zag-js/popper@0.78.0
Published on 27 Nov 2024
@zag-js/remove-scroll@0.78.0
Published on 27 Nov 2024
@zag-js/numeric-range@0.78.0
Published on 27 Nov 2024
@zag-js/rect-utils@0.78.0
Published on 27 Nov 2024
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
4,090 Stars
4,067 Commits
170 Forks
16 Watching
12 Branches
78 Contributors
Updated on 28 Nov 2024
TypeScript (69.2%)
MDX (17.29%)
JavaScript (9.38%)
CSS (3.79%)
Handlebars (0.34%)
Cumulative downloads
Total Downloads
Last day
-16.6%
41,283
Compared to previous day
Last week
-10.2%
260,949
Compared to previous week
Last month
88%
1,657,814
Compared to previous month
Last year
285.3%
5,786,127
Compared to previous year
3
1
Finite state machines for accessible JavaScript components
To see the documentation, visit zagjs.com/
For changelog, Check CHANGELOG.md
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. useState
, useEffect
in React.js). Framework specific solutions tend to grow
in complexity over time and often become hard to understand, debug, improve or test.
Zag is a JavaScript API that implements common component patterns using the state machine methodology.
1npm i --save @zag-js/{component} 2 3# or 4 5yarn add @zag-js/{component}
{component}
represents any component machine like dialog (@zag-js/dialog
), tooltip (@zag-js/tooltip
) , etc.
For framework specific solutions, we provide simple wrappers to help you consume the component state machines.
@zag-js/react
- React hooks for consuming machines in React applications@zag-js/vue
- Vue composition for consuming machines in Vue applications@zag-js/solid
- Solid.js utilities for consuming machines in Solid.js applications1import { normalizeProps, useMachine } from "@zag-js/react" 2import * as toggle from "@zag-js/toggle-group" 3import { useId } from "react" 4 5export function ToggleGroup() { 6 const [state, send] = useMachine(toggle.machine({ id: useId() })) 7 const api = toggle.connect(state, send, normalizeProps) 8 9 return ( 10 <div {...api.getRootProps()}> 11 <button {...api.getItemProps({ value: "bold" })}>B</button> 12 <button {...api.getItemProps({ value: "italic" })}>I</button> 13 <button {...api.getItemProps({ value: "underline" })}>U</button> 14 </div> 15 ) 16}
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.
When you see someone using classic react, vue or solid 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" 🔥
Our build is managed with esbuild and turborepo to provide fast, concurrent builds across the packages.
build
: Build the CJS, ESM and DTS files. This is the actual production build that we run in the CI.Since zag is framework agnostic, we need a way to test it within a framework. The examples/
directory includes starter
projects for the frameworks we support.
start-react
: Starts the Next.js TypeScript projectstart-vue
: Starts the Vue 3 TypeScript projectstart-solid
: Starts the Solid TypeScript projectWe'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.
e2e-react
: Starts the E2E tests for the React projecte2e-vue
: Starts the E2E tests for the Vue projecte2e-solid
: Starts the E2E tests for the Solid projectgenerate-machine
: Generates a new machine package in the packages/
directory. It sets up the required files and
structure for new machine.generate-util
: Generates a new utility package in the packages/utilities
directory.test
: Run the tests for all packageslint
: Lint all packagesstart-website
: Starts the websitecomputed
and watch
)Looking to contribute? Look for the Good First Issue label.
Please file an issue for bugs, missing documentation, or unexpected behavior.
Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.
MIT © Segun Adebayo
No vulnerabilities found.
No security vulnerabilities found.