diff --git a/packages/sanity/src/core/config/studio/types.ts b/packages/sanity/src/core/config/studio/types.ts index 3406fd7068c..a8e3a5657b2 100644 --- a/packages/sanity/src/core/config/studio/types.ts +++ b/packages/sanity/src/core/config/studio/types.ts @@ -18,20 +18,30 @@ export interface LogoProps { renderDefault: (props: LogoProps) => React.JSX.Element } -/** - * @internal - * @beta - * An internal API for defining actions in the navbar. - */ -export interface NavbarAction { +interface NavbarActionBase { icon?: React.ComponentType location: 'topbar' | 'sidebar' name: string +} + +interface ActionWithCustomRender extends NavbarActionBase { + render: () => React.ReactElement +} + +interface Action extends NavbarActionBase { onAction: () => void selected: boolean title: string + render?: undefined } +/** + * @internal + * @beta + * An internal API for defining actions in the navbar. + */ +export type NavbarAction = Action | ActionWithCustomRender + /** * @hidden * @beta */ diff --git a/packages/sanity/src/core/studio/components/navbar/StudioNavbar.tsx b/packages/sanity/src/core/studio/components/navbar/StudioNavbar.tsx index d0355c94a37..51ac2975c21 100644 --- a/packages/sanity/src/core/studio/components/navbar/StudioNavbar.tsx +++ b/packages/sanity/src/core/studio/components/navbar/StudioNavbar.tsx @@ -164,6 +164,10 @@ export function StudioNavbar(props: Omit) { return actions ?.filter((v) => v.location === 'topbar') ?.map((action) => { + const {render: ActionComponent} = action + + if (ActionComponent) return + return (