This component is only used for HealthCare. Please use the theme switcher to view the component with HealthCare styles.
Examples
The HealthCare.gov header component varies depending on the user's state (ie. logged-in) and context (ie. what page the user is on).
Logged-In
Logged-Out
Minimal
Code
React
Name | Type | Default | Description |
---|---|---|---|
className | string | Additional classes to be added to the root <header> element. | |
switchLocaleLink | string | For applications that handle their own locale switching. Overrides the
default locale link. This takes precedence over the subpath prop. | |
loggedIn | boolean | Indicate that a user is logged-in. | |
hideLoginLink | boolean | When set to true, do not display the Login text in the upper right of the header | |
hideLogoutLink | boolean | When set to true, even if logged in the Logout link will not render | |
hideLanguageSwitch | boolean | When set to true, do not display the the switch locale link | |
firstName | string | For logged-in users, pass in their first name to display in the header | |
subpath | string | For applications hosted at paths other than the root healthcare.gov /
cuidadodesalud.gov . This string will be appended to the end of the
language links so as to keep the user within the same part of the site
when switching languages. | |
primaryDomain | string | The primary, or root domain where the majority of header links should be
hosted. By default, links render with relative paths, but providing this
prop will force all links to render with absolute paths based on the
provided string. The string should include the protocol (http:// or
https:// ) and the domain only, with no trailing slash. For example, if
the provided string is https://test.healthcare.gov , the login link will
render as https://test.healthcare.gov/login instead of just /login .
Note that this is only really necessary if your application is hosted on a
subdomain, such as https://localhelp.healthcare.gov , where relative links
would direct the user to the wrong location, e.g. the link to /login
would incorrectly direct the user to
https://localhelp.healthcare.gov/login when it should direct the user to
https://healthcare.gov/login . | |
skipNavHref | string | #main | A URL hash used for the "Skip to main content" link. This is
typically the id of your "main" content area (ie. #main ). |
onSkipNavClick | (...args: any[]) => any | An onClick handler used for the "Skip to main content" link. This can be used in cases where one would need to manually set the focus on the content area (e.g. where hash routing is being used). | |
deConsumer | boolean | Indicates when a consumer is coming from a Direct Enrollment flow. This will include additional messaging and modify some of the links. | |
deBrokerName | string | Used in conjunction with deConsumer , the Direct Enrollment broker's
name is used in some of the messaging displayed to the consumer. | |
links | Link[] | Optionally pass in an array of link objects to override the default
set of menu links. This may be useful if you need to customize the
links on a page-by-page basis. To reference the default set of menu
links, you can import the defaultMenuLinks method. | |
submenuTop | ReactNode | Optionally pass a React component to render within the menu. Useful for
when you need more control over what appears in the menu than what's
provided by the links prop, e.g. a search input. Will appear above any
links provided by the defaultMenuLinks method or the links provided by
the links prop. | |
submenuBottom | ReactNode | Same as submenuTop , except it will appear below any links provided by
the defaultMenuLinks method or the links provided by the links prop. | |
headerBottom | ReactNode | Element added to display content on Header bottom section | |
isMenuOpen | boolean | Open and handler function for fully controlled menu behavior | |
onMenuToggle | () => void | ||
logoClassName | string | Additional classes to be added to the Logo component |
Google Analytics
Analytics event tracking is enabled by default.
On applications where the page has utag
loaded, the data goes to Tealium which allows it to route to Google Analytics or the currently approved data analytics tools.
Disabling event tracking
Import and set the setHeaderSendsAnalytics
feature flag to false
in your application's entry file:
import { setHeaderSendsAnalytics } from "@cmsgov/<design-system-package>";
setHeaderSendsAnalytics(false);
Component maturity
For more information about how we tested and validated our work for each checklist item, read our component maturity documentation.