Configs2026年5月18日·1 分钟阅读

Headless UI — Unstyled Accessible UI Components for React and Vue

A set of completely unstyled, fully accessible UI components for React and Vue, designed to integrate with Tailwind CSS or any styling solution.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Headless UI
通用 CLI 安装命令
npx tokrepo install b42d852f-524e-11f1-9bc6-00163e2b0d79

Introduction

Headless UI is an open-source component library by the Tailwind Labs team that provides fully accessible, completely unstyled UI primitives. It handles the complex accessibility logic, keyboard navigation, and focus management so you can apply any visual design without fighting opinionated default styles.

What Headless UI Does

  • Provides unstyled, WAI-ARIA compliant components for common UI patterns
  • Handles keyboard navigation, focus trapping, and screen reader announcements automatically
  • Ships components for menus, listboxes, comboboxes, dialogs, disclosure panels, tabs, radio groups, and switches
  • Offers render-prop and slot-based APIs for full control over rendered HTML
  • Supports both React and Vue with dedicated packages

Architecture Overview

Each component is a state machine that manages open/closed state, active item tracking, and focus management. Components expose render props (React) or scoped slots (Vue) that pass down state like open, active, selected, and disabled. No CSS is bundled; all styling is left to the consumer. Transitions are handled via a built-in Transition component that coordinates enter/leave classes.

Self-Hosting & Configuration

  • Install @headlessui/react for React or @headlessui/vue for Vue
  • Import individual components and compose them in your JSX or template
  • Apply styles using Tailwind utility classes, CSS modules, styled-components, or plain CSS
  • Use the as prop to change the underlying HTML element any component renders
  • Wrap opening/closing animations with the built-in Transition component and configure enter/leave classes

Key Features

  • Zero styling opinions: compatible with Tailwind CSS, CSS-in-JS, or any approach
  • WAI-ARIA patterns implemented correctly out of the box with no extra configuration
  • Composable API where each component part is a separate importable piece
  • Built-in transition support for coordinated open/close animations
  • TypeScript-first with full generic type inference for custom elements via as

Comparison with Similar Tools

  • Radix Primitives — Similar headless approach for React; Headless UI also supports Vue and pairs natively with Tailwind
  • Reach UI — Accessible React components but with default styles; no longer actively maintained
  • Ariakit — Flexible low-level primitives; Headless UI offers higher-level compound components
  • Mantine — Full-featured styled library; Headless UI gives complete styling freedom
  • shadcn/ui — Built on Radix; Headless UI is the Tailwind Labs equivalent with its own component set

FAQ

Q: Do I need Tailwind CSS to use Headless UI? A: No. The components are completely unstyled and work with any CSS approach. Tailwind is recommended but not required.

Q: Does Headless UI handle animations? A: Yes. The built-in Transition component lets you define enter/leave CSS classes for coordinated open/close animations.

Q: Can I customize the HTML elements rendered? A: Yes. Every component accepts an as prop that lets you swap the default element for any HTML tag or custom component.

Q: Is Headless UI production-ready? A: Yes. It is maintained by the Tailwind Labs team and used in production by Tailwind UI and many large-scale applications.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产