{#- chirp-ui: Navbar component Top navigation bar with brand and links. Active state: use match= for automatic path comparison (requires current_path in template context), or active= for explicit control. match="exact" — active when current_path == href match="prefix" — active when current_path starts with href (or equals it) active=true — always active (explicit override) Named slots (Kida 0.3+, use_slots=true): default (links), end (right-aligned), brand (brand area, when brand_slot=true). Usage: from "chirpui/navbar.html" import navbar, navbar_link, navbar_end, navbar_dropdown call navbar(brand="My App", brand_url="/", use_slots=true) navbar_link("/docs", "Docs", match="prefix") navbar_link("/about", "About", match="exact") {% slot end %}btn("Login", href="/login"){% end %} end call navbar(brand_url="/", use_slots=true, brand_slot=true) {% slot brand %}logo(text="My App", image_src="/static/logo.svg", variant="both"){% end %} navbar_link("/docs", "Docs", match="prefix") end Legacy: wrap right-aligned content in navbar_end(). Add cls="chirpui-navbar--sticky" for sticky nav. -#} {% def navbar(brand=none, brand_url="/", cls="", use_slots=false, brand_slot=false) %} {% end %} {% def navbar_link(href, label, active=false, match="", cls="") %} {% set _cp = current_path | default("") if match else "" %} {% set _active = active if not match else ((_cp == href) if match == "exact" else (_cp == href or _cp.startswith(href ~ "/")) if match == "prefix" else active) %} {{ label }} {% end %} {% def navbar_end(cls="") %}
{% end %} {% def navbar_dropdown(label, active=false, match="", href="", cls="") %} {% set _cp = current_path | default("") if match else "" %} {% set _active = active if not match else ((_cp == href) if match == "exact" else (_cp == href or _cp.startswith(href ~ "/")) if match == "prefix" else active) %} {% end %}