|
| 1 | +<h3 align="center"> |
| 2 | + @headlessui/tailwindcss |
| 3 | +</h3> |
| 4 | + |
| 5 | +<p align="center"> |
| 6 | + A complementary Tailwind CSS plugin for Headless UI |
| 7 | +</p> |
| 8 | + |
| 9 | +<p align="center"> |
| 10 | + <a href="https://www.npmjs.com/package/@headlessui/tailwindcss"><img src="https://img.shields.io/npm/dt/@headlessui/tailwindcss.svg" alt="Total Downloads"></a> |
| 11 | + <a href="https://github.com/tailwindlabs/headlessui/releases"><img src="https://img.shields.io/npm/v/@headlessui/tailwindcss.svg" alt="Latest Release"></a> |
| 12 | + <a href="https://github.com/tailwindlabs/headlessui/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@headlessui/tailwindcss.svg" alt="License"></a> |
| 13 | +</p> |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +```sh |
| 18 | +npm install @headlessui/tailwindcss |
| 19 | +``` |
| 20 | + |
| 21 | +```js |
| 22 | +// tailwind.config.js |
| 23 | +module.exports = { |
| 24 | + content: [], |
| 25 | + theme: { |
| 26 | + extend: {}, |
| 27 | + }, |
| 28 | + plugins: [ |
| 29 | + require('@headlessui/tailwindcss') |
| 30 | + |
| 31 | + // Or with a custom prefix: |
| 32 | + require('@headlessui/tailwindcss')({ prefix: 'ui' }) |
| 33 | + ], |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +## Documentation |
| 38 | + |
| 39 | +Use Tailwind CSS utilities for styling the components based on their state. You can use the |
| 40 | +following variants: |
| 41 | + |
| 42 | +| Variant | Inverse variant | |
| 43 | +| ------------- | ----------------- | |
| 44 | +| `ui-open` | `ui-not-open` | |
| 45 | +| `ui-checked` | `ui-not-checked` | |
| 46 | +| `ui-selected` | `ui-not-selected` | |
| 47 | +| `ui-active` | `ui-not-active` | |
| 48 | +| `ui-disabled` | `ui-not-disabled` | |
| 49 | + |
| 50 | +Example: |
| 51 | + |
| 52 | +```js |
| 53 | +import { Menu } from '@headlessui/react' |
| 54 | + |
| 55 | +function MyDropdown() { |
| 56 | + return ( |
| 57 | + <Menu> |
| 58 | + <Menu.Button>More</Menu.Button> |
| 59 | + <Menu.Items> |
| 60 | + <Menu.Item> |
| 61 | + <a |
| 62 | + className="ui-active:bg-blue-500 ui-active:text-white ui-not-active:bg-white ui-not-active:text-black" |
| 63 | + href="/account-settings" |
| 64 | + > |
| 65 | + Account settings |
| 66 | + </a> |
| 67 | + </Menu.Item> |
| 68 | + {/* ... */} |
| 69 | + </Menu.Items> |
| 70 | + </Menu> |
| 71 | + ) |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +## Community |
| 76 | + |
| 77 | +For help, discussion about best practices, or any other conversation that would benefit from being searchable: |
| 78 | + |
| 79 | +[Discuss Headless UI on GitHub](https://github.com/tailwindlabs/headlessui/discussions) |
| 80 | + |
| 81 | +For casual chit-chat with others using the library: |
| 82 | + |
| 83 | +[Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe) |
0 commit comments