Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@zag-js/anatomy
Advanced tools
@zag-js/anatomy is a utility library for creating and managing component anatomy in a consistent and reusable way. It helps in defining the structure and parts of a component, making it easier to manage and style complex UI components.
Define Component Anatomy
This feature allows you to define the different parts of a component. In this example, a button component is defined with root, icon, and label parts.
const { defineParts } = require('@zag-js/anatomy');
const buttonAnatomy = defineParts({
root: 'button',
icon: 'button__icon',
label: 'button__label'
});
console.log(buttonAnatomy.parts); // { root: 'button', icon: 'button__icon', label: 'button__label' }
Get Part Selectors
This feature allows you to get the CSS selectors for each part of the component. This is useful for styling the component parts consistently.
const { defineParts } = require('@zag-js/anatomy');
const buttonAnatomy = defineParts({
root: 'button',
icon: 'button__icon',
label: 'button__label'
});
const selectors = buttonAnatomy.selectors;
console.log(selectors.root); // .button
console.log(selectors.icon); // .button__icon
console.log(selectors.label); // .button__label
Extend Component Anatomy
This feature allows you to extend an existing component anatomy with additional parts. In this example, the button anatomy is extended to include an iconWrapper part.
const { defineParts } = require('@zag-js/anatomy');
const buttonAnatomy = defineParts({
root: 'button',
icon: 'button__icon',
label: 'button__label'
});
const iconButtonAnatomy = buttonAnatomy.extend({
iconWrapper: 'button__icon-wrapper'
});
console.log(iconButtonAnatomy.parts); // { root: 'button', icon: 'button__icon', label: 'button__label', iconWrapper: 'button__icon-wrapper' }
styled-components is a library for React and React Native that allows you to use component-level styles in your application. It provides a way to style components using tagged template literals. While @zag-js/anatomy focuses on defining and managing component parts, styled-components focuses on styling components directly.
Emotion is a library designed for writing CSS styles with JavaScript. It provides powerful and flexible tools for styling applications. Similar to styled-components, Emotion focuses on styling, whereas @zag-js/anatomy focuses on defining the structure and parts of components.
FAQs
Unknown package
The npm package @zag-js/anatomy receives a total of 156,381 weekly downloads. As such, @zag-js/anatomy popularity was classified as popular.
We found that @zag-js/anatomy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.