Skip to content

CategoryNav

Premium navigation pattern for e-commerce, supporting bidirectional synchronization (Left click -> Right scroll; Right scroll -> Left centering & highlighting).

Basic Usage (Massive Data Demo)

This example demonstrates bidirectional linkage with 10 large category groups. The sidebar intelligently centers the active item as you scroll through the massive content area.

Top Picks
Mobiles
Computers
Appliances
Accessories
Home Design
Outdoors
Books
Fresh Food
Baby Care
Massive Data Synchronization

Loading State

Displays high-quality skeleton grids when `loading` is enabled.

Top Picks
Mobiles
Computers
Async Simulation

Custom Theme

The theme-overrides property allows you to quickly override internal CSS variables without writing complex global styles.

Top Picks
Mobiles
Brand Customized Theme

Use in Nuxt

YhCategoryNav can be used directly in Nuxt 3/4 projects. After enabling the YH-UI Nuxt module, the component is auto-imported and its static navigation structure can be rendered during SSR.

ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@yh-ui/nuxt'],
  yhUI: {
    components: ['YhCategoryNav']
  }
})

API

Props

AttributeDescriptionTypeDefault
categoriesCore data source containing IDs and sub-itemsCategoryItem[][]
model-value / v-modelCurrent active primary category IDstring | number | nullnull
sub-value / v-model:subValueCurrent active sub-category IDstring | number | nullnull
side-widthWidth of the left sidebarstring84px
show-allWhether to display the "All" item at the topbooleantrue
loadingWhether to show refined skeleton loading statebooleanfalse
columnsNumber of columns for flattened sub-itemsnumber3
sub-image-sizeImage thumbnail size (px)number64
anchorWhether to enable bidirectional scroll anchoringbooleantrue
theme-overridesSet of custom theme CSS variable overridesRecord<string, string>{}

Events

Event NameDescriptionCallback Parameters
category-clickTriggered when any primary category is clicked(item: CategoryItem)
sub-category-clickTriggered when any sub-category is clicked(item: CategorySubItem, parent: CategoryItem)
update:modelValueEmitted when active primary category ID changes(id: string | number | null)
update:subValueEmitted when active sub-category ID changes(id: string | number | null)

Slots

Slot NameDescriptionParameters
all-iconCustom icon for "All" button-
headerBusiness slot at the top of content area-
footerBusiness slot at the bottom of content area-
section-headerCustom rendering for each section header{ category: CategoryItem }
section-footerCustom rendering for each section footer{ category: CategoryItem }
sub-itemComplete custom rendering for sub-items{ sub: CategorySubItem, parent: CategoryItem }

Expose

This component does not expose public instance methods or properties.

Theme Variables

Variable NameDescriptionDefault
--yh-category-nav-side-bgLeft sidebar background color#f7f8fa
--yh-category-nav-content-bgRight content area background color#ffffff
--yh-category-nav-side-active-colorActive item text & indicator colorvar(--yh-color-primary)
--yh-category-nav-side-active-bgActive item background color#ffffff
--yh-category-nav-side-widthSidebar width84px
--yh-category-nav-sub-image-sizeSub-category image size64px
--yh-category-nav-columnsNumber of columns for flattened items3
--yh-category-nav-section-title-colorSection title colorvar(--yh-text-color-secondary)

Type Exports

NameDescription
YhCategoryNavPropsProps type for YhCategoryNav
YhCategoryNavEmitsEmits type for YhCategoryNav
YhCategoryNavSlotsSlots type for YhCategoryNav
YhCategoryItemPrimary category item type
YhCategorySubItemSecondary category item type
YhCategoryNavInstancePublic instance type for YhCategoryNav

Released under the MIT License.