salla-menu

Renders the store's navigation menu.

Renders the store's navigation menu. Use it in the theme header for the main (and mobile) menu, or in the footer for a flat list of links. Menu items are fetched from the store unless source="json" is used.

With source="header" it renders a <nav id="mobile-menu"> containing both a mobile list and a desktop list (items with children get a sub-menu, items with products get a mega menu). With source="footer" it renders a flat list of links.

Use it

In HTML or JSX, use the tag <salla-menu> with the Attribute names below. In React, the wrapper takes the Property names (camelCase).

import { SallaMenu } from '@salla.sa/twilight-components-react/menu';

Client-only. On the server this wrapper renders a placeholder (a skeleton, or nothing), and the real component mounts in the browser. Do not rely on it for content that search engines must see.

Try it

web-components/salla-menu

Example

import { SallaMenu } from '@salla.sa/twilight-components-react/menu';

export function Example() {
  return (
    <SallaMenu source="header" />
  );
}
import { SallaMenu } from '@salla.sa/twilight-components-react/menu';

export function Example() {
  return (
    <SallaMenu source="footer" limit={5} />
  );
}
import { SallaMenu } from '@salla.sa/twilight-components-react/menu';

export function Example() {
  return (
    <SallaMenu source="json" sourceValue='[{"id":1,"title":"Offers","url":"/offers","children":[],"attrs":"","link_attrs":""}]' />
  );
}

Properties

PropertyAttributeDescriptionTypeDefault
limitlimitFooter menu only. Maximum number of links to show. Has no effect on header menus.number
sourcesourceWhere the menu comes from. header and footer fetch the store's menu of that name; json reads the items from source-value."footer" | "header" | "json""header"
sourceValuesource-valueOnly used when source="json". A JSON string of an array of menu items, each shaped like {id, title, url, attrs, link_attrs, image, children, products}. attrs and link_attrs are strings of key="value" pairs separated by spaces and are applied to the <li> and <a>; both should be provided (use an empty string if unused) for header menus.string
topnavtopnavFooter menu only. When true, renders the links as a top navigation list and shows only the first limit items (3 if limit is not set).boolean
useReactLinkuse-react-linkNot read by the component, so it has no effect. Links are handled by the storefront router. Deprecated: It will be removed in the next major version. Stop passing it.booleanfalse
withCookiePreferenceswith-cookie-preferencesWhen true (footer menu only), appends a link to open cookie preferences. Use as with-cookie-preferences in markup. The link is added by salla-cookies-bar, which reads this prop from the menu, so it appears only when a cookies bar is on the page.boolean

Renders: <salla-products-list>.

On this page