Usage
Import components, bind their state, and set shared defaults.
Import a component
After installation, import from the component's local folder:
<script setup lang="ts">
import { ref } from 'vue'
import { Button } from '~/components/ui/button'
const saved = ref(false)
</script>
<template>
<Button @click="saved = true">Save project</Button>
<p v-if="saved" role="status">Project saved.</p>
</template>
Use your application's alias or a relative import in a Vue with Vite project.
Defaults
Set shared defaults in app/components/ui/ui.config.ts. A component uses only the global values it supports.
import type { UiConfig } from './ui.types'
const uiConfig: UiConfig = {
defaults: { size: 'md' },
components: {
button: { color: 'primary', variant: 'solid' },
input: { variant: 'outline' },
},
}
export default uiConfig
An explicit prop takes priority over the component setting, then a compatible global default, then the component's built-in default. Omitted or null variant props inherit the next setting.
Props and state
Choose size, color, and variant independently when a component supports them. Use v-model for controlled values and named slots to replace content.
import tailwindcss from '@tailwindcss/vite'
export default defineNuxtConfig({
modules: ['akaza-ui/nuxt', '@nuxt/fonts', '@nuxtjs/color-mode'],
css: ['~/assets/main.css'],
colorMode: { classSuffix: '', preference: 'system', fallback: 'light' },
vite: { plugins: [tailwindcss()] },
})
Each component's API lists its models, props, slots, events, and exposed methods. Cancelable change events provide details.cancel() to prevent an update.
Accessibility
Give inputs visible labels through Field or an accessible name through aria-label. Give icon-only buttons an accessible name. Preserve keyboard focus when customizing classes or replacing slots.
import tailwindcss from '@tailwindcss/vite'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [vue(), tailwindcss()],
})
Find an example
Component pages start with demos and example source. Use their controls to inspect sizes, variants, and states. The Installation section contains the core component files. The API section documents behavior and supported options.