Windi UI Documentation
website·Indexed 29 days ago
https://ui-windi.netlify.app/A UI component library built with TypeScript designed to speed up web application development. Features a comprehensive set of components including Buttons, Modals, Accordions, and Inputs, with built-in support for light and dark themes.
What's inside Windi UI
- Windi UI is a Vue.js-based UI library built on top of Tailwind CSS, VueUse, and Headless UI. It provides a collection of 50+ prebuilt, fully customizable components designed to accelerate web application development. The library is written in TypeScript and supports on-demand imports to ensure only used components are bundled, optimizing performance.
Use the WDivider component for content separation
TheWDividercomponent is used to create a visual separation between content or sections in a user interface. By default, it renders as a horizontal line.Use the WAccordion component
The Accordion component displays a list of high-level options that can expand or collapse to reveal more information. By default, multiple panels can be expanded at the same time.Windi UI Theme Overview
Windi UI supports light and dark themes out of the box with no developer configuration required. Customization is achieved through two primary methods: using thevariantsproperty for component-level overrides or creating a dedicated theme file for global styling.Use the WKbd component for keyboard inputs
TheWKbdcomponent is used to represent a keyboard or keyboard-like input in the user interface. You can set the text of the component by using its default slot.Implement a closable WAlert
To make an alert dismissible, add theclosableprop to theWAlertcomponent. This displays a close button that emits a close event when clicked. Developers must define a custom method to handle this event and remove the component from the UI.Add icons to WButton
WButton supports icons from the Iconify library via the
iconprop or specific slots:- Leading Icon: Pass an icon to the
iconprop or use theleadingslot. - Trailing Icon: Set the
trailingprop totrueor use thetrailingslot. - Icon Only: To create an icon-only button, omit the
labelprop.
- Leading Icon: Pass an icon to the
Create a custom theme for Windi UI
Windi UI allows for global customization by creating a custom theme file. This is useful for projects that need specific utility classes or an alternative provider to Tailwind CSS.
To create a custom theme:
- Create a
themefolder in thesrcdirectory. - Create a theme file (e.g.,
my-theme.ts) inside that folder. - Define the theme based on the component's presets, which typically include a
baseobject for structural classes and avariantsobject for style variations.
// Example: WButton preset structure in my-theme.ts WButton: { base: { root: 'focus:outline-none text-white block font-medium rounded-md transition-all duration-200 ease-in', buttonPill: '!rounded-full', buttonSize: { 'sm': 'text-sm', 'lg': 'text-sm', // ... other sizes }, // ... other base properties }, variants: { 'primary': { root: 'bg-blue-500 hover:enabled:bg-blue-600', }, 'success': { root: 'bg-green-500 hover:enabled:bg-green-600', }, // ... other variants }, }- Create a
Configure auto-imports for Windi UI components
Windi UI supports automatic component imports usingunplugin-vue-components. This allows you to use components in templates without explicit import statements while maintaining tree shaking.# Install the plugin npm i -D unplugin-vue-components// 1. In main.ts/js, disable automatic registration in createWindiUI import { createApp } from 'vue' import windiTheme from 'windi-vue/dist/theme/windiTheme' import { createWindiUI } from 'windi-vue'
const app = createApp(App) const UI = createWindiUI({ registerComponents: false }) app.use(UI, windiTheme) app.mount('#app')
// 2. In vite.config.ts/js, add the WindiUIComponentResolver import { WindiUIComponentResolver } from 'windi-vue' import Components from "unplugin-vue-components/vite"
export default defineConfig({ plugins: [ Components({ resolvers: [WindiUIComponentResolver()] }), ], })
Use the Badge component for status and notifications
The Badge component is used to highlight an item's status for quick recognition. It supports several display modes and configurations:
- Chip: Use the
chipprop to display the badge as a small dot/chip. - Value: Use the
valueprop to display a number or string. If the value exceeds a specifiedmax-value, it automatically displays with a+icon. - Square: Use the
squareprop to change the badge shape from rounded to square. - Position: Use the
positionprop to place the badge relative to its container. The default position istop-right.
- Chip: Use the
Create a vertical divider with WDivider
To change the orientation of theWDividercomponent from horizontal to vertical, use theverticalprop. This adjusts the alignment and dimensions of the divider to fit vertical layouts.Register individual Windi UI components with tree shaking
UsecreateWindiUIto register only the specific components you need. This method supports aprefixoption to avoid naming collisions.import { createApp } from 'vue' import App from './App.vue' import windiTheme from 'windi-vue/dist/theme/windiTheme' import { WKbd, createWindiUI } from 'windi-vue' const app = createApp(App) const UI = createWindiUI({ prefix: 'T', components: [WKbd], }) app.use(UI, windiTheme) app.mount('#app')// Usage in template: <template> <div> <TKbd>K</TKbd> </div> </template>