Vueless UI Component Library
repository·main·Indexed 41 days ago
https://github.com/vuelessjs/vuelessAn open-architecture UI library for Vue.js 3 and Nuxt.js 3/4 powered by Tailwind CSS v4. It features 65+ customizable components, a runtime theme builder, and a flexible system using CSS variables and Class Variance Authority (CVA) for styling. Supports SSR, i18n, and accessibility, with dedicated integration for Storybook v10.
What's inside Vueless UI
- Vueless UI is a UI library designed with an 'Open Architecture' for Vue.js 3 and Nuxt.js 3/4. It is built using Storybook v10 and Tailwind CSS v4. The library is designed to be highly flexible, allowing developers to customize, copy, extend, or build components from scratch. It supports unstyled mode, light/dark modes, and uses CSS variables for design tokens.
Explore the Vueless UI Ecosystem
mainVueless provides several specialized packages to extend its functionality:
- @vueless/storybook: A Storybook preset for testing and documenting your component library.
- @vueless/nuxt: A dedicated Nuxt.js module for seamless integration.
- create-vueless: A CLI tool for scaffolding projects from templates, including
vueless-quickstart(JavaScript) andvueless-quickstart-ts(TypeScript).
Key features of Vueless UI
mainVueless UI provides the following capabilities:
- Component Library: 65+ crafted UI components (e.g., range date picker, multi-select, nested table).
- Open Architecture: Full freedom to customize, copy, extend, or create components.
- Storybook Integration: Built-in support for documentation and component exploration.
- Theme Builder: Runtime theme customization available via the Vueless Theme Builder.
- Styling & Theming: Beautiful default theme, unstyled mode, light/dark mode, and design tokens powered by CSS variables.
- Developer Experience: Auto component imports, uncompiled source in npm, and full TypeScript support.
- Core Capabilities: SSR support, Internationalization (i18n), Accessibility (a11y), and inline SVG icons.
- Reliability: 1300+ unit tests for consistent logic.
Configure component styling with CVA and Layers
mainVueless uses a layered styling approach powered by Class Variance Authority (CVA) and Tailwind CSS. Customization can be applied at four levels:
- Base component styling: Defined in the component's
config.ts. - Global customization: Applied via the
vueless.config.{js,ts}file. - Per-instance customization: Applied via the
:configprop on the component. - Direct class application: Applied via the standard
classattribute.
In
config.ts, you definebaseclasses,variants(e.g.,size,color), andcompound variants(combinations of props).export default /*tw*/ { button: { base: "flex items-center justify-center font-medium rounded-medium transition cursor-pointer", variants: { size: { "2xs": "px-2 py-1 text-small gap-0.5", sm: "px-4 py-2 text-medium gap-1.5", }, variant: { solid: "bg-{color} border-transparent text-inverted hover:bg-{color}-lifted", ghost: "text-{color} bg-transparent border-transparent", }, }, }, defaults: { color: "primary", variant: "solid", size: "md", }, };- Base component styling: Defined in the component's
Use Vueless colors via CSS variables
mainVueless exposes all
primaryandneutralshades as CSS variables, allowing for dynamic color changes at runtime.Available variables follow the pattern:
--vl-primary-{shade}(e.g.,--vl-primary-500)--vl-neutral-{shade}(e.g.,--vl-neutral-500)
You can use these directly in your HTML/Vue templates using Tailwind's custom property syntax.
<UButton class=" text-(--vl-primary-600) dark:text-(--vl-primary-400) bg-(--vl-neutral-200) dark:bg-(--vl-neutral-800) " />Extend keys with conditional styling (variants)
mainWhen you extend a key that contains conditional styling (such as
variantsorcompoundVariants), Vueless resolves the conditional classes fully before applying the extension. The resulting resolved class string is then merged with the key where the extension is applied.export default { component: { UTable: { headerCellBase: { base: "p-4 text-sm ...", variants: { compact: { true: "px-4 py-3 ...", }, }, }, headerCellCheckbox: "{>headerCellBase} w-10 ...", stickyHeaderCell: "{>headerCellBase} flex-none ...", } } };Understand the Vueless design system and color aliases
mainVueless uses a design system that enhances Tailwind CSS theming through color aliases and CSS variables. Instead of using specific Tailwind colors (like
blue-500) directly in components, Vueless uses semantic aliases (likeprimaryorsuccess). This allows you to change your entire brand aesthetic by simply remapping these aliases in your Vueless configuration without changing component code.Color Alias Reference
Color Alias Default Tailwind Color Description neutralgrayRegular neutral color. grayscalegrayContrasted neutral color. primarygrayscale(alias)The primary color, used as the default for components. secondarygrayA secondary color that complements the primary color. successgreenA color used for success states. errorredA color used for danger states or form error validation. warningorangeA color used for warning states. noticevioletA color used for highlighted informational states. infoblueA color used for informational states. Color Alias | Default ------------|---------- neutral | gray grayscale | gray primary | grayscale secondary | gray success | green error | red warning | orange notice | violet info | blueImplement conditional styling using the CVA pattern
mainVueless components use a structured configuration object (often exported as
default /*tw*/) to manage conditional styling. This pattern allows you to define styles that react to component props without manual class manipulation in the template.Key elements of the configuration:
base: Classes applied to every instance of the component.variants: A mapping of prop names to their possible values and corresponding classes. You can use runtime placeholders like{color}to inject values from thedefaultsor current props.compoundVariants: An array of objects defining classes that apply only when a specific combination of props is met (e.g.,variant: 'solid'ANDdisabled: true).defaults: The fallback values for props if they are not explicitly provided.
export default /*tw*/ { button: { base: "flex items-center justify-center rounded-medium transition cursor-pointer", variants: { variant: { solid: "bg-{color} border-transparent text-inverted hover:bg-{color}-lifted", outlined: "text-{color} border-{color} hover:text-{color}-lifted", }, size: { sm: "text-medium px-4 py-2", md: "text-medium px-5 py-2.5", }, loading: { true: "gap-0 pointer-events-none", }, }, compoundVariants: [ { variant: "solid", disabled: true, class: "bg-gray-300 hover:bg-gray-300", }, ], }, defaults: { color: "primary", variant: "solid", size: "md", }, };How Vueless component styling works
mainVueless uses Tailwind CSS for styling and CVA (Class Variance Authority) to handle conditional styles based on props.
Each HTML tag within a component is mapped to a specific configuration key. When you provide new classes, Vueless uses
tailwind-mergeto intelligently merge them with the component's default styles, preventing class duplication and conflicts.Merging Priority
When multiple styles are applied, they follow this priority order (from highest to lowest):
- Component
classattribute: Applied to the top-level HTML tag. - Component
configprop: Used for fine-tuning specific internal parts. - Global
vueless.config.{js,ts}: Project-wide component overrides. - Component default config: The library's built-in styles.
- Component
Customize themes with the Vueless Theme Builder
mainThe Vueless Theme Builder allows you to customize colors, rounding, and typography at runtime. You can generate full palettes and export a ready-to-use theme directly into your project.Understand Vueless design tokens and CSS variables
mainVueless uses over 40 CSS variables as design tokens to provide consistent styling and seamless support forlightanddarkmodes. These tokens are applied across all components and can be customized globally via the Vueless configuration or your main CSS file. These tokens serve as the foundation for the entire theming system.Understand the Vueless component file structure
mainAll Vueless components follow a standardized internal file organization. While the folder name and location change based on the context (project-wide, local, or internal to the Vueless repo), the internal files remain consistent:
config.ts: Styling configuration, default prop values, and component settings.constants.ts: Component constants and identifiers.types.ts: TypeScript types and props interface.U[component].vue: The main component file.U[component][child].vue: Optional child components.use[composable].ts: Optional component-specific composables.util[service].ts: Optional component-specific utility functions.storybook/: Containsdocs.mdxandstories.tsfor documentation and visualization.tests/: Contains component, utility, and composable tests.