一键导入
n-back-top
Back Top component for scrolling back to page top. Invoke when user needs to implement a back-to-top button or scroll-to-top functionality in Naive UI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Back Top component for scrolling back to page top. Invoke when user needs to implement a back-to-top button or scroll-to-top functionality in Naive UI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Naive UI Skills Library - A comprehensive skill library for AI agents to understand and utilize Naive UI components. Invoke when user needs to work with Naive UI components, theming, i18n, dark mode, or design specifications.
Affix component that makes content stick to fixed places when scrolling. Invoke when user needs to implement sticky positioning or fixed elements in Naive UI.
Alert component for displaying important messages and notifications. Invoke when user needs to show contextual feedback messages with different types and styles in Naive UI.
Anchor component for navigation and table of contents. Invoke when user needs to implement anchor navigation, table of contents, or scroll-based navigation highlighting in Naive UI.
An autocomplete input component that provides search hints and suggestions as users type, with support for grouping, custom rendering, and various input configurations
Avatar component for displaying user profile images, icons, or text. Invoke when user needs to implement user avatars, avatar groups, or customize avatar appearance in Naive UI.
| name | n-back-top |
| description | Back Top component for scrolling back to page top. Invoke when user needs to implement a back-to-top button or scroll-to-top functionality in Naive UI. |
| metadata | {"author":"jiaiyan","version":"1.0.0"} |
It helps you back to where you were. However, time never goes back.
Use this component when:
Invoke this skill when:
| Name | Type | Default | Description |
|---|---|---|---|
| bottom | number | string | 40 | The height of BackTop from the bottom of the page |
| listen-to | string | HTMLElement | undefined | The element to be listened to scroll event. If it is undefined back top will listen to the nearest scrollable parent. |
| right | number | string | 40 | The width of BackTop from the right side of the page |
| show | boolean | undefined | Whether to show BackTop |
| to | string | HTMLElement | 'body' | Container node to show BackTop |
| visibility-height | number | 180 | BackTop's trigger scroll top. |
| on-update:show | (value: boolean) => void | undefined | Callback is triggered when back-top display changes. |
<template>
<n-back-top :right="100" />
</template>
<template>
<n-back-top
:bottom="100"
:visibility-height="300"
:style="{
transition: 'all .3s cubic-bezier(.4, 0, .2, 1)',
}"
>
<div
style="
width: 200px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 14px;
"
>
Visibility Height: 300px
</div>
</n-back-top>
</template>
<template>
<n-back-top
:right="40"
:bottom="160"
:style="{
transition: 'all .3s cubic-bezier(.4, 0, .2, 1)',
}"
>
<div
style="
width: 200px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 14px;
"
>
Change Position
</div>
</n-back-top>
</template>
<template>
<n-back-top
:listen-to="target"
:bottom="220"
:visibility-height="10"
:style="{
transition: 'all .3s cubic-bezier(.4, 0, .2, 1)',
}"
>
<div
style="
width: 200px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 14px;
"
>
Specify Target
</div>
</n-back-top>
<div
ref="scrollContainer"
style="overflow: auto; height: 72px; line-height: 1.5"
>
<p v-for="i in 10" :key="i">
Scroll content line {{ i }}
</p>
</div>
</template>
<script setup>
import { ref, computed } from 'vue'
const scrollContainer = ref(null)
const target = computed(() => scrollContainer.value)
</script>
<template>
<n-back-top :right="40" :bottom="80">
<n-button circle size="large">
<template #icon>
<n-icon><ArrowUpIcon /></n-icon>
</template>
</n-button>
</n-back-top>
</template>
<template>
<n-back-top :show="isVisible" @update:show="handleShowChange" />
</template>
<script setup>
import { ref } from 'vue'
const isVisible = ref(false)
const handleShowChange = (value) => {
isVisible.value = value
}
</script>
Set appropriate visibility-height: Show button only after meaningful scroll distance
Position for accessibility: Position where it won't obstruct content but is easily accessible
Customize for branding: Match button style with your application theme
Use with specific containers: Set listen-to for scrollable containers other than document
Smooth transitions: Add CSS transitions for better user experience
Mobile considerations: Adjust position for mobile devices to avoid obstruction