# Tansy UI A themeable, accessible React component kit by [OpenKhalix](https://ui.openkhalix.com), built on [Base UI](https://base-ui.com) and Tailwind CSS v4. - **38 components:** forms with floating labels, selects and comboboxes, dialogs, drawers, menus, tabs, toasts, tables and more. - **Accessible:** keyboard support and screen-reader wiring from Base UI, visible focus rings, and every story checked with axe in light and dark mode. - **Themeable:** seven palettes switchable at runtime, class-based dark mode, and one semantic token set. - **One API:** `color`, `variant` and `size` on everything; `label`, `description` and `error` on every field; controlled or uncontrolled values. **Docs and live examples:** https://ui.openkhalix.com/docs/ ## Install ```bash npm install @openkhalix/tansy-ui ``` Needs React 19. `@base-ui/react`, `lucide-react`, `clsx` and `tailwind-merge` install with it. ## Add the styles Pick one of the two setups. ### With Tailwind CSS v4 (recommended) Import the tokens after Tailwind, and let Tailwind scan the package for the classes it uses: ```css /* app.css */ @import "tailwindcss"; @import "@openkhalix/tansy-ui/tokens.css"; @source "../node_modules/@openkhalix/tansy-ui/dist"; ``` Your own Tailwind utilities can then use the same tokens (`bg-surface`, `text-fg`, `bg-primary-500`). ### Without Tailwind Import the prebuilt stylesheet once, for example in your entry file: ```ts import '@openkhalix/tansy-ui/styles.css' ``` It contains the tokens, only the utilities the components use, and a modern CSS reset (Tailwind's preflight), which the components rely on, much as MUI relies on `CssBaseline`. The reset normalises margins, borders and form controls across your app. If you already use Tailwind, use the setup above instead. ## Use ```tsx import { Mail } from 'lucide-react' import { Button, FeaturedInput, Select, Switch } from '@openkhalix/tansy-ui' export function InviteForm() { return (
) } ``` ### Next.js Components are marked `"use client"`, so you can import them straight into Server Components. Helpers such as `cn` and `applyPalette` stay server-safe. ## Dark mode and palettes ```ts import { applyPalette } from '@openkhalix/tansy-ui' document.documentElement.classList.toggle('dark', true) // dark mode applyPalette(document.documentElement, 'emerald') // classicBlue, emerald, violet, amber, crimson, slate, teal ``` Apply a palette to `` so popups, which render in a portal, pick it up too. ## Components | Group | Components | |---|---| | Actions | `Button`, `IconButton`, `LinkButton`, `ToggleGroup`, `Toggle` | | Forms | `Field`, `Input`, `FeaturedInput`, `TextArea`, `FeaturedTextArea`, `NumberInput`, `Select`, `FeaturedSelect`, `Combobox`, `NativeSelect`, `Checkbox`, `CheckboxGroup`, `Radio`, `Switch`, `Slider` | | Overlays | `Dialog` (`Modal`), `AlertDialog`, `Drawer` (`Sheet`), `Popover`, `Tooltip`, `InfoTip`, `DropdownMenu` | | Navigation | `Tabs`, `Accordion`, `Breadcrumb`, `Pagination` | | Feedback | `Alert`, `Toast` (`Toaster`, `useToast`), `Spinner`, `Progress`, `Meter`, `Skeleton` | | Display | `Badge`, `CountBadge`, `Avatar`, `AvatarGroup`, `Kbd`, `Table` | | Layout | `Card`, `Separator` | Every component has a Storybook page with its props, controls and a story for each state: https://ui.openkhalix.com/docs/ ## Licence and credit MIT © OpenKhalix. Use it, fork it, and ship it in commercial products, free. The licence's only condition is that you keep the copyright notice in copies of the code. If Tansy UI helps you, a visible credit such as "UI by [Tansy UI](https://ui.openkhalix.com)" in your README or site footer is much appreciated. It isn't required.