Cette annonce peut être fermée. Cliquez sur le X pour la masquer !
Cette annonce ne peut pas être fermée - pas de bouton de fermeture !
Dismissible Demo
Ce contenu n’est pas encore disponible dans votre langue.
This page demonstrates the difference between dismissible and non-dismissible announcements. Look at the top of the page to see both types.
Announcements Displayed
Section titled “Announcements Displayed”The announcements at the top of this page showcase:
- Dismissible (default): Has a close button, state persists in localStorage
- Non-dismissible: No close button, always visible
Configuration
Section titled “Configuration”Control dismissibility with the dismissible property:
starlightAnnouncement({ announcements: [ // Dismissible (default behavior) { id: 'demo-dismissible', content: 'This announcement can be dismissed. Click the X to hide it!', variant: 'tip', dismissible: true, // This is the default showOn: ['/demos/dismissible/'], }, // Non-dismissible { id: 'demo-non-dismissible', content: 'This announcement cannot be dismissed - no close button!', variant: 'danger', dismissible: false, showOn: ['/demos/dismissible/'], }, ],})How Dismissal Works
Section titled “How Dismissal Works”localStorage Persistence
Section titled “localStorage Persistence”When a user dismisses an announcement:
- The announcement ID is stored in
localStorageunderstarlight-announcements-dismissed - On subsequent page loads, dismissed announcements are hidden automatically
- The dismissal persists across browser sessions
Storage Format
Section titled “Storage Format”// localStorage key: starlight-announcements-dismissed["demo-dismissible", "another-dismissed-id"]Resetting Dismissed Announcements
Section titled “Resetting Dismissed Announcements”To see dismissed announcements again:
- Open browser DevTools (F12)
- Go to Application → Local Storage
- Delete the
starlight-announcements-dismissedkey - Refresh the page
Or run this in the console:
localStorage.removeItem('starlight-announcements-dismissed');location.reload();When to Use Non-Dismissible
Section titled “When to Use Non-Dismissible”Use dismissible: false for:
- Critical security alerts that users must see
- Active maintenance notices during outages
- Legal/compliance notices that require acknowledgment
- Temporary but important announcements
Try It
Section titled “Try It”- Dismiss the tip announcement by clicking the X button
- Notice the danger announcement has no X button
- Refresh the page - the tip stays hidden, danger remains visible
- Reset using the console command above to see the tip again
See Announcement Options for detailed documentation on dismissibility.