Skip to Content

Vue Components

TailAdmin Vue offers a curated set of customizable, accessible UI components designed to accelerate dashboard development. Built with Vue 3 (Composition API and <script setup>), Tailwind CSS v4, and Reka UI , each component combines clean design with robust accessibility.

UI Primitives & Accessibility

TailAdmin Vue uses Reka UI  as the headless foundation for its UI primitives located in src/components/ui/.

Using Reka UI ensures comprehensive accessibility management across your application:

  • WAI-ARIA Compliance: Built-in support for ARIA roles, attributes, and screen reader announcements.
  • Keyboard Navigation & Focus Management: Native keyboard interactions (such as Escape to dismiss, Arrow keys for list traversal, and automatic focus trapping/restoration in modals).
  • Headless Flexibility: Unstyled compound components that adapt to Tailwind CSS v4 classes without style conflicts or extra runtime bloat.
  • State-driven Attributes: Primitives expose declarative data attributes (data-state, data-highlighted, data-disabled) for seamless animation and styling.

For the complete API reference, props specification, and component anatomy for any primitive, refer to the Reka UI Documentation .

Usage Instructions

Primitives are stored in src/components/ui/ and are imported directly into your pages and layouts. Each primitive lives in its own folder and exposes its parts through an index.ts file.

Static Component

For static elements without internal state (such as Buttons, Badges, or Avatars), import the primitive and pass your desired variant, size, or Tailwind classes:

<script setup lang="ts"> import { Button } from "@/components/ui/button"; </script> <template> <div class="flex flex-wrap items-center gap-3"> <Button variant="default" size="sm">Primary Action</Button> <Button variant="outline" size="sm">Secondary Outline</Button> <Button variant="ghost" size="sm">Ghost</Button> <Button variant="destructive" size="sm">Delete</Button> </div> </template>

Interactive Components

Interactive elements (such as Dropdowns, Dialogs, Popovers, Tabs, and Selects) use compound components that coordinate state and accessibility attributes automatically.

The dropdown primitive uses Reka UI Dropdown Menu  under the hood, managing trigger interactions, keyboard navigation, and popover positioning.

<script setup lang="ts"> import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; </script> <template> <DropdownMenu> <DropdownMenuTrigger as-child> <Button size="sm" variant="outline">Account Menu</Button> </DropdownMenuTrigger> <DropdownMenuContent align="start"> <DropdownMenuItem>Edit Profile</DropdownMenuItem> <DropdownMenuItem>Account Settings</DropdownMenuItem> <DropdownMenuItem>Support</DropdownMenuItem> <DropdownMenuSeparator /> <DropdownMenuItem class="text-red-500 hover:text-red-600"> Sign Out </DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </template>

Creating & Extending UI Primitives

When creating or extending a UI primitive in src/components/ui/:

  1. Import Reka UI Primitive: Choose the appropriate headless primitive from reka-ui.
  2. Define Variants: Keep variant and size classes in a variants.ts file next to the component (see button/variants.ts), using Tailwind CSS v4 tokens.
  3. Attach data-slot: Set a descriptive data-slot attribute on each rendered element to support styling hooks and parent targeting.
  4. Merge Classes: Wrap class with the cn() utility from @/utils/cn (clsx + tailwind-merge) to allow consumer overrides.
  5. Forward Props: Use useForwardProps or useForwardPropsEmits from reka-ui so the wrapper keeps the primitive’s full props and events.
  6. Check Accessibility: Review the Reka UI API Reference  for required sub-components (such as Title and Description) to ensure valid ARIA tree generation.

Forms & Validation

TailAdmin Vue manages forms with a small, dependency-free useFormValidation composable (src/composables/useFormValidation.ts). It follows the “validate on touch” pattern: a field’s error appears after the field is blurred or the form is submitted, and is re-validated on every change. Accessible form controls are constructed with the compound Field primitives (Field, FieldLabel, FieldError, FieldDescription) from @/components/ui/field.

Schema Definition

Colocate a validation function alongside your form or feature module. It receives the form values and returns an object of error messages keyed by field name:

// schema.ts import { isEmail } from "@/composables/useFormValidation"; export interface LoginFormData { email: string; password: string; } export const validateLogin = (data: LoginFormData) => { const errors: Partial<Record<keyof LoginFormData, string>> = {}; if (!data.email.trim()) errors.email = "Email address is required"; else if (!isEmail(data.email.trim())) errors.email = "Please enter a valid email address"; if (data.password.length < 6) errors.password = "Password must be at least 6 characters"; return errors; };

Form Component Implementation

Call useFormValidation with the default values and the validate function, then bind inputs with v-model and wrap each one in Field:

<script setup lang="ts"> import { Button } from "@/components/ui/button"; import { Field, FieldError, FieldLabel } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; import { useFormValidation } from "@/composables/useFormValidation"; import { validateLogin, type LoginFormData } from "./schema"; const { values, errorOf, touch, handleSubmit, isSubmitting } = useFormValidation<LoginFormData>( { email: "", password: "" }, validateLogin, ); const onSubmit = handleSubmit(async (data) => { console.log("Form data:", data); }); </script> <template> <form class="space-y-4" novalidate @submit="onSubmit"> <Field :data-invalid="Boolean(errorOf('email'))"> <FieldLabel>Email</FieldLabel> <Input v-model="values.email" type="email" placeholder="[email protected]" :aria-invalid="errorOf('email') ? 'true' : undefined" @blur="touch('email')" /> <FieldError :errors="[{ message: errorOf('email') }]" /> </Field> <Field :data-invalid="Boolean(errorOf('password'))"> <FieldLabel>Password</FieldLabel> <Input v-model="values.password" type="password" placeholder="Enter password" :aria-invalid="errorOf('password') ? 'true' : undefined" @blur="touch('password')" /> <FieldError :errors="[{ message: errorOf('password') }]" /> </Field> <Button type="submit" :disabled="isSubmitting" class="w-full"> {{ isSubmitting ? "Signing in..." : "Sign In" }} </Button> </form> </template>
  • Field Association: FieldLabel links to its input through the for attribute, so pass an id to the input and the same value to for when you need a clickable label (for example with a Checkbox).
  • Validation State: Setting data-invalid on Field and aria-invalid on the input triggers Tailwind error styling and ensures accessible feedback.
  • Accessible Errors: FieldError renders error text with role="alert" for screen reader announcements, and renders nothing when there is no message.
  • Other helpers: useFormValidation also returns reset(), which clears the values and touched state.

Tables

TailAdmin Vue provides semantic table primitives under @/components/ui/table (Table, TableHeader, TableBody, TableRow, TableCell). TailAdmin Vue also ships with Tanstack Table  (@tanstack/vue-table) for building complex and interactive tables.

Basic Table

Create a basic table by using the Table primitives:

<script setup lang="ts"> import { Table, TableBody, TableCell, TableHeader, TableRow, } from "@/components/ui/table"; interface User { id: string; name: string; role: string; status: string; } defineProps<{ users: User[] }>(); </script> <template> <Table> <TableHeader class="border-b border-gray-100 dark:border-white/5"> <TableRow> <TableCell is-header class="px-5 py-3 text-start text-xs font-medium text-gray-500 dark:text-gray-400" > User </TableCell> <TableCell is-header class="px-5 py-3 text-start text-xs font-medium text-gray-500 dark:text-gray-400" > Role </TableCell> <TableCell is-header class="px-5 py-3 text-start text-xs font-medium text-gray-500 dark:text-gray-400" > Status </TableCell> </TableRow> </TableHeader> <TableBody class="divide-y divide-gray-100 dark:divide-white/5"> <TableRow v-for="user in users" :key="user.id"> <TableCell class="px-5 py-4 text-sm font-medium text-gray-800 dark:text-white/90" > {{ user.name }} </TableCell> <TableCell class="px-5 py-4 text-sm text-gray-500 dark:text-gray-400"> {{ user.role }} </TableCell> <TableCell class="px-5 py-4 text-sm text-gray-500 dark:text-gray-400"> {{ user.status }} </TableCell> </TableRow> </TableBody> </Table> </template>

Advance Data Table

For advanced features such as sorting, global search filtering, and pagination, combine the table primitives with @tanstack/vue-table. Check Tanstack Table documentation here  for more details.

Register only the features and functions you use with tableFeatures, define columns with createColumnHelper, and keep the table state in refs that you pass to useTable:

<script setup lang="ts"> import { computed, ref } from "vue"; import { columnFilteringFeature, createColumnHelper, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, sortFn_alphanumeric, tableFeatures, useTable, type PaginationState, type SortingState, type Updater, } from "@tanstack/vue-table"; import { Table, TableBody, TableCell, TableHeader, TableRow, } from "@/components/ui/table"; interface User { id: number; name: string; role: string; } const data = ref<User[]>([ { id: 1, name: "Lindsey Curtis", role: "Designer" }, { id: 2, name: "Kaiya George", role: "Developer" }, ]); const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, rowSortingFeature, rowPaginationFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortFns: { alphanumeric: sortFn_alphanumeric }, }); const columnHelper = createColumnHelper<typeof features, User>(); const columns = columnHelper.columns([ columnHelper.accessor("name", { header: "Name", sortFn: "alphanumeric" }), columnHelper.accessor("role", { header: "Role", sortFn: "alphanumeric" }), ]); const searchQuery = ref(""); const sorting = ref<SortingState>([]); const pagination = ref<PaginationState>({ pageIndex: 0, pageSize: 10 }); const resolve = <T,>(updater: Updater<T>, previous: T): T => typeof updater === "function" ? (updater as (old: T) => T)(previous) : updater; const table = useTable({ features, data, columns, getRowId: (row: User) => String(row.id), state: computed(() => ({ globalFilter: searchQuery.value, sorting: sorting.value, pagination: pagination.value, })), onSortingChange: (updater: Updater<SortingState>) => { sorting.value = resolve(updater, sorting.value); }, onPaginationChange: (updater: Updater<PaginationState>) => { pagination.value = resolve(updater, pagination.value); }, }); const rows = computed(() => table.getRowModel().rows.map((row) => row.original)); </script> <template> <input v-model="searchQuery" placeholder="Search..." /> <Table> <TableHeader> <TableRow> <TableCell is-header> <button @click="table.getColumn('name')?.toggleSorting()">Name</button> </TableCell> <TableCell is-header>Role</TableCell> </TableRow> </TableHeader> <TableBody> <TableRow v-for="user in rows" :key="user.id"> <TableCell>{{ user.name }}</TableCell> <TableCell>{{ user.role }}</TableCell> </TableRow> </TableBody> </Table> </template>

Complete working examples (Data Tables One, Two and Three, the product list, invoice list and ticket list) are in src/components/main/tables/ and the feature folders under src/components/.

Last updated on