Skip to content

Commit 4cbd574

Browse files
committed
docs(Banner): clarify persistence requirements for dismissed state
Added a note emphasizing the necessity of specifying an `id` prop to maintain the dismissed state of the banner across page reloads. This update enhances user understanding of the banner's behavior regarding visibility persistence.
1 parent af4f81c commit 4cbd574

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

docs/content/docs/2.components/banner.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ name: 'banner-example'
8686
When closed, `banner-${id}` will be stored in the local storage to prevent it from being displayed again. :br For the example above, `banner-example` will be stored in the local storage.
8787
::
8888

89+
::important
90+
To persist the dismissed state across page reloads, you must specify an `id` prop. Without an explicit `id`, the banner will only be hidden for the current session and will reappear on page reload.
91+
::
92+
8993
### Close Icon
9094

9195
Use the `close-icon` prop to customize the close button [Icon](/docs/components/icon). Defaults to `i-lucide-x`.

playgrounds/nuxt/app/pages/components/banner.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const attrs = reactive({
3636
v-bind="props"
3737
/>
3838
<UBanner
39+
id="banner3"
3940
title="Close me - I'll stay closed permanently (id='banner3')"
4041
:close="true"
41-
id="banner3"
4242
v-bind="props"
4343
/>
4444
</Matrix>

src/runtime/components/Banner.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ onMounted(() => {
103103
104104
useHead(() => {
105105
if (!hasPersistence.value) return {}
106-
106+
107107
return {
108108
script: [{
109109
key: `prehydrate-banner-${id.value}`,

0 commit comments

Comments
 (0)