一键导入
n-collapse-transition
Collapse transition component for smooth show/hide animations. Invoke when user needs to implement expand/collapse animations in Naive UI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Collapse transition component for smooth show/hide animations. Invoke when user needs to implement expand/collapse animations 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-collapse-transition |
| description | Collapse transition component for smooth show/hide animations. Invoke when user needs to implement expand/collapse animations in Naive UI. |
| metadata | {"author":"jiaiyan","version":"1.0.0"} |
A collapse transition without any form of encapsulation. Provides smooth expand/collapse animations.
Use this component when:
Invoke this skill when:
| Name | Type | Default | Description |
|---|---|---|---|
| appear | boolean | false | Whether to play animation on first mounted. |
| show | boolean | true | Whether to show content. |
| Name | Parameters | Description |
|---|---|---|
| default | () | The content inside the transition. |
<template>
<n-space vertical>
<n-switch v-model:value="show">
<template #checked>
Show
</template>
<template #unchecked>
Hide
</template>
</n-switch>
<n-collapse-transition :show="show">
<div style="background: rgba(128, 128, 128, 0.2); padding: 24px;">
Content that can be collapsed
</div>
</n-collapse-transition>
</n-space>
</template>
<script setup>
import { ref } from 'vue'
const show = ref(true)
</script>
<template>
<n-collapse-transition appear :show="show">
<div style="background: rgba(128, 128, 128, 0.2); padding: 24px;">
This content will animate on mount
</div>
</n-collapse-transition>
</template>
<template>
<n-space vertical>
<n-button @click="expanded = !expanded">
{{ expanded ? 'Collapse' : 'Expand' }}
</n-button>
<n-collapse-transition :show="expanded">
<n-card>
<p>Line 1</p>
<p>Line 2</p>
<p>Line 3</p>
</n-card>
</n-collapse-transition>
</n-space>
</template>
<script setup>
import { ref } from 'vue'
const expanded = ref(false)
</script>
<template>
<n-space vertical>
<n-button @click="section1 = !section1">
Toggle Section 1
</n-button>
<n-collapse-transition :show="section1">
<div style="background: rgba(0, 128, 0, 0.1); padding: 16px;">
Section 1 Content
</div>
</n-collapse-transition>
<n-button @click="section2 = !section2">
Toggle Section 2
</n-button>
<n-collapse-transition :show="section2">
<div style="background: rgba(0, 128, 0, 0.2); padding: 16px;">
Section 2 Content
</div>
</n-collapse-transition>
</n-space>
</template>
<script setup>
import { ref } from 'vue'
const section1 = ref(true)
const section2 = ref(false)
</script>
<template>
<n-space vertical>
<n-checkbox v-model:checked="isVisible">
Show Content
</n-checkbox>
<n-collapse-transition :show="isVisible">
<div style="background: rgba(128, 128, 128, 0.2); padding: 24px;">
Content controlled by checkbox
</div>
</n-collapse-transition>
</n-space>
</template>
<script setup>
import { ref } from 'vue'
const isVisible = ref(true)
</script>
<template>
<n-space vertical>
<n-button @click="outer = !outer">
Toggle Outer
</n-button>
<n-collapse-transition :show="outer">
<div style="background: rgba(0, 128, 0, 0.1); padding: 16px;">
<n-button @click="inner = !inner" size="small">
Toggle Inner
</n-button>
<n-collapse-transition :show="inner">
<div style="background: rgba(0, 128, 0, 0.2); padding: 16px; margin-top: 8px;">
Inner Content
</div>
</n-collapse-transition>
</div>
</n-collapse-transition>
</n-space>
</template>
<script setup>
import { ref } from 'vue'
const outer = ref(true)
const inner = ref(true)
</script>
Use with v-model: Combine with v-model for reactive visibility control
Appear for initial animation: Use appear prop when you want animation on first mount
Avoid margin collapse: Be aware of margin collapse inside the transition
Content height: The transition works best with content that has a defined height
Combine with other components: Works well with cards, panels, and other containers
Performance: CSS-based transition is performant for most use cases