Web component for brand/logo display with optional image logos and automatic dark/light switching. Use in headers, footers, and anywhere you need consistent brand representation.
Overview
The <brand-mark> element provides a consistent way to display your brand name and logo. It handles typography, spacing, link styling, and optional image logos with automatic dark/light and compact switching.
Whatever you write inside <brand-mark> is content, and the component never changes it: text, an <img> or <svg>, and <em>/<small> taglines are left exactly as authored, through upgrades, moves, and attribute changes. Without JavaScript the same markup renders as plain text. With JavaScript, the src attribute adds one image that the component owns, marked data-brand-mark-img, and only that element is ever updated or removed.
Attributes
| Attribute |
Values |
Default |
Description |
src |
URL |
- |
Logo image (SVG preferred). Adds an owned <picture data-brand-mark-img> before your content; removing the attribute removes only that element. Used in light mode, or in both modes when there is no src-dark. |
src-dark |
URL |
- |
Dark-mode logo. Follows the data-mode attribute on <html>, then the theme’s resolved color-scheme, then prefers-color-scheme. |
src-compact |
URL |
- |
Compact/icon logo, shown while compact-media matches. It is a <source> in the owned <picture>, so the browser switches it natively. It takes priority over src-dark at narrow widths. |
compact-media |
media query |
(width < 48rem) |
When to use src-compact. The default is the --bp-m breakpoint. |
alt |
string |
- |
Text alternative for the logo. See Accessibility for when it is used. |
wordmark |
boolean |
- |
Show your content next to the src logo. Without it, only the logo is visible and your content is visually hidden (it stays in the page as the accessible name). |
height |
number (px) or CSS length |
- |
Logo height. Sets --brand-mark-height on the element, so it also sizes an authored <img>. |
data-size |
s, l, xl |
- |
Adjust brand mark size |
data-stack |
boolean |
- |
Stack logo and text vertically |
Basic Usage
Wrap your brand name in the element, optionally with a logo image. Use an empty alt on the image since the brand name provides the text alternative.
1234
<brand-mark> <img src="/logo.svg" alt="" /> Acme Inc</brand-mark>
Image Logo via src
Use the src attribute to show a logo image. The component adds a <picture data-brand-mark-img> before your content; your content itself is untouched. Without JavaScript the text renders as a fallback.
123
<a href="/"> <brand-mark src="/logo.svg">Acme Inc</brand-mark></a>
By default only the image is visible. “Acme Inc” is still in the page, visually hidden, and is the link’s accessible name.
Use height to set the logo size; themes can also set the --brand-mark-height token. Add src-compact for an icon-sized logo on narrow screens.
123
<brand-mark src="/logo.svg" src-compact="/icon.svg" height="40"> Acme Inc</brand-mark>
Image + Wordmark
Add the wordmark attribute to show your content next to the logo image. Taglines and other children stay as written.
123
<brand-mark src="/icon.svg" wordmark> Acme Inc</brand-mark>
Dark/Light Logo Switching
Use src-dark to provide an alternate logo for dark mode. The component follows the VB data-mode attribute on <html>, then the theme’s color-scheme, then the system prefers-color-scheme preference.
12345
<brand-mark src="/logo-light.svg" src-dark="/logo-dark.svg"> Acme Inc</brand-mark>
The switch is live: toggling the color mode in the settings panel or changing the system preference updates the logo without a page reload.
If only src is provided without src-dark, that logo is used in both modes.
Tagline
Nest an <em> or <small> inside <brand-mark> to display a tagline or subtitle. Combine with data-stack for vertical layouts commonly used in footers.
1234
<brand-mark data-stack> Acme Inc <em>Making things better</em></brand-mark>
The tagline renders in a smaller, muted font with italic style. It works in both inline and stacked layouts.
Sizes
Use data-size to adjust the brand mark for different contexts.
1234567
<brand-mark data-size="s">Small</brand-mark> <brand-mark>Default</brand-mark> <brand-mark data-size="l">Large</brand-mark> <brand-mark data-size="xl">Extra Large</brand-mark>
Stacked Layout
Use data-stack for vertical logo and text arrangement. Useful for centered layouts like login pages or footers.
1234
<brand-mark data-stack> <img src="/logo.svg" alt="" /> Acme Inc</brand-mark>
As a Link
Wrap in an anchor to make the brand mark clickable. The element automatically removes link underlines and adjusts hover states.
123456
<a href="/"> <brand-mark> <img src="/logo.svg" alt="" /> Acme Inc </brand-mark></a>
In a Header
Common usage in site headers with navigation.
1234567891011
<header> <nav> <a href="/"> <brand-mark> <img src="/logo.svg" alt="" /> Acme Inc </brand-mark> </a> </nav></header>
Accessibility
The component never sets aria-label on itself. The owned logo’s alt follows these rules:
- Image only, no
alt attribute: the image gets alt="" and your content, visually hidden but still in the page, is the accessible name.
- Image only, with
alt: the image gets that alt, and your content is hidden from assistive technology as well, so the name is announced once. Use this when the logo says something different from your text.
- With
wordmark: the image is decorative (alt="") and the visible text is the name, so the visible label and the accessible name match.
- No text content: the image gets the
alt attribute. Always set alt when there is no text.
- When adding your own
<img> child, set alt="", since the brand name text provides the text alternative.
- When wrapped in a link, the brand name serves as the link text. Focus states come from the link.
- Ensure sufficient color contrast between brand text and background.
- Without JavaScript, the
src attribute has no effect, and the text content is the readable fallback.
Content Model
Permitted Content
- Text (brand name)
- Optional
<img> or <svg> (logo)
- Optional
<em> or <small> tagline
Authored children are never modified. With src, the component adds one <picture data-brand-mark-img> as the first child; style it with brand-mark > [data-brand-mark-img].
Permitted Parents
Any flow content. Commonly placed inside <a>, <header>, or <nav>.
CSS Tokens
| Token | Default | Description |
--brand-mark-height |
2rem |
Height of the logo image (set by themes, or by the height attribute) |