;
}
-);
+
+ return (
+
+ {render({
+ active,
+ isParent,
+ href,
+ expanded,
+ level,
+ orientation,
+ elementProps,
+ })}
+
+ );
+});
diff --git a/packages/core/stories/navigation-item/navigation-item.stories.tsx b/packages/core/stories/navigation-item/navigation-item.stories.tsx
index 3978fa3f02c..50e2d287085 100644
--- a/packages/core/stories/navigation-item/navigation-item.stories.tsx
+++ b/packages/core/stories/navigation-item/navigation-item.stories.tsx
@@ -3,6 +3,8 @@ import {
FlexLayout,
NavigationItem,
NavigationItemProps,
+ NavigationItemRenderProps,
+ StackLayout,
} from "@salt-ds/core";
import { Meta, StoryFn } from "@storybook/react";
import { useState } from "react";
@@ -585,3 +587,58 @@ export const VerticalNestedGroupNoIcon = () => {
);
};
+
+export const WithRenderProp = () => {
+ const [expanded, setExpanded] = useState(false);
+
+ const render: React.FC<
+ NavigationItemRenderProps
+ > = (props) => {
+ console.log("render NavigationItem with props", props);
+ const { href, isParent, elementProps } = props;
+ if (isParent) {
+ return ;
+ } else {
+ return ;
+ }
+ };
+
+ return (
+
+ );
+};
diff --git a/site/docs/components/navigation-item/examples.mdx b/site/docs/components/navigation-item/examples.mdx
index b9e4f6963ae..f1c68dd757a 100644
--- a/site/docs/components/navigation-item/examples.mdx
+++ b/site/docs/components/navigation-item/examples.mdx
@@ -91,6 +91,13 @@ If a navigation item has nested items within it, it will act as a trigger to sho
When the user collapses a vertical nested group, and there is an active nested item within it, the parent item should be configured with `blurActive={true}`. The indicator will stay on the parent item in the blur-active state. This tells the user that the active item is within this nested structure.
+
+
+
+## Render prop
+
+Configuring the `render` prop, allows the button or anchor element to be replaced with an alternative element.
+
diff --git a/site/src/examples/navigation-item/RenderProp.tsx b/site/src/examples/navigation-item/RenderProp.tsx
new file mode 100644
index 00000000000..43907c1ec19
--- /dev/null
+++ b/site/src/examples/navigation-item/RenderProp.tsx
@@ -0,0 +1,59 @@
+import { ReactElement, useState } from "react";
+import {
+ NavigationItem,
+ NavigationItemRenderProps,
+ StackLayout,
+} from "@salt-ds/core";
+
+const render: React.FC<
+ NavigationItemRenderProps
+> = (props) => {
+ console.log("render NavigationItem with props", props);
+ const { href, isParent, elementProps } = props;
+ if (isParent) {
+ return ;
+ }
+ return ;
+};
+
+export const RenderProp = (): ReactElement => {
+ const [expanded, setExpanded] = useState(false);
+ return (
+
+ );
+};
diff --git a/site/src/examples/navigation-item/index.ts b/site/src/examples/navigation-item/index.ts
index 447e611f20e..37aefc786b1 100644
--- a/site/src/examples/navigation-item/index.ts
+++ b/site/src/examples/navigation-item/index.ts
@@ -5,5 +5,6 @@ export * from "./WithIcon";
export * from "./WithBadge";
export * from "./WithNestedItems";
export * from "./HorizontalGroup";
+export * from "./RenderProp";
export * from "./VerticalGroup";
export * from "./VerticalNestedGroup";