@asevenid/ui-vue
v0.2.0
Published
Aseven UI for Vue — the Vue 3 / reka-ui port of @asevenid/ui (shadcn-vue + Tailwind v4 token system) with runtime brand/gray/radius/font/density/feedback/decorative/style/elevation modes.
Maintainers
Readme
@asevenid/ui-vue
Aseven UI for Vue 3: the Vue port of @asevenid/ui. It's built on shadcn-vue, reka-ui and Tailwind CSS v4, and uses the same token system and runtime modes as the React package. It ships compiled components, TypeScript types and a single self-contained stylesheet, so your app doesn't need its own Tailwind setup.
Theming happens at runtime. data-* attributes on <html> switch brand, gray, radius, font, density, feedback colors (error/warning/info/success), decorative palettes, surface style, elevation and press independently. Dark mode uses the standard .dark class.
Installation
npm install @asevenid/ui-vuevue (^3.5) is a peer dependency.
Setup
// main.ts
import "@asevenid/ui-vue/styles.css"
import { initModes } from "@asevenid/ui-vue"
initModes() // optional: restore persisted mode choices from localStorage before mountWeb fonts are not bundled. To use the non-system font modes, add:
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Arima:[email protected]&family=DynaPuff:[email protected]&family=Inter:opsz,[email protected],100..900&family=Lora:[email protected]&family=Plus+Jakarta+Sans:[email protected]&family=Space+Grotesk:[email protected]&display=swap" />If your app runs its own Tailwind v4
Don't import styles.css. It is a finished Tailwind build, and a second one on the same page clashes with it: your preflight resets its base rules (borders turn black), your utilities land after its own (hidden beats sm:block), and your Tailwind doesn't know the Aseven theme (bg-success, the token radii).
Import the un-built tailwind.css into your main stylesheet instead, right after Tailwind:
/* app.css */
@import "tailwindcss";
@import "@asevenid/ui-vue/tailwind.css";Your Tailwind then builds everything in one stylesheet: the tokens and modes, the theme mapping (so bg-primary, text-muted-foreground, rounded-lg, shadow-border and dark: mean the same in your markup as in the components), the base rules, and the utilities the components use. It finds those itself, so you don't need an @source for the package. Needs Tailwind 4.1 or later. Apps that set a Tailwind prefix() can't use it, because the components' classes have no prefix.
initModes() and the fonts work the same either way.
Usage
<script setup lang="ts">
import { Button, Input, Toaster } from "@asevenid/ui-vue"
import { toast } from "vue-sonner"
</script>
<template>
<Input placeholder="Email" />
<Button @click="toast.success('Saved')">Save</Button>
<Toaster />
</template>Switching themes at runtime
import { setMode, getMode, MODE_OPTIONS, setCustomColor } from "@asevenid/ui-vue"
setMode("brand", "violet") // data-brand="violet" + persisted
setMode("density", "compact")
setCustomColor("brand", "#3b82f6") // generate a full palette from one hex
MODE_OPTIONS.brand // available values
document.documentElement.classList.toggle("dark")If your server renders the modes (for example, <html data-brand="…"> from your backend), skip initModes() and the attributes still apply.
Themes stored on the server
When the theme is data (one record per tenant, say) rather than a browser preference, keep it as one DesignSettings object. A colour slot takes a palette name or a hex; missing or unknown values fall back to the defaults.
import {
type DesignSettings,
designSettingsAttributes,
designSettingsCss,
applyDesignSettings,
} from "@asevenid/ui-vue"
const settings: DesignSettings = {
brand: "#0f766e", // a hex renders as data-brand="custom"
gray: "stone",
"decorative-3": "purple", // e.g. the colour of your own "Pre Order" tags
elevation: "on",
}
// On the server (no DOM needed):
designSettingsAttributes(settings) // { "data-brand": "custom", "data-gray": "stone", … } for <html>
designSettingsCss(settings) // the custom ramps, for an inline <style>
// In the browser, e.g. a live preview of unsaved settings:
applyDesignSettings(settings) // sets the same attributes and CSS; persists nothingUse applyDesignSettings() instead of initModes() here, so a stored browser preference doesn't override the tenant's theme.
What's included
Components: Accordion, Alert, AlertDialog, Avatar, Badge, Banner, Breadcrumb, Button, Calendar, Card, Checkbox, Combobox, DatePicker, DateRangePicker, Dialog, Drawer, DropdownMenu, Field, FileUpload, Input, InputGroup, InputMoney, Kbd, Label, NativeSelect, Pagination, PasswordInput, QuantityStepper, RadioGroup, Select, Sheet, Sidebar, Skeleton, Slider, Sonner, Switch, Table, Tabs, Tag, Textarea, Toggle, ToggleGroup. Also exported: Command, HoverCard, NavigationMenu, Popover, RangeCalendar, Separator, Spinner, Tooltip.
Utilities: cn, cva, shade generation (generateShadesWith, …), the press-effect and field-scale class fragments, the full mode runtime (getMode, setMode, initModes, setCustomColor, MODE_OPTIONS, types), and the server-side theme helpers (DesignSettings, designSettingsAttributes, designSettingsCss, applyDesignSettings).
Only the root entry (@asevenid/ui-vue), @asevenid/ui-vue/styles.css and @asevenid/ui-vue/tailwind.css can be imported. The modules are preserved, so bundlers still tree-shake unused components.
Differences from @asevenid/ui (React)
See SYNC.md for the Vue-only components and behaviour, features not ported yet, and how to keep this package in sync with the React repo.
Development
npm install
npm run dev # sandbox: every component, with pickers for every mode and dark mode
npm run typecheck
npm run build:lib # dist/ (JS + .d.ts + styles.css + tailwind.css)License
MIT © Falah Filano
