Socket
Socket
Sign inDemoInstall

@headlessui/react

Package Overview
Dependencies
8
Maintainers
4
Versions
597
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @headlessui/react

A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.


Version published
Weekly downloads
1.8M
increased by2.76%
Maintainers
4
Install size
777 kB
Created
Weekly downloads
 

Package description

What is @headlessui/react?

The @headlessui/react package provides a set of completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS, for React projects. It allows developers to build fully accessible UI components without having to design the visual part from scratch, focusing instead on functionality and accessibility.

What are @headlessui/react's main functionalities?

Dropdown Menu

This feature allows developers to create a dropdown menu with accessible interactions. The example shows a basic dropdown menu with two options, highlighting the active option.

import { Menu } from '@headlessui/react';

<Menu>
  <Menu.Button>More</Menu.Button>
  <Menu.Items>
    <Menu.Item>
      {({ active }) => (
        <a
          className={`${active ? 'bg-blue-500 text-white' : 'text-gray-900'}`}
          href="/account-settings"
        >
          Account settings
        </a>
      )}
    </Menu.Item>
    <Menu.Item>
      {({ active }) => (
        <a
          className={`${active ? 'bg-blue-500 text-white' : 'text-gray-900'}`}
          href="/sign-out"
        >
          Sign out
        </a>
      )}
    </Menu.Item>
  </Menu.Items>
</Menu>

Dialog (Modal)

This feature enables the creation of a dialog (modal) component. The example demonstrates how to use the Dialog component to create a modal that can be opened, closed, and contains accessible titles and descriptions.

import { Dialog } from '@headlessui/react';
import { useState } from 'react';

function MyDialog() {
  let [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Open Dialog</button>

      <Dialog open={isOpen} onClose={() => setIsOpen(false)}>
        <Dialog.Overlay />

        <Dialog.Title>Deactivate account</Dialog.Title>
        <Dialog.Description>
          This will permanently deactivate your account
        </Dialog.Description>

        <button onClick={() => setIsOpen(false)}>Deactivate</button>
        <button onClick={() => setIsOpen(false)}>Cancel</button>
      </Dialog>
    </>
  );
}

Other packages similar to @headlessui/react

Readme

Source

@headlessui/react

A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.

Total Downloads Latest Release License

Installation

npm install @headlessui/react

Documentation

For full documentation, visit headlessui.dev.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Headless UI on GitHub

For casual chit-chat with others using the library:

Join the Tailwind CSS Discord Server

FAQs

Last updated on 15 Apr 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc