|
| 1 | +[id="configuring-logo-in-the-global-header.adoc_{context}"] |
| 2 | += Configuring the logo in the global header |
| 3 | + |
| 4 | +You can configure a company logo in the global header of the {product} ({product-very-short}) to reflect your company's branding. `CompanyLogo` is part of the global header by default and offers full control over the theming, navigation behavior, sizing, and fallback options. |
| 5 | + |
| 6 | +This component supports the following props, which are provided through configuration: |
| 7 | + |
| 8 | +* `logo`: The base64 encoded logo image. |
| 9 | +* `to`: The redirect path for when users click the logo is '/catalog'. |
| 10 | +* `width`: The logo width is optional and defaults to 150 px. |
| 11 | +* `height`: The logo height is optional and defaults to 40px. |
| 12 | + |
| 13 | +.Procedure |
| 14 | + |
| 15 | +. To display a custom company logo in the global header, update the configuration with a mount point for `CompanyLogo`: |
| 16 | ++ |
| 17 | +.Example: Configuring company logo |
| 18 | ++ |
| 19 | +[source,yaml,subs="+attributes,+quotes"] |
| 20 | +---- |
| 21 | +# ...rest of the global header configuration |
| 22 | +red-hat-developer-hub.backstage-plugin-global-header: |
| 23 | + mountPoints: |
| 24 | + - mountPoint: application/header |
| 25 | + importName: GlobalHeader |
| 26 | + config: |
| 27 | + # Supported values: `above-main-content` | `above-sidebar` |
| 28 | + position: above-main-content |
| 29 | +
|
| 30 | + - mountPoint: global.header/component |
| 31 | + importName: CompanyLogo |
| 32 | + config: |
| 33 | + priority: 200 |
| 34 | + props: |
| 35 | + # Path to navigate when users click the logo: |
| 36 | + to: '/catalog' |
| 37 | + width: 300 |
| 38 | + height: 200 |
| 39 | + logo: <string> or <object> # Logo can be a base64 string or theme-specific object |
| 40 | + # Example 1: Single logo for all themes |
| 41 | + # logo: "<base64_encoded_images>" |
| 42 | +
|
| 43 | + # Example 2: Theme-specific logos |
| 44 | + # logo: |
| 45 | + dark: 'data:image/png;base64,...' # Used in dark theme |
| 46 | + light: 'data:image/png;base64,...' # Used in light theme |
| 47 | +---- |
| 48 | + |
| 49 | +. (Optional) If you do not provide `logo` props to the `CompanyLogo` component, the component instead uses values defined under `app.branding` in your `{my-app-config-file}` file. You can configure the `CompanyLogo` as shown in the following configuration: |
| 50 | ++ |
| 51 | +.Example: Fallback configuration |
| 52 | ++ |
| 53 | +[source,yaml,subs="+attributes,+quotes"] |
| 54 | +---- |
| 55 | +app: |
| 56 | + branding: |
| 57 | + fullLogoWidth: 220 # Fallback width |
| 58 | + fullLogo: <string> or <object> #fullLogo can be a base64 string or theme-specific object |
| 59 | +
|
| 60 | + # Example 1: Single logo for all themes |
| 61 | + #fullLogo: "<base64_encoded_image> |
| 62 | + # Example 2: Theme-specific logos |
| 63 | + #fullLogo: |
| 64 | + dark: 'data:image/png;base64,...' # Used in dark theme |
| 65 | + light: 'data:image/png;base64,...' # Used in light theme |
| 66 | +---- |
| 67 | ++ |
| 68 | +`CompanyLogo` uses the following configuration elements to control fallback and sizing behavior: |
| 69 | + |
| 70 | +* *Logo source priority* |
| 71 | +** The component selects the logo source in the following order: |
| 72 | ++ |
| 73 | +First, `CompanyLogo` props (logo, logo.light, logo.dark), then, `app.branding.fullLogo`. If you do not provide a logo through either, the component displays the default {product-short} theme-specific logo. |
| 74 | + |
| 75 | +* *Logo width priority* |
| 76 | +** The component applies the first available value from `props.width`, then `app.branding.fullLogoWidth` from `{my-app-config-file}`. If you do not specify the `width` using either, the component applies a default width (150 px). |
| 77 | + |
| 78 | +[NOTE] |
| 79 | +==== |
| 80 | +`CompanyLogo` preserves the images aspect ratio and never crops or distorts it. If the configured width results in a height greater than the maximum allowed (default: 40px), the image is automatically scaled down. As a result, adjusting only the width may not visibly change the logo unless the height is also configured. |
| 81 | +
|
| 82 | +Increasing the logo `height` increases the height of the global header. The component first applies the value from `props.height`. If you do not specify the `height`, the component applies a default height (40px). |
| 83 | +==== |
| 84 | + |
| 85 | +.Verification |
| 86 | +. The logo appears correctly in the global header. |
| 87 | +. Click the logo to confirm it redirects to the path you defined in `props.to`. |
| 88 | +. Toggle between `light` and `dark` themes to ensure the correct logo loads in each. |
| 89 | +. (Optional) Temporarily remove the `CompanyLogo` props to test the fallback to `app.branding.fullLogo`. |
0 commit comments