
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fixโa new CLI tool that turns CVE alerts into safe, automated upgrades.
@zag-js/react
Advanced tools
@zag-js/react is a collection of accessible, headless UI components for React. It provides a set of hooks and utilities to build custom UI components with accessibility and state management in mind.
Accordion
The Accordion feature allows you to create collapsible sections of content. The useAccordion hook provides the necessary props to manage the state and accessibility of the accordion items.
import { useAccordion } from '@zag-js/react';
function AccordionComponent() {
const { getAccordionProps, getItemProps } = useAccordion();
return (
<div {...getAccordionProps()}>
<div {...getItemProps({ index: 0 })}>Item 1</div>
<div {...getItemProps({ index: 1 })}>Item 2</div>
</div>
);
}
Tabs
The Tabs feature provides a way to create tabbed interfaces. The useTabs hook manages the state and accessibility of the tabs and their corresponding panels.
import { useTabs } from '@zag-js/react';
function TabsComponent() {
const { getTabListProps, getTabProps, getTabPanelProps } = useTabs();
return (
<div>
<div {...getTabListProps()}>
<button {...getTabProps({ index: 0 })}>Tab 1</button>
<button {...getTabProps({ index: 1 })}>Tab 2</button>
</div>
<div {...getTabPanelProps({ index: 0 })}>Content 1</div>
<div {...getTabPanelProps({ index: 1 })}>Content 2</div>
</div>
);
}
Dialog
The Dialog feature helps in creating modal dialogs. The useDialog hook provides the necessary props to control the dialog's open/close state and ensure it is accessible.
import { useDialog } from '@zag-js/react';
function DialogComponent() {
const { getDialogProps, getTriggerProps } = useDialog();
return (
<div>
<button {...getTriggerProps()}>Open Dialog</button>
<div {...getDialogProps()}>This is a dialog</div>
</div>
);
}
Headless UI is a set of completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS. It provides similar functionality to @zag-js/react but is more tightly integrated with Tailwind CSS, making it a great choice for projects already using Tailwind.
React Aria is a library of React Hooks that provides accessible UI primitives. It offers similar headless components and focuses on accessibility, much like @zag-js/react, but with a broader range of low-level hooks for building custom components.
FAQs
The react wrapper for zag
The npm package @zag-js/react receives a total of 162,254 weekly downloads. As such, @zag-js/react popularity was classified as popular.
We found that @zag-js/react 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.
Product
Automatically fix and test dependency updates with socket fixโa new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
Weโre excited to announce a powerful new capability in Socket: historical data and enhanced analytics.