Usage
The Link component is a wrapper around <NuxtLink> using the custom prop. It provides a few extra props:
inactive-classprop to set a class when the link is inactive,active-classis used when active.exactprop to style withactive-classwhen the link is active and the route is exactly the same as the current route.exact-queryandexact-hashprops to style withactive-classwhen the link is active and the query or hash is exactly the same as the current query or hash.- use
exact-query="partial"to style withactive-classwhen the link is active and the query partially match the current query.
- use
The incentive behind this is to provide the same API as NuxtLink back in Nuxt 2 / Vue 2. You can read more about it in the Vue Router migration from Vue 2 guide.
Tag
The Link components renders an <a> tag when a to prop is provided, otherwise it renders a <button> tag. You can use the as prop to change fallback tag.
{
"wait": "Loading client-side content..."
}to prop.Style
By default, the link has default active and inactive styles, check out the #theme section.
{
"wait": "Loading client-side content..."
}to prop to see the active and inactive states.You can override this behavior by using the raw prop and provide your own styles using class, active-class and inactive-class.
{
"wait": "Loading client-side content..."
}You can use the is-action prop to indicate a pseudo-link.
{
"wait": "Loading client-side content..."
}IntelliSense
If you're using VSCode and wish to get autocompletion for the classes active-class and inactive-class, you can add the following settings to your .vscode/settings.json:
{
"tailwindCSS.classAttributes": [
"active-class",
"inactive-class"
]
}
API
Props
Slots
Theme
export default defineAppConfig({
b24ui: {
link: {
base: 'cursor-pointer focus-visible:outline-(--ui-color-accent-main-primary) focus-visible:outline-1 focus-visible:rounded-[4px] text-start',
variants: {
active: {
true: 'text-(--ui-color-accent-main-primary) outline-(--ui-color-accent-main-primary) hover:not-disabled:not-aria-disabled:underline underline-offset-2',
false: 'text-(--ui-color-design-selection-content) underline-offset-2'
},
disabled: {
true: 'cursor-not-allowed opacity-75'
},
isAction: {
true: 'text-nowrap text-(length:--ui-font-size-sm) h-auto py-0 font-(--ui-font-weight-normal) rounded-none border border-x-0 border-t-0 border-dashed text-(--ui-color-design-outline-a1-content) border-b-(--ui-color-design-outline-a1-content) hover:not-disabled:not-aria-disabled:no-underline hover:text(--ui-color-accent-soft-element-red) hover:not-disabled:not-aria-disabled:text-(--ui-color-accent-soft-element-red) hover:border-b-(--ui-color-accent-soft-element-red) focus-visible:outline-(--ui-color-accent-soft-element-red)'
}
},
compoundVariants: [
{
active: false,
disabled: false,
class: 'hover:text-(--ui-color-accent-main-primary-alt-2) hover:underline'
}
]
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'
export default defineConfig({
plugins: [
vue(),
bitrix24UIPluginVite({
b24ui: {
link: {
base: 'cursor-pointer focus-visible:outline-(--ui-color-accent-main-primary) focus-visible:outline-1 focus-visible:rounded-[4px] text-start',
variants: {
active: {
true: 'text-(--ui-color-accent-main-primary) outline-(--ui-color-accent-main-primary) hover:not-disabled:not-aria-disabled:underline underline-offset-2',
false: 'text-(--ui-color-design-selection-content) underline-offset-2'
},
disabled: {
true: 'cursor-not-allowed opacity-75'
},
isAction: {
true: 'text-nowrap text-(length:--ui-font-size-sm) h-auto py-0 font-(--ui-font-weight-normal) rounded-none border border-x-0 border-t-0 border-dashed text-(--ui-color-design-outline-a1-content) border-b-(--ui-color-design-outline-a1-content) hover:not-disabled:not-aria-disabled:no-underline hover:text(--ui-color-accent-soft-element-red) hover:not-disabled:not-aria-disabled:text-(--ui-color-accent-soft-element-red) hover:border-b-(--ui-color-accent-soft-element-red) focus-visible:outline-(--ui-color-accent-soft-element-red)'
}
},
compoundVariants: [
{
active: false,
disabled: false,
class: 'hover:text-(--ui-color-accent-main-primary-alt-2) hover:underline'
}
]
}
}
})
]
})