Page navigation
Use a styled native anchor to reach another route.
Components / Navigation
A styled native anchor or Vue router link that preserves link behavior.
Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.
bunx --bun @getweini/cli@latest add linkImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
Read the getting started guide.
<script setup lang="ts">
import Link from './components/ui/link/Link.vue'
</script>
<template>
<p>Read the <Link href="/guides/getting-started">getting started guide</Link>.</p>
</template>Native anchor attributes and events pass through. In Nuxt, use :as="NuxtLink" with to for client-side navigation.
Use a styled native anchor to reach another route.
Link to a separate site with clear destination text.
Use NuxtLink for the route and Link for the Weini anchor treatment.
<script setup lang="ts">
import { NuxtLink } from '#components'
import Link from './components/ui/link/index.vue'
</script>
<template>
<p>
Read the <Link :as="NuxtLink" to="/guides/export">export guide</Link> before downloading.
</p>
</template>A muted variant can sit beside a primary form action.
<script setup lang="ts">
import Link from './components/ui/link/Link.vue'
</script>
<template>
<Link href="/account/help" variant="muted" size="sm">Need help signing in?</Link>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
sizeprop | NonNullable<"sm" | "md" | "lg" | undefined> | undefined | 'md' | Choose the visual size. Medium is the usual default where available. |
variantprop | NonNullable<"default" | "muted" | "plain" | undefined> | undefined | 'default' | Choose the visual treatment for this component. |
asprop | Component | "a" | undefined | 'a' | Choose the HTML element or Vue component used for this control. |
asChildprop | boolean | undefined | false | Use one child element as the control instead of adding another wrapper. |
hrefprop | string | undefined | Not set | URL to navigate to when this link is activated. |
defaultslot | () => unknown | Required | Content shown inside Link. |
// packages/frameworks/vue/components/link/types.ts
// ------- IMPORTS -------
import type { Component } from 'vue'
import type { linkSizes, linkVariants } from './styles'
// ------- TYPES -------
export interface LinkProps {
href?: string
as?: 'a' | Component
asChild?: boolean
variant?: keyof typeof linkVariants
size?: keyof typeof linkSizes
}
// packages/frameworks/vue/components/link/styles.ts
// Edit the native link's appearance here; public visual prop types follow the map keys.
export const linkVariants = {
default:
'text-primary underline decoration-primary/40 underline-offset-4 hover:decoration-current',
muted:
'text-muted-foreground underline decoration-current/35 underline-offset-4 hover:text-foreground',
plain: 'text-foreground hover:text-primary',
} as const
export const linkSizes = { sm: 'text-sm', md: 'text-base', lg: 'text-lg' } as const