mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 18:30:35 +01:00
docs(link): update
This commit is contained in:
@@ -17,32 +17,73 @@ The Link component is a wrapper around [`<NuxtLink>`](https://nuxt.com/docs/api/
|
|||||||
|
|
||||||
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](https://router.vuejs.org/guide/migration/#removal-of-the-exact-prop-in-router-link) guide.
|
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](https://router.vuejs.org/guide/migration/#removal-of-the-exact-prop-in-router-link) guide.
|
||||||
|
|
||||||
::component-card
|
::note
|
||||||
|
It is used by the [Breadcrumb](/components/breadcrumb), [Button](/components/button), [ContextMenu](/components/context-menu), [DropdownMenu](/components/dropdown-menu) and [NavigationMenu](/components/navigation-menu) components.
|
||||||
|
::
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
::component-code
|
||||||
|
---
|
||||||
|
props:
|
||||||
|
to: ''
|
||||||
|
as: 'button'
|
||||||
|
slots:
|
||||||
|
default: Link
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
|
::tip
|
||||||
|
You can inspect the rendered HTML by changing the `to` prop.
|
||||||
|
::
|
||||||
|
|
||||||
|
### Style
|
||||||
|
|
||||||
|
By default, the link has default active and inactive styles, check out the [#theme](#theme) section.
|
||||||
|
|
||||||
|
::component-code
|
||||||
---
|
---
|
||||||
props:
|
props:
|
||||||
to: /components/link
|
to: /components/link
|
||||||
activeClass: 'text-primary'
|
slots:
|
||||||
inactiveClass: 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200'
|
default: Link
|
||||||
code: ' Link '
|
---
|
||||||
|
::
|
||||||
|
|
||||||
|
::tip
|
||||||
|
Try changing the `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`.
|
||||||
|
|
||||||
|
::component-code
|
||||||
|
---
|
||||||
|
ignore:
|
||||||
|
- raw
|
||||||
|
props:
|
||||||
|
raw: true
|
||||||
|
to: /components/link
|
||||||
|
active-class: 'font-bold'
|
||||||
|
inactive-class: 'text-gray-500 dark:text-gray-500'
|
||||||
|
slots:
|
||||||
|
default: Link
|
||||||
---
|
---
|
||||||
|
|
||||||
Link
|
Link
|
||||||
::
|
::
|
||||||
|
|
||||||
It also renders an `<a>` tag when a `to` prop is provided, otherwise it defaults to rendering a `<button>` tag. The default behavior can be customized using the `as` prop.
|
|
||||||
|
|
||||||
It is used underneath by the [Button](/components/button), [Dropdown](/components/dropdown) and [VerticalNavigation](/components/vertical-navigation) components.
|
|
||||||
|
|
||||||
## IntelliSense
|
## 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`:
|
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`:
|
||||||
|
|
||||||
```json [.vscode/settings.json]
|
```json [.vscode/settings.json]
|
||||||
{
|
{
|
||||||
"tailwindCSS.classAttributes": [
|
"tailwindCSS.classAttributes": [
|
||||||
"active-class",
|
"active-class",
|
||||||
"inactive-class"
|
"inactive-class"
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -50,8 +91,17 @@ If you're using VSCode and wish to get autocompletion for the classes `active-cl
|
|||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
|
||||||
:component-props
|
::component-props
|
||||||
|
---
|
||||||
|
ignore:
|
||||||
|
- custom
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
:component-slots
|
:component-slots
|
||||||
|
|
||||||
|
## Theme
|
||||||
|
|
||||||
|
:component-theme
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ export default defineNuxtConfig({
|
|||||||
const globals = components.filter(c => [
|
const globals = components.filter(c => [
|
||||||
'UBadge',
|
'UBadge',
|
||||||
'UButton',
|
'UButton',
|
||||||
'UKbd'
|
'UKbd',
|
||||||
|
'ULink'
|
||||||
].includes(c.pascalName))
|
].includes(c.pascalName))
|
||||||
|
|
||||||
globals.forEach(c => c.global = 'sync')
|
globals.forEach(c => c.global = 'sync')
|
||||||
|
|||||||
@@ -22,12 +22,18 @@ export interface LinkProps extends NuxtLinkProps {
|
|||||||
*/
|
*/
|
||||||
type?: ButtonHTMLAttributes['type']
|
type?: ButtonHTMLAttributes['type']
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
/** Force the link to be active independent of the current route. */
|
||||||
active?: boolean
|
active?: boolean
|
||||||
|
/** Will only be active if the current route is an exact match. */
|
||||||
exact?: boolean
|
exact?: boolean
|
||||||
|
/** Will only be active if the current route query is an exact match. */
|
||||||
exactQuery?: boolean
|
exactQuery?: boolean
|
||||||
|
/** Will only be active if the current route hash is an exact match. */
|
||||||
exactHash?: boolean
|
exactHash?: boolean
|
||||||
|
/** The class to apply when the link is inactive. */
|
||||||
inactiveClass?: string
|
inactiveClass?: string
|
||||||
custom?: boolean
|
custom?: boolean
|
||||||
|
/** When `true`, only styles from `class`, `activeClass`, and `inactiveClass` will be applied. */
|
||||||
raw?: boolean
|
raw?: boolean
|
||||||
class?: any
|
class?: any
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user