--- sidebar_label: "Header" --- import { TypeList } from "docs-ui" export const metadata = { title: `Header - Admin Components`, } # {metadata.title} Each section in the Medusa Admin has a header with a title, and optionally a subtitle with buttons to perform an action. ![Example of a header in a section](https://res.cloudinary.com/dza7lstvk/image/upload/v1728288562/Medusa%20Resources/header_dtz4gl.png) To create a component that uses the same header styling and structure, create the file `src/admin/components/header.tsx` with the following content: ```tsx title="src/admin/components/header.tsx" import { Heading, Button, Text } from "@medusajs/ui" import React from "react" import { Link, LinkProps } from "react-router-dom" import { ActionMenu, ActionMenuProps } from "./action-menu" export type HeadingProps = { title: string subtitle?: string actions?: ( { type: "button", props: React.ComponentProps link?: LinkProps } | { type: "action-menu" props: ActionMenuProps } | { type: "custom" children: React.ReactNode } )[] } export const Header = ({ title, subtitle, actions = [], }: HeadingProps) => { return (
{title} {subtitle && ( {subtitle} )}
{actions.length > 0 && (
{actions.map((action, index) => ( <> {action.type === "button" && ( )} {action.type === "action-menu" && ( )} {action.type === "custom" && action.children} ))}
)}
) } ``` The `Header` component shows a title, and optionally a subtitle and action buttons. The component also uses the [Action Menu](../action-menu/page.mdx) custom component. It accepts the following props: --- ## Example Use the `Header` component in any widget or UI route. For example, create the widget `src/admin/widgets/product-widget.tsx` with the following content: ```tsx title="src/admin/widgets/product-widget.tsx" import { defineWidgetConfig } from "@medusajs/admin-sdk" import { Container } from "../components/container" import { Header } from "../components/header" const ProductWidget = () => { return (
{ alert("You clicked the button.") }, }, }, ]} /> ) } export const config = defineWidgetConfig({ zone: "product.details.before", }) export default ProductWidget ``` This widget also uses a [Container](../container/page.mdx) custom component.