Anu Vue Documentation
website·Indexed 30 days ago
https://anu-vue.netlify.app/A Vue component library featuring a comprehensive set of UI elements including ATable, AInput, AButton, ASelect, and ACard. The library provides a grid system based on CSS Grid Layout, integration with Nuxt via @anu-vue/nuxt, and utility composables such as useAnu, useSelection, and useIndeterminateCheckbox. It leverages UnoCSS for icons and arbitrary sizing flexibility.
What's inside Anu Vue
- Anu is a developer-experience (DX) focused, utility-based Vue component library designed for building professional user interfaces quickly. It is built on top of UnoCSS and VueUse, allowing for high flexibility and hackability. Key features include the ability to customize rendered UI via configurable arrays and the use of UnoCSS shortcuts to modify component styles.
Overview of the Anu Vue framework
Anu is a Vue framework built using UnoCSS and VueUse. It provides ready-to-use components designed for high developer experience (DX) and flexibility. A key architectural feature is that Anu provides component styles via UnoCSS presets, meaning components are effectively unstyled by default. This allows developers to shape the UI and customize components according to their specific design requirements without fighting default styles.Use icons from external libraries in Anu
Anu utilizes UnoCSS, allowing developers to use the UnoCSS Icons preset to integrate icons from any supported library (such as Box Icons, Fluent Emoji, or Logos). By default, Anu uses Box Icons. You can preview available icons at icones.js.org.Use the ABadge component for notifications
TheABadgecomponent wraps an element (like an icon, button, or avatar) to display a notification badge. By default, the badge color isprimary.<template> <ABadge :content="9"> <i class="i-bx-bell w-6 h-6" /> </ABadge> </template>AAvatar Component Overview and Basic Usage
TheAAvatarcomponent is used to display user avatars using text, icons, or images. The default variant islight. You can change the avatar's color using thecolorprop. If the component is used within anAMenucomponent, the default slot is typically used to show the menu, which may cause some props to be ignored.<template> <div class="flex flex-wrap gap-4"> <!-- Using content prop --> <AAvatar content="A" /> <!-- Using default slot --> <AAvatar color="success"> JD </AAvatar> <!-- Using icon prop --> <AAvatar color="info" icon="i-bx-support" /> <!-- Using image src prop --> <AAvatar src="/images/demo/portrait-1.jpg" /> </div> </template>Understand Anu's preset architecture
Anu uses a two-preset system to manage component styling.presetAnuprovides the core functional styles (non-visual), whilepresetThemeDefaulthandles the visual styling and look-and-feel of the components. This system is powered by UnoCSS, allowing developers to replicate design systems like Bootstrap or Material Design.Choose between ATable and ADataTable components
Anu provides two table variations depending on the required functionality:
ATable: A lightweight component for simple row and column rendering. It supports custom column content via slots and extra columns.ADataTable: An advanced table built on top ofATablethat includes sorting, searching, and pagination, specifically designed for rendering data fetched from an API.
Adjust ARating size and spacing
The size of the rating icons is controlled via font-size utility classes (e.g.,text-sm,text-lg,text-2xl). To increase the gap between each rating icon, use padding utilities with theall:variant (e.g.,all:px-3).<template> <ARating v-model="rating" class="text-2xl" /> </template>Implement loading states in ABtn
Use the
loadingprop (boolean) to indicate a background process. Whentrue, the button displays a loading spinner (typicallyALoadingorASpinner) instead of the icon and/or label.Note: If the
loadingprop is set to any boolean value (trueorfalse), the component will render the spinner logic. If leftundefined, the spinner is not rendered at all.<script lang="ts" setup> import { ref } from 'vue' const isLoading = ref(false) </script> <template> <ABtn :loading="isLoading" @click="isLoading = !isLoading"> Click to load </ABtn> </template>Customize ACard header using slots
Use the#titleslot to render custom content in the card header, such as adding action icons or links next to the title. To add content to the right of both the title and subtitle, use theheader-rightslot.<ACard subtitle="Subtitle text" text="Body text"> <template #title> <div class="flex justify-between items-center"> <span>Card title</span> <a href="#" class="text-sm">Link</a> </div> </template> </ACard>Choose between CSS Variables and Theme for Anu customization
Anu provides two primary methods for customizing the look and feel of components. The choice depends on whether the change should be reactive to the current theme:
- Use Theme: When customization depends on the active theme (e.g., changing a component's color specifically for light vs. dark mode).
- Use CSS Variables: When customization should be global and regardless of the active theme (e.g., adjusting spacing for a list component).
Create a dismissible AAlert with v-model
Adding thedismissibleprop adds a close icon to the alert. To programmatically control the visibility of the alert or respond to the close action, usev-model(which maps to themodelValueprop). You can customize the close icon using theappend-iconprop.<script setup lang="ts"> import { ref } from 'vue' const isVisible = ref(true) </script> <template> <!-- Dismissible alert controlled by v-model --> <AAlert v-model="isVisible" dismissible> <span>This alert can be dismissed.</span> </AAlert> <!-- Dismissible alert with custom close icon --> <AAlert v-model="isVisible" dismissible variant="fill" append-icon="i-bx-block" > <span>Custom close icon alert</span> </AAlert> <ABtn @click="isVisible = !isVisible">Toggle visibility</ABtn> </template>