Custom Machines for Zag JS. Visit zagjs.com for full usage guide and more information.
- Lottie
npm i --save @zag-js-recipes/{component}
# or
yarn add @zag-js-recipes/{component}
{component}
represents any component machine like dialog (@zag-js-recipes/lottie
)
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 applications
import * as lottie from "@zag-js-recipes/lottie";
import { normalizeProps, useMachine } from "@zag-js/react";
function Example() {
// if you need access to `state` or `send` from machine
const [state, send] = useMachine(lottie.machine({ id: "2" }));
// convert machine details into `DOM` props
const api = lottie.connect(state, send, normalizeProps);
// consume into components
return <div {...api.lottieProps} />
}
Our build is managed with esbuild and turborepo to provide fast, concurrent builds across the packages.
build-fast
: Build the CJS and ESM versions, without the types.build
: Build the CJS, ESM and DTS files. This is the actual production build that we run in the CI.start
: The command to run when developing for Zag. It runs thebuild:fast
command, watches for changes and rebuilds as needed.
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 project
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.
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 project
generate-machine
: Generates a new machine package in thepackages/
directory. It sets up the required files and structure for new machine.generate-util
: Generates a new utility package in thepackages/utilities
directory.
test
: Run the tests for all packageslint
: Lint all packages
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 Β© Abraham Aremu