Home
Wiki
Home
Wiki
  1. 2. Components
  • Back to home
  • 1. Themes
  • Vs Code
    • Getting Started
  • Kitchenware
    • Layout
      • New Layout
      • Legacy Layout
    • Components
      • Announcement
      • Banner Carousel
      • Banner With Products Carousel
      • Blog Category List
      • Blog List
      • Brand List
      • Brands Carousel
      • Breadcrumb
      • Call To Action
      • Cart
      • Categories List
      • Change Password
      • Checkout
      • Cookie Manager
      • Filter list
      • Footer
      • Forgot Password
      • Form
      • Hero Carousel
      • Icon Block
      • Invitation
      • Last Visited Products
      • Layout
      • Login
      • Map
      • Nav Bar
      • Offer
      • Product Attachments
      • Product Attributes
      • Product Documentation
      • Product Expected
      • Product Modal
      • Products Block
      • Products Carousel
      • Product Single
      • Profile
      • Quote
      • Register
      • Related Products
      • Search
      • Stores
      • Subscribe Newsletter
      • Text with Image
      • Top Bar
      • Video
    • Reusables
      • Getting Started
    • Assets
      • Getting Started
    • SDK
      • Products
        • _findProductsByCategory
        • _findProductsByIds
        • _findProductsByTitle
        • _findProductsByFilter
        • _findProductsByCriteria
        • _findProductsAndCalculate
        • _findProductsThenCalculate
        • _getProductAttributeSet
        • _setLastVisited
      • Categories
        • _findCategoryTreeById
        • _findCategoriesByIds
        • _findCategoryByAlias
        • _findCategoryTreeByAlias
        • _getCategoryContent
      • Collections
        • _getCollectionContent
        • _findCollectionsByIds
        • _findCollectionsByIdsThenCalculate
      • Brands
        • _getBrandContent
        • _findBrandsByIds
      • Cart
        • _addToCartMulti
        • _addToCart
        • _setCart
        • _clearCart
        • _setCartListener
        • _removeFromCart
        • _calculateCart
      • Checkout
        • _startCheckout
        • _updateCheckout
        • _completeCheckout
      • Shopping Lists
        • _getShoppingLists
        • _updateShoppingList
        • _createShoppingList
        • _deleteShoppingList
        • _getShoppingListByAlias
      • Navigation
        • _getFooterMenu
        • _getHeaderMenu
      • Users
        • _getUserById
      • Utils
        • _calculateCurrency
        • _getCurrencySymbol
        • _getCulture
        • _subscribeToNewsletter
        • _findUnitsByIds
  • Noir
    • 0. Introduction
    • 1. Structure
      • Overview
      • LayoutA.liquid
      • ComponentsList.liquid
      • Metas.liquid
      • CssVariables.liquid
      • Json.liquid
      • GoogleTagManager.liquid
      • StagingButton.liquid
    • 2. Components
      • Overview
      • Announcement
      • BannerCarousel
      • BlogCategoryList
      • BlogList
      • BrandList
      • Breadcrumb
      • Cart
      • CategoriesList
      • ChangePassword
      • Checkout
      • CookieManager
      • FilterList
      • Footer
      • ForgotPassword
      • Form
      • IconBlock
      • Invitation
      • LastVisitedProducts
      • Login
      • Map
      • NavBar
      • ProductAttachments
      • ProductAttributes
      • ProductComparison
      • ProductDocumentation
      • ProductMixList
      • ProductsBlock
      • ProductsCarousel
      • ProductSingle
      • Profile
      • Register
      • RelatedProducts
      • SingleBlog
      • Stores
      • TextWithImage
      • ThankYouPage
      • TopBar
      • Wishlist
    • 3. Reusables
      • Overview
      • Addresses
      • BillingRetail
      • AddressForm
      • AnnouncementModal
      • BackToTop
      • Company
      • General
      • Login
      • LoginModal
      • Orders
      • Payment
      • ProductAttachments
      • ProductAttributes
      • ProductComparisonButton
      • ProductComparisonFloatingButton
      • ProductGridItem
      • ProductListItem
      • ShoppingListsButton
      • ProductModal
      • ProfileInfo
      • PromptModal
      • Register
      • Shipping
      • ShoppingLists
      • ShoppingListsNavbar
      • Toast
      • Users
      • VariantContent
      • WishlistButton
      • Services
    • 4. Assets
      • Fonts
      • Images
      • Templates
      • Javascript
        • Overview
        • theme.js
      • Css / Scss
        • Overview
        • ThemeClasses
    • 5. SDK
      • Overview
      • LiquidGlobals
      • ServicesSDK
  1. 2. Components

TopBar

Purpose#

The TopBar component renders the thin announcement bar at the top of the site header.
It:
renders announcement text (settings.text)
optionally renders up to 2 links (contact/blog etc.) on desktop
optionally renders a language switcher dropdown (desktop) when enabled and more than one language exists
renders a dark mode toggle button (desktop)
hides/shows itself on scroll (client-side)

Inputs (model contract)#

Model shape (storefront example)#

{
  "name": "TopBar",
  "view": "Default",
  "section": "SectionHeader",
  "settings": {
    "text": "Sample text",
    "link1Title": "Sample text",
    "link1Path": "/sample",
    "link2Title": "Sample text",
    "link2Path": "/sample",
    "showLanguage": true,
    "id": "Component Id",
    "section": "SectionHeader",
    "type": "NoirTopBar",
    "name": "TopBar",
    "configuredInContentApi": true,
    "view": "Default",
    "displayName": "",
    "cssClass": "",
    "header": "",
    "alignment": "Left"
  },
  "translations": {
    "enableDarkMode": "Sample text",
    "disableDarkMode": "Sample text",
    "selectLanguage": "Sample text",
    "...": "..."
  }
}

Required fields#

settings.id
settings.text

Optional fields#

settings.cssClass
Link 1:
settings.link1Title
settings.link1Path
Link 2:
settings.link2Title
settings.link2Path
Language dropdown:
settings.showLanguage
GlobalData.Company.Languages[] (must contain more than one language)
GlobalData.CurrentLanguage / GlobalData.Company.DefaultLanguage
translations.*

JavaScript#

Global object#

Components/TopBar/Default.js exposes:
Liquid binds it via x-init:
<div x-init="topbardefault.init($el)">

init(el)#

What it does
Calculates a scroll threshold based on the header height.
Adds a scroll listener that toggles the hide class on the TopBar element.
Key behaviors / edge cases
Threshold is header.offsetHeight / 2 and is updated on resize.
Uses a simple debounce/lock (canToggle + toggleDelay = 300ms) to prevent flicker.
Advice
The hide CSS class must exist in theme styles, otherwise the bar won’t visually hide.

Global Alpine stores (used by TopBar)#

$store.darkMode (theme mode)#

The dark mode toggle uses a shared Alpine store:
$store.darkMode.toggle()
$store.darkMode.on (for aria-checked and styling)

Dependencies#

Alpine.js
Alpine stores:
darkMode
Liquid globals:
GlobalData.Company.Languages
GlobalData.CurrentLanguage
GlobalData.Company.DefaultLanguage

Notes#

TopBar links and controls render only on desktop (hidden lg:flex).
Language dropdown is rendered only when settings.showLanguage is true and there are multiple languages.
Announcement text uses | raw, so the backend is expected to provide safe HTML.

Extras#

Template behavior (Liquid + Alpine)#

Computes booleans link1Exists / link2Exists based on title+path.
Language dropdown uses local Alpine state (open) and supports Escape + click-away.
The current language label is derived from the first two characters of the language code.
Modified at 2026-04-14 13:18:56
Previous
ThankYouPage
Next
Wishlist
Built with