diff --git a/docs/components/content/examples/BreadcrumbExampleBasic.vue b/docs/components/content/examples/BreadcrumbExampleBasic.vue new file mode 100644 index 0000000000..1ed31c3447 --- /dev/null +++ b/docs/components/content/examples/BreadcrumbExampleBasic.vue @@ -0,0 +1,17 @@ + + + diff --git a/docs/components/content/examples/BreadcrumbExampleDefaultSlot.vue b/docs/components/content/examples/BreadcrumbExampleDefaultSlot.vue new file mode 100644 index 0000000000..e26386025c --- /dev/null +++ b/docs/components/content/examples/BreadcrumbExampleDefaultSlot.vue @@ -0,0 +1,20 @@ + + + diff --git a/docs/components/content/examples/BreadcrumbExampleDividerSlot.vue b/docs/components/content/examples/BreadcrumbExampleDividerSlot.vue new file mode 100644 index 0000000000..0a279176b8 --- /dev/null +++ b/docs/components/content/examples/BreadcrumbExampleDividerSlot.vue @@ -0,0 +1,21 @@ + + + diff --git a/docs/components/content/examples/BreadcrumbExampleIconSlot.vue b/docs/components/content/examples/BreadcrumbExampleIconSlot.vue new file mode 100644 index 0000000000..9cd758a755 --- /dev/null +++ b/docs/components/content/examples/BreadcrumbExampleIconSlot.vue @@ -0,0 +1,25 @@ + + + diff --git a/docs/content/1.getting-started/3.theming.md b/docs/content/1.getting-started/3.theming.md index d86968e425..45dbb4bfb4 100644 --- a/docs/content/1.getting-started/3.theming.md +++ b/docs/content/1.getting-started/3.theming.md @@ -369,13 +369,29 @@ export default defineAppConfig({ }, pagination: { default: { + firstButton: { + icon: 'i-octicon-chevron-left-24' + }, prevButton: { icon: 'i-octicon-arrow-left-24' }, nextButton: { icon: 'i-octicon-arrow-right-24' + }, + lastButton: { + icon: 'i-octicon-chevron-right-24' } } + }, + accordion: { + default: { + openIcon: 'i-octicon-chevron-down-24' + } + }, + breadcrumb: { + default: { + divider: 'i-octicon-chevron-right-24' + } } } }) diff --git a/docs/content/5.navigation/1.vertical-navigation.md b/docs/content/5.navigation/1.vertical-navigation.md index 17a350db5c..6fa52a1433 100644 --- a/docs/content/5.navigation/1.vertical-navigation.md +++ b/docs/content/5.navigation/1.vertical-navigation.md @@ -13,7 +13,7 @@ Pass an array to the `links` prop of the VerticalNavigation component. Each link - `label` - The label of the link. - `icon` - The icon of the link. -- `iconClass` - The class of the icon of the link. +- `iconClass` - The class of the icon link. - `avatar` - The avatar of the link. You can pass all the props of the [Avatar](/elements/avatar) component. - `badge` - A badge to display next to the label. - `click` - The click handler of the link. diff --git a/docs/content/5.navigation/5.breadcrumb.md b/docs/content/5.navigation/5.breadcrumb.md new file mode 100644 index 0000000000..77e3372c05 --- /dev/null +++ b/docs/content/5.navigation/5.breadcrumb.md @@ -0,0 +1,69 @@ +--- +title: Breadcrumb +description: A list of links that indicate the current page's location within a navigational hierarchy. +navigation: + badge: New +--- + +## Usage + +Pass an array to the `links` prop of the Breadcrumb component. Each link can have the following properties: + +- `label` - The label of the link. +- `icon` - The icon of the link. +- `iconClass` - The class of the icon link. + +You can also pass any property from the [NuxtLink](https://nuxt.com/docs/api/components/nuxt-link#props) component such as `to`, `exact`, etc. + +:component-example{component="breadcrumb-example-basic"} + +::callout{icon="i-heroicons-light-bulb"} +A `span` will be rendered instead of a link when the `to` property is not defined. +:: + +## Divider + +Use the `divider` prop to customize the divider between each link, it can be **an icon or a string**. You can change it globally in `ui.breadcrumb.default.divider`. Defaults to `i-heroicons-chevron-right-20-solid`. + +You can set the prop to `null` to hide the divider. Additionally, you can customize it using the [`divider`](#divider-1) slot. + +::component-card +--- +baseProps: + links: + - label: Home + to: / + - label: Navigation + - label: Breadcrumb +props: + divider: '/' +--- +:: + +## Slots + +### `default` + +Use the `#default` slot to customize the link label. You will have access to the `link`, `index` and `isActive` properties in the slot scope. + +:component-example{component="breadcrumb-example-default-slot"} + +### `icon` + +Use the `#icon` slot to customize the link icon. You will have access to the `link`, `index` and `isActive` properties in the slot scope. + +:component-example{component="breadcrumb-example-icon-slot"} + +### `divider` + +Use the `divider` slot to customize the divider of the Breadcrumb. + +:component-example{component="breadcrumb-example-divider-slot"} + +## Props + +:component-props + +## Config + +:component-preset diff --git a/src/runtime/components/navigation/Breadcrumb.vue b/src/runtime/components/navigation/Breadcrumb.vue new file mode 100644 index 0000000000..12cde2b07a --- /dev/null +++ b/src/runtime/components/navigation/Breadcrumb.vue @@ -0,0 +1,84 @@ + + + diff --git a/src/runtime/types/breadcrumb.d.ts b/src/runtime/types/breadcrumb.d.ts new file mode 100644 index 0000000000..6c4b14ce70 --- /dev/null +++ b/src/runtime/types/breadcrumb.d.ts @@ -0,0 +1,7 @@ +import type { Link } from './link' + +export interface BreadcrumbLink extends Link { + label: string + icon?: string + iconClass?: string +} diff --git a/src/runtime/types/index.d.ts b/src/runtime/types/index.d.ts index 1b9c1ed333..e274f25e92 100644 --- a/src/runtime/types/index.d.ts +++ b/src/runtime/types/index.d.ts @@ -1,6 +1,7 @@ export * from './accordion' export * from './avatar' export * from './badge' +export * from './breadcrumb' export * from './button' export * from './clipboard' export * from './command-palette' diff --git a/src/runtime/ui.config.ts b/src/runtime/ui.config.ts index 6dc2781428..1fac6cd84b 100644 --- a/src/runtime/ui.config.ts +++ b/src/runtime/ui.config.ts @@ -1124,7 +1124,7 @@ export const pagination = { nextButton: { color: 'white', class: 'rtl:[&_span:last-child]:rotate-180', - icon: 'i-heroicons-chevron-right-20-solid ' + icon: 'i-heroicons-chevron-right-20-solid' } } } @@ -1163,6 +1163,26 @@ export const tabs = { } } +export const breadcrumb = { + wrapper: 'relative', + ol: 'flex items-center gap-x-1.5', + li: 'flex items-center gap-x-1.5 text-gray-500 dark:text-gray-400 text-sm', + base: 'flex items-center gap-x-1.5 group font-semibold', + icon: { + base: 'flex-shrink-0 w-4 h-4', + active: '', + inactive: '' + }, + divider: { + base: 'flex-shrink-0 w-5 h-5' + }, + active: 'text-primary-500 dark:text-primary-400', + inactive: ' hover:text-gray-700 dark:hover:text-gray-200', + default: { + divider: 'i-heroicons-chevron-right-20-solid' + } +} + // Overlays export const modal = {