Skip to content

The open alternative to Salesforce, designed for AI.

Share Breadcrumb navigation in Twenty UI (#27001)

Raphaël Bosi1d561b8c73c9
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.json
index bee453491ba..704d372edfd 100644
--- a/packages/twenty-docs/docs.json
+++ b/packages/twenty-docs/docs.json
@@ -589,6 +589,7 @@
{
"group": "Navigation",
"pages": [
+ "ui/primitives/navigation/breadcrumb",
"ui/primitives/navigation/list-item",
"ui/primitives/navigation/tabs"
]
diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.json
index 398e234d1cb..c7085965de8 100644
--- a/packages/twenty-docs/navigation/base-structure.json
+++ b/packages/twenty-docs/navigation/base-structure.json
@@ -604,6 +604,7 @@
"key": "uiNavigation",
"label": "Navigation",
"pages": [
+ "ui/primitives/navigation/breadcrumb",
"ui/primitives/navigation/list-item",
"ui/primitives/navigation/tabs"
]
diff --git a/packages/twenty-docs/snippets/ui/generated/navigation/breadcrumb.mdx b/packages/twenty-docs/snippets/ui/generated/navigation/breadcrumb.mdx
new file mode 100644
index 00000000000..4f46444bcf6
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/navigation/breadcrumb.mdx
@@ -0,0 +1,20 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file
+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten
+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs
+ * |___/
+ *
+ * This file is generated from the documentation data in packages/twenty-ui/generated.
+ * To update it, edit the component prop types or design tokens in twenty-ui and run:
+ * npx nx generate:ui twenty-docs
+ */}
+
+<ParamField body="links" type="BreadcrumbItem[]" required>
+ Ordered trail items. Each item accepts `children`, `href`, `render`, and `title`. The final item represents the current page.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+ Caller-supplied root element or renderer. Preserve the navigation landmark and forward the supplied props and ref.
+</ParamField>
diff --git a/packages/twenty-docs/ui/primitives/navigation/breadcrumb.mdx b/packages/twenty-docs/ui/primitives/navigation/breadcrumb.mdx
new file mode 100644
index 00000000000..97978fbfd9d
--- /dev/null
+++ b/packages/twenty-docs/ui/primitives/navigation/breadcrumb.mdx
@@ -0,0 +1,79 @@
+---
+title: Breadcrumb
+description: Show a page's location with a trail of ancestor links.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+
+import BreadcrumbReference from '/snippets/ui/generated/navigation/breadcrumb.mdx';
+
+`Breadcrumb` renders an ordered navigation trail. It owns separators, current-page semantics, link focus styles, and truncation of the current item's label.
+
+<StoryEmbed
+ storyId="primitives-navigation-breadcrumb--default"
+ title="Breadcrumb example"
+ height={160}
+/>
+
+## Usage
+
+Pass items in ancestor-to-current order. The navigation landmark defaults to the accessible name `Breadcrumb`; use `aria-label` to localize it or distinguish multiple trails. The final item receives `aria-current="page"`, whether it has a destination or displays plain text.
+
+```tsx
+import { Breadcrumb } from 'twenty-ui/primitives/navigation';
+
+export const CompanyBreadcrumb = () => (
+ <Breadcrumb
+ aria-label="Breadcrumb"
+ links={[
+ { children: 'Home', href: '/' },
+ { children: 'Companies', href: '/companies' },
+ { children: 'Acme' },
+ ]}
+ />
+);
+```
+
+Items with `href` use native links. Items without a destination are text. Separators are decorative and hidden from assistive technology. Links follow the browser's normal Tab and Enter behavior.
+
+## Router links
+
+Use an item's `render` prop to supply your router's link component, alongside `href`. The rendered link must forward the supplied props and ref to its anchor. See [custom components](/ui/primitives/overview#custom-components) for composition requirements.
+
+The application chooses destinations and decides when to show a mobile back action. `Breadcrumb` does not infer routes or collapse ancestors into a menu.
+
+## Long labels
+
+The current item shrinks and truncates with an ellipsis when the container has limited space. Ancestor items retain their width. Plain string labels become the native browser tooltip automatically. Use `title` to override that text or provide a tooltip for rich content.
+
+<StoryEmbed
+ storyId="primitives-navigation-breadcrumb--truncation"
+ title="Breadcrumb with a long current page label"
+ height={160}
+/>
+
+## Rich content
+
+An item's `children` can include text and supporting visual content. Keep the label readable and avoid nesting interactive controls inside a link.
+
+<StoryEmbed
+ storyId="primitives-navigation-breadcrumb--rich-content"
+ title="Breadcrumb with supporting content"
+ height={160}
+/>
+
+## Text direction
+
+The trail follows the surrounding text direction. Set `dir="rtl"` on `Breadcrumb` or an ancestor for right-to-left content. When other controls need matching directional keyboard or pointer behavior, also set [TextDirectionProvider](/ui/primitives/layout/text-direction-provider) to the same direction.
+
+<StoryEmbed
+ storyId="primitives-navigation-breadcrumb--rtl"
+ title="Breadcrumb in right-to-left content"
+ height={160}
+/>
+
+## Props
+
+Native navigation attributes, including accessible names, `className`, `style`, and event handlers, reach the root landmark.
+
+<BreadcrumbReference />
diff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
index 9ac7cc70324..aa1842ec026 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -1,3 +1,4 @@
+import { breadcrumbTest } from '@/__stories__/twenty-ui-gallery/utils/breadcrumbTest';
import { jsonTreeTest } from '@/__stories__/twenty-ui-gallery/utils/jsonTreeTest';
import { inlineBannerSandboxTest } from '@/__stories__/twenty-ui-gallery/utils/inlineBannerSandboxTest';
import { themeTokenTest } from '@/__stories__/twenty-ui-gallery/utils/themeTokenTest';
@@ -226,6 +227,18 @@ export const DisplayHelpersPreact: Story = createGalleryStory({
play: displayHelpersTest,
});
+export const BreadcrumbReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-breadcrumb',
+ runtime: 'react',
+ play: breadcrumbTest,
+});
+
+export const BreadcrumbPreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-breadcrumb',
+ runtime: 'preact',
+ play: breadcrumbTest,
+});
+
export const ListItemReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-list-item',
runtime: 'react',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-breadcrumb.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-breadcrumb.front-component.tsx
new file mode 100644
index 00000000000..e94cfc1f759
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-breadcrumb.front-component.tsx
@@ -0,0 +1,50 @@
+import { useState } from 'react';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import { Breadcrumb } from 'twenty-ui/primitives/navigation';
+import { Text } from 'twenty-ui/primitives/typography';
+
+import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
+
+const BreadcrumbExample = () => {
+ const [activations, setActivations] = useState(0);
+ const [composedActivations, setComposedActivations] = useState(0);
+
+ return (
+ <TwentyUiGalleryCard title="Breadcrumb">
+ <Breadcrumb
+ aria-label="Account breadcrumb"
+ onClick={() => setActivations((count) => count + 1)}
+ links={[
+ { children: 'Objects', href: '/objects' },
+ {
+ children: 'Account',
+ href: '/objects/account',
+ render: (
+ <a onClick={() => setComposedActivations((count) => count + 1)} />
+ ),
+ },
+ ]}
+ />
+ <Breadcrumb
+ aria-label="Truncated breadcrumb"
+ style={{ width: 220 }}
+ links={[
+ { children: 'Settings', href: '/settings' },
+ {
+ children: 'A long account name that stays available when truncated',
+ },
+ ]}
+ />
+ <Text role="status">
+ Activations: {activations}; Composed activations: {composedActivations}
+ </Text>
+ </TwentyUiGalleryCard>
+ );
+};
+
+export default defineFrontComponent({
+ universalIdentifier: 'e5e0d2b9-5227-4376-bc92-364cb55a9f72',
+ name: 'twenty-ui-breadcrumb',
+ description: 'Breadcrumb links, current items, and truncation in the sandbox',
+ component: BreadcrumbExample,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
index 5eb29b30222..dfcb5cd8e42 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
@@ -11,7 +11,7 @@ import {
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
import { IconHome, IconUser } from 'twenty-ui/icon';
import { ColorSample, Tag } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { Breadcrumb, ListItem } from 'twenty-ui/primitives/navigation';
import { ThemeProvider } from 'twenty-ui/theme';
import {
ComponentGallery,
@@ -19,6 +19,18 @@ import {
} from '../shared/front-components/component-gallery';
const NAVIGATION_ENTRIES: GalleryEntry[] = [
+ {
+ name: 'Breadcrumb',
+ node: (
+ <Breadcrumb
+ aria-label="Workspace breadcrumb"
+ links={[
+ { children: 'Workspace', href: '/workspace' },
+ { children: 'Settings' },
+ ]}
+ />
+ ),
+ },
{
name: 'MenuItem',
node: <MenuItem text="Menu item" LeftIcon={IconUser} />,
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/breadcrumbTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/breadcrumbTest.ts
new file mode 100644
index 00000000000..68347203e12
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/breadcrumbTest.ts
@@ -0,0 +1,75 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const breadcrumbTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ await expectFrontComponentMounted(canvas);
+
+ const navigation = canvas.getByRole('navigation', {
+ name: 'Account breadcrumb',
+ });
+ const trail = within(navigation);
+ const objects = trail.getByRole('link', { name: 'Objects' });
+ const account = trail.getByRole('link', { name: 'Account', current: 'page' });
+
+ await expect(trail.getByRole('list').tagName).toBe('OL');
+ await expect(trail.getAllByRole('listitem')).toHaveLength(2);
+ await expect(trail.getByText('/')).toHaveAttribute('aria-hidden', 'true');
+ await expect(objects).toHaveAttribute('href', '/objects');
+ await expect(objects).not.toHaveAttribute('aria-current');
+ await expect(account).toHaveAttribute('href', '/objects/account');
+ await expect(account.tagName).toBe('A');
+
+ const preventNavigation = (event: Event) => event.preventDefault();
+ navigation.addEventListener('click', preventNavigation);
+
+ try {
+ await userEvent.click(objects);
+ await expect(objects).toHaveFocus();
+ await waitFor(() =>
+ expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Activations: 1; Composed activations: 0',
+ ),
+ );
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() =>
+ expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Activations: 2; Composed activations: 0',
+ ),
+ );
+ await userEvent.tab();
+ await expect(account).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() =>
+ expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Activations: 3; Composed activations: 1',
+ ),
+ );
+ } finally {
+ navigation.removeEventListener('click', preventNavigation);
+ }
+
+ const truncatedNavigation = canvas.getByRole('navigation', {
+ name: 'Truncated breadcrumb',
+ });
+ const truncatedTrail = within(truncatedNavigation);
+ const currentItem = truncatedTrail.getByText(
+ 'A long account name that stays available when truncated',
+ );
+
+ await expect(currentItem).toHaveAttribute('aria-current', 'page');
+ await expect(truncatedTrail.getAllByRole('link')).toHaveLength(1);
+ await waitFor(() => {
+ expect(getComputedStyle(currentItem).textOverflow).toBe('ellipsis');
+ expect(currentItem.scrollWidth).toBeGreaterThan(currentItem.clientWidth);
+ expect(truncatedNavigation.scrollWidth).toBeLessThanOrEqual(
+ truncatedNavigation.clientWidth,
+ );
+ });
+ await expect(errorHandler).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/FormAdvancedTextFieldInput.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/FormAdvancedTextFieldInput.tsx
index 466567c1eca..d6b765637ea 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/components/FormAdvancedTextFieldInput.tsx
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/FormAdvancedTextFieldInput.tsx
@@ -7,7 +7,7 @@ import { serializeAdvancedTextEditorDocument } from '@/advanced-text-editor/util
import { FormFieldInputContainer } from '@/ui/input/components/FormFieldInputContainer';
import { type VariablePickerComponent } from '@/ui/input/types/VariablePickerComponent';
import { useFullScreenModal } from '@/ui/layout/fullscreen/hooks/useFullScreenModal';
-import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
import { usePushFocusItemToFocusStack } from '@/ui/utilities/focus/hooks/usePushFocusItemToFocusStack';
import { useRemoveFocusItemFromFocusStackById } from '@/ui/utilities/focus/hooks/useRemoveFocusItemFromFocusStackById';
import { useRemoveFocusItemFromFocusStackOnUnmount } from '@/ui/utilities/focus/hooks/useRemoveFocusItemFromFocusStackOnUnmount';
diff --git a/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsx b/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsx
index cf93ab21de3..22c5ee5adc1 100644
--- a/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsx
+++ b/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsx
@@ -3,7 +3,7 @@ import { SettingsSecondaryBar } from '@/settings/components/layout/SettingsSecon
import { SidePanelPageTitleSyncEffect } from '@/side-panel/components/SidePanelPageTitleSyncEffect';
import { PageCardHeader } from '@/ui/layout/page/components/PageCardHeader';
import { PageCardLayout } from '@/ui/layout/page/components/PageCardLayout';
-import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
import { useId, type JSX, type ReactNode } from 'react';
import { isDefined } from 'twenty-shared/utils';
diff --git a/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenContainer.tsx b/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenContainer.tsx
index 92ee454335c..621188fd3c5 100644
--- a/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenContainer.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenContainer.tsx
@@ -1,10 +1,8 @@
import { type JSX } from 'react';
import { PageHeader } from '@/ui/layout/page/components/PageHeader';
import { PAGE_BAR_MIN_HEIGHT } from '@/ui/layout/page/constants/PageBarMinHeight';
-import {
- Breadcrumb,
- type BreadcrumbProps,
-} from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
import { styled } from '@linaria/react';
import { useIsMobile } from 'twenty-ui/utilities';
import { themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenModal.tsx b/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenModal.tsx
index ce0d95c0483..34970800471 100644
--- a/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenModal.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/fullscreen/components/FullScreenModal.tsx
@@ -1,9 +1,7 @@
import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices';
import { PageHeader } from '@/ui/layout/page/components/PageHeader';
-import {
- Breadcrumb,
- type BreadcrumbProps,
-} from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
import { styled } from '@linaria/react';
import { forwardRef } from 'react';
import { themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/modules/ui/layout/fullscreen/hooks/useFullScreenModal.tsx b/packages/twenty-front/src/modules/ui/layout/fullscreen/hooks/useFullScreenModal.tsx
index 5e1b83f154b..6a77129f0b0 100644
--- a/packages/twenty-front/src/modules/ui/layout/fullscreen/hooks/useFullScreenModal.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/fullscreen/hooks/useFullScreenModal.tsx
@@ -1,5 +1,5 @@
import { FullScreenModal } from '@/ui/layout/fullscreen/components/FullScreenModal';
-import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
import { useRef } from 'react';
import { createPortal } from 'react-dom';
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsx
index 5df826d4775..86e01efee4c 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsx
@@ -2,10 +2,8 @@ import { APP_HEADER_HEIGHT } from '@/ui/layout/constants/AppHeaderHeight';
import { useNavigationDrawerExpanded } from '@/navigation/hooks/useNavigationDrawerExpanded';
import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';
import { useWorkspaceSurfaceHeaderPortal } from '@/ui/layout/hooks/useWorkspaceSurfaceHeaderPortal';
-import {
- Breadcrumb,
- type BreadcrumbProps,
-} from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
import { PAGE_ACTION_CONTAINER_CLICK_OUTSIDE_ID } from '@/ui/layout/page/constants/PageActionContainerClickOutsideId';
import { NavigationDrawerCollapseButton } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton';
import { useIsMobile } from 'twenty-ui/utilities';
diff --git a/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/Breadcrumb.tsx b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/Breadcrumb.tsx
index 9c5b1d4c5ea..2746d728430 100644
--- a/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/Breadcrumb.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/Breadcrumb.tsx
@@ -1,82 +1,23 @@
import { MobileBreadcrumb } from '@/ui/navigation/bread-crumb/components/MobileBreadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
+import { getBreadcrumbItems } from '@/ui/navigation/bread-crumb/utils/getBreadcrumbItems';
+import { t } from '@lingui/core/macro';
+import { isNonEmptyArray } from 'twenty-shared/utils';
+import { Breadcrumb as BreadcrumbPrimitive } from 'twenty-ui/primitives/navigation';
import { useIsMobile } from 'twenty-ui/utilities';
-import { styled } from '@linaria/react';
-import { Fragment, type ReactNode } from 'react';
-import { Link } from 'react-router-dom';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-export type BreadcrumbProps = {
- className?: string;
- links: { children: string | ReactNode; href?: string }[];
-};
-
-const StyledWrapper = styled.nav`
- align-items: center;
- color: ${themeCssVariables.font.color.tertiary};
- display: flex;
- font-size: ${themeCssVariables.font.size.md};
- gap: ${themeCssVariables.spacing[1]};
- height: ${themeCssVariables.spacing[8]};
- max-width: 100%;
- min-width: 0;
- overflow: hidden;
-`;
-
-const StyledCrumbContainer = styled.span<{ $isLast: boolean }>`
- flex: ${({ $isLast }) => ($isLast ? '0 1 auto' : '0 0 auto')};
- min-width: 0;
- overflow: hidden;
-`;
-
-const StyledLink = styled(Link)`
- color: inherit;
- display: block;
- overflow: hidden;
- text-decoration: none;
- text-overflow: ellipsis;
- white-space: nowrap;
-`;
-
-const StyledText = styled.span`
- color: ${themeCssVariables.font.color.primary};
- display: block;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-`;
-
-const StyledDivider = styled.span`
- flex: 0 0 ${themeCssVariables.spacing[2]};
-`;
export const Breadcrumb = ({ className, links }: BreadcrumbProps) => {
const isMobile = useIsMobile();
- if (isMobile && links.length > 0) {
+ if (isMobile && isNonEmptyArray(links)) {
return <MobileBreadcrumb className={className} links={links} />;
}
return (
- <StyledWrapper className={className}>
- {links.map((link, index) => {
- const text = typeof link.children === 'string' ? link.children : '';
- const isLast = index === links.length - 1;
-
- return (
- <Fragment key={index}>
- <StyledCrumbContainer $isLast={isLast}>
- {link.href ? (
- <StyledLink title={text} to={link.href}>
- {link.children}
- </StyledLink>
- ) : (
- <StyledText title={text}>{link.children}</StyledText>
- )}
- </StyledCrumbContainer>
- {index < links.length - 1 && <StyledDivider>/</StyledDivider>}
- </Fragment>
- );
- })}
- </StyledWrapper>
+ <BreadcrumbPrimitive
+ aria-label={t`Breadcrumb`}
+ className={className}
+ links={getBreadcrumbItems(links)}
+ />
);
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/MobileBreadcrumb.tsx b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/MobileBreadcrumb.tsx
index 7b909a54735..889908b4324 100644
--- a/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/MobileBreadcrumb.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/MobileBreadcrumb.tsx
@@ -1,16 +1,17 @@
-import { t } from '@lingui/core/macro';
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
+import { getBreadcrumbItems } from '@/ui/navigation/bread-crumb/utils/getBreadcrumbItems';
+import { t } from '@lingui/core/macro';
+import { Trans } from '@lingui/react/macro';
import { styled } from '@linaria/react';
import { isNonEmptyString } from '@sniptt/guards';
-import { type ReactNode } from 'react';
import { Link } from 'react-router-dom';
+import { isDefined } from 'twenty-shared/utils';
import { IconChevronLeft } from 'twenty-ui/icon';
+import { Breadcrumb as BreadcrumbPrimitive } from 'twenty-ui/primitives/navigation';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';
-export type MobileBreadcrumbProps = {
- className?: string;
- links: { children: string | ReactNode; href?: string }[];
-};
+type MobileBreadcrumbProps = BreadcrumbProps;
const StyledWrapper = styled.nav`
align-items: center;
@@ -25,18 +26,25 @@ const StyledWrapper = styled.nav`
`;
const StyledLinkContainer = styled.div`
+ min-width: 0;
+
> a {
color: inherit;
+ display: block;
overflow: hidden;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
+
+ &:focus-visible {
+ outline: 2px solid ${themeCssVariables.color.blue};
+ outline-offset: -2px;
+ }
}
`;
const StyledText = styled.span`
color: inherit;
- cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -53,25 +61,34 @@ export const MobileBreadcrumb = ({
return null;
}
- const previousLink = links[links.length - 2];
+ const previousLink = links.at(-2);
+
+ if (!isDefined(previousLink)) {
+ return (
+ <BreadcrumbPrimitive
+ aria-label={t`Breadcrumb`}
+ className={className}
+ links={getBreadcrumbItems(links)}
+ />
+ );
+ }
- const text = isNonEmptyString(previousLink.children)
- ? previousLink.children
- : '';
+ const text = previousLink.children;
+ const title = isNonEmptyString(text) ? text : undefined;
return (
- <StyledWrapper className={className}>
- {previousLink?.href ? (
+ <StyledWrapper aria-label={t`Breadcrumb`} className={className}>
+ {isNonEmptyString(previousLink.href) ? (
<>
- <IconChevronLeft size={theme.icon.size.md} />
+ <IconChevronLeft size={theme.icon.size.md} aria-hidden />
<StyledLinkContainer>
- <Link title={text} to={previousLink.href}>
- {t`Back to ${text}`}
+ <Link title={title} to={previousLink.href}>
+ <Trans>Back to {text}</Trans>
</Link>
</StyledLinkContainer>
</>
) : (
- <StyledText title={text}>{previousLink?.children}</StyledText>
+ <StyledText title={title}>{text}</StyledText>
)}
</StyledWrapper>
);
diff --git a/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/__stories__/Breadcrumb.interactions.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/__stories__/Breadcrumb.interactions.stories.tsx
new file mode 100644
index 00000000000..7fa9e1cd2b3
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/components/__stories__/Breadcrumb.interactions.stories.tsx
@@ -0,0 +1,193 @@
+import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { setupI18n } from '@lingui/core';
+import { msg } from '@lingui/core/macro';
+import { I18nProvider } from '@lingui/react';
+import { Trans } from '@lingui/react/macro';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { MemoryRouter, useLocation } from 'react-router-dom';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { Text } from 'twenty-ui/primitives/typography';
+import {
+ ComponentDecorator,
+ overrideMediaQueryMatches,
+} from 'twenty-ui/testing';
+import { MOBILE_MEDIA_QUERY } from 'twenty-ui/utilities';
+import { messages as frenchMessages } from '~/locales/generated/fr-FR';
+
+const frenchI18n = setupI18n({
+ locale: 'fr-FR',
+ messages: { 'fr-FR': frenchMessages },
+});
+
+const CurrentLocation = () => {
+ const { pathname } = useLocation();
+
+ return (
+ <Text render={<output aria-label="Current location" />}>{pathname}</Text>
+ );
+};
+
+const meta: Meta<typeof Breadcrumb> = {
+ title: 'UI/Navigation/Breadcrumb/Interactions',
+ component: Breadcrumb,
+ decorators: [ComponentDecorator],
+ args: {
+ links: [
+ { children: 'Objects', href: '/objects' },
+ { children: 'Companies', href: '/objects/companies' },
+ { children: 'New' },
+ ],
+ },
+ parameters: {
+ container: { width: 350 },
+ },
+ render: (args) => (
+ <MemoryRouter initialEntries={['/objects/companies/new']}>
+ <Breadcrumb {...args} />
+ <CurrentLocation />
+ </MemoryRouter>
+ ),
+};
+
+export default meta;
+type Story = StoryObj<typeof Breadcrumb>;
+
+export const RouterNavigation: Story = {
+ beforeEach: () => overrideMediaQueryMatches({ [MOBILE_MEDIA_QUERY]: false }),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const navigation = canvas.getByRole('navigation', { name: 'Breadcrumb' });
+ const objectsLink = within(navigation).getByRole('link', {
+ name: 'Objects',
+ });
+ const currentLocation = canvas.getByRole('status', {
+ name: 'Current location',
+ });
+
+ await expect(objectsLink).toHaveAttribute('href', '/objects');
+ await expect(within(navigation).getByText('New')).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ );
+ objectsLink.focus();
+ await expect(objectsLink).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(currentLocation.textContent).toBe('/objects');
+ await userEvent.click(
+ within(navigation).getByRole('link', { name: 'Companies' }),
+ );
+ await expect(currentLocation.textContent).toBe('/objects/companies');
+ },
+};
+
+export const MobileSingleItem: Story = {
+ beforeEach: () => overrideMediaQueryMatches({ [MOBILE_MEDIA_QUERY]: true }),
+ args: {
+ links: [{ children: 'Text Editor' }],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const navigation = await canvas.findByRole('navigation', {
+ name: 'Breadcrumb',
+ });
+
+ await expect(within(navigation).getByText('Text Editor')).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ );
+ await expect(
+ within(navigation).queryByRole('link'),
+ ).not.toBeInTheDocument();
+ },
+};
+
+export const MobileSettingsBack: Story = {
+ beforeEach: () => overrideMediaQueryMatches({ [MOBILE_MEDIA_QUERY]: true }),
+ args: {
+ links: [
+ { children: 'User', href: '/settings/profile' },
+ {
+ children: <Trans>Account</Trans>,
+ href: '/settings/accounts',
+ },
+ { children: 'Email' },
+ ],
+ },
+ render: (args) => (
+ <MemoryRouter initialEntries={['/settings/accounts/email']}>
+ <Breadcrumb {...args} />
+ <CurrentLocation />
+ </MemoryRouter>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const backLink = await canvas.findByRole('link', {
+ name: 'Back to Account',
+ });
+
+ await expect(backLink).toHaveAttribute('href', '/settings/accounts');
+ await expect(
+ canvas.queryByRole('link', { name: 'User' }),
+ ).not.toBeInTheDocument();
+ backLink.focus();
+ await expect(backLink).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(
+ canvas.getByRole('status', { name: 'Current location' }).textContent,
+ ).toBe('/settings/accounts');
+ },
+};
+
+export const MobileSettingsRoot: Story = {
+ beforeEach: () => overrideMediaQueryMatches({ [MOBILE_MEDIA_QUERY]: true }),
+ args: {
+ links: [
+ { children: 'Workspace', href: '/settings/general' },
+ { children: 'General' },
+ ],
+ },
+ render: (args) => (
+ <MemoryRouter initialEntries={['/settings/general']}>
+ <Breadcrumb {...args} />
+ <CurrentLocation />
+ </MemoryRouter>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await waitFor(() =>
+ expect(canvas.queryByRole('navigation')).not.toBeInTheDocument(),
+ );
+ await expect(
+ canvas.getByRole('status', { name: 'Current location' }),
+ ).toHaveTextContent('/settings/general');
+ },
+};
+
+export const MobileTranslatedBack: Story = {
+ ...MobileSettingsBack,
+ render: (args) => (
+ <I18nProvider i18n={frenchI18n}>
+ <MemoryRouter initialEntries={['/settings/accounts/email']}>
+ <Breadcrumb {...args} />
+ <CurrentLocation />
+ </MemoryRouter>
+ </I18nProvider>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const text = frenchI18n._(msg`Account`);
+ const translatedBackLabel = frenchI18n._(msg`Back to ${text}`);
+
+ await expect(translatedBackLabel).not.toBe(`Back to ${text}`);
+
+ const backLink = await canvas.findByRole('link', {
+ name: translatedBackLabel,
+ });
+
+ await userEvent.click(backLink);
+ await expect(
+ canvas.getByRole('status', { name: 'Current location' }).textContent,
+ ).toBe('/settings/accounts');
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/navigation/bread-crumb/types/BreadcrumbProps.ts b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/types/BreadcrumbProps.ts
new file mode 100644
index 00000000000..789e2fd8039
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/types/BreadcrumbProps.ts
@@ -0,0 +1,6 @@
+import { type BreadcrumbItem } from 'twenty-ui/primitives/navigation';
+
+export type BreadcrumbProps = {
+ className?: string;
+ links: Pick<BreadcrumbItem, 'children' | 'href'>[];
+};
diff --git a/packages/twenty-front/src/modules/ui/navigation/bread-crumb/utils/getBreadcrumbItems.tsx b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/utils/getBreadcrumbItems.tsx
new file mode 100644
index 00000000000..6c3d60a94f9
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/bread-crumb/utils/getBreadcrumbItems.tsx
@@ -0,0 +1,13 @@
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
+import { isNonEmptyString } from '@sniptt/guards';
+import { Link } from 'react-router-dom';
+import { type BreadcrumbItem } from 'twenty-ui/primitives/navigation';
+
+export const getBreadcrumbItems = (
+ links: BreadcrumbProps['links'],
+): BreadcrumbItem[] =>
+ links.map(({ children, href }) => ({
+ children,
+ href: isNonEmptyString(href) ? href : undefined,
+ render: isNonEmptyString(href) ? <Link to={href} /> : undefined,
+ }));
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
index 5e4d30164e0..ae733c17885 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
@@ -2,7 +2,7 @@ import { useGetAvailablePackages } from '@/logic-functions/hooks/useGetAvailable
import { useLogicFunctionForm } from '@/logic-functions/hooks/useLogicFunctionForm';
import { useFullScreenModal } from '@/ui/layout/fullscreen/hooks/useFullScreenModal';
import { TabListRoot } from '@/ui/layout/tab-list/components/TabListRoot';
-import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
+import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/types/BreadcrumbProps';
import { useGetUpdatableWorkflowVersionOrThrow } from '@/workflow/hooks/useGetUpdatableWorkflowVersionOrThrow';
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
import { workflowVisualizerWorkflowIdComponentState } from '@/workflow/states/workflowVisualizerWorkflowIdComponentState';
diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.ts
index dcfed9e1559..62b1af865b8 100644
--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts
+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts
@@ -188,6 +188,7 @@ export const DOCUMENTATION_PATHS = {
UI_PRIMITIVES_LAYOUT_RESIZE_HANDLE: '/ui/primitives/layout/resize-handle',
UI_PRIMITIVES_LAYOUT_TEXT_DIRECTION_PROVIDER:
'/ui/primitives/layout/text-direction-provider',
+ UI_PRIMITIVES_NAVIGATION_BREADCRUMB: '/ui/primitives/navigation/breadcrumb',
UI_PRIMITIVES_NAVIGATION_LIST_ITEM: '/ui/primitives/navigation/list-item',
UI_PRIMITIVES_NAVIGATION_TABS: '/ui/primitives/navigation/tabs',
UI_PRIMITIVES_OVERVIEW: '/ui/primitives/overview',
diff --git a/packages/twenty-ui/docs/breadcrumbPropDescriptions.ts b/packages/twenty-ui/docs/breadcrumbPropDescriptions.ts
new file mode 100644
index 00000000000..4486c2de07e
--- /dev/null
+++ b/packages/twenty-ui/docs/breadcrumbPropDescriptions.ts
@@ -0,0 +1,10 @@
+import { type ComponentProps } from 'react';
+
+import { type Breadcrumb } from '../src/primitives/navigation/Breadcrumb/Breadcrumb';
+
+export const BREADCRUMB_PROP_DESCRIPTIONS = {
+ links:
+ 'Ordered trail items. Each item accepts `children`, `href`, `render`, and `title`. The final item represents the current page.',
+ render:
+ 'Caller-supplied root element or renderer. Preserve the navigation landmark and forward the supplied props and ref.',
+} satisfies Partial<Record<keyof ComponentProps<typeof Breadcrumb>, string>>;
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index fd7b5555ddf..2a8199dbb36 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -25,6 +25,7 @@ import { COMPONENT_STORYBOOK_LAYOUT_PROP_DESCRIPTIONS } from './componentStorybo
import { COLLAPSIBLE_PROP_DESCRIPTIONS } from './collapsiblePropDescriptions';
import { AVATAR_PROP_DESCRIPTIONS } from './avatarPropDescriptions';
import { BANNER_PROP_DESCRIPTIONS } from './bannerPropDescriptions';
+import { BREADCRUMB_PROP_DESCRIPTIONS } from './breadcrumbPropDescriptions';
import { BUTTON_GROUP_PROP_DESCRIPTIONS } from './buttonGroupPropDescriptions';
import { BUTTON_PROP_DESCRIPTIONS } from './buttonPropDescriptions';
import { CARD_CONTENT_PROP_DESCRIPTIONS } from './cardContentPropDescriptions';
@@ -272,6 +273,13 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/primitives/input',
slug: 'input/switch',
},
+ {
+ name: 'Breadcrumb',
+ source: 'primitives/navigation/Breadcrumb/Breadcrumb.tsx',
+ entryPoint: 'twenty-ui/primitives/navigation',
+ slug: 'navigation/breadcrumb',
+ propDescriptions: BREADCRUMB_PROP_DESCRIPTIONS,
+ },
{
name: 'ListItem',
source: 'primitives/navigation/ListItem/ListItem.tsx',
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index f8c6e2d39db..e361ad8b7dd 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -3,6 +3,7 @@
"AlertDialog",
"Avatar",
"Banner",
+ "Breadcrumb",
"Button",
"ButtonGroup",
"Card",
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index fd5138551b0..6f265e60512 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -753,10 +753,13 @@
"primitives/navigation": {
"reExports": [],
"values": {
+ "Breadcrumb": "primitives/navigation/Breadcrumb/Breadcrumb",
"ListItem": "primitives/navigation/ListItem/ListItem",
"Tabs": "primitives/navigation/Tabs/Tabs"
},
"types": {
+ "BreadcrumbItem": "primitives/navigation/Breadcrumb/types/BreadcrumbItem",
+ "BreadcrumbProps": "primitives/navigation/Breadcrumb/types/BreadcrumbProps",
"ListItemColor": "primitives/navigation/ListItem/types/ListItemColor",
"ListItemDescriptionPlacement": "primitives/navigation/ListItem/types/ListItemDescriptionPlacement",
"ListItemIndicator": "primitives/navigation/ListItem/types/ListItemIndicator",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index a82d57a66ed..a9965684e46 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -3047,6 +3047,27 @@
}
]
},
+ {
+ "name": "Breadcrumb",
+ "entryPoint": "twenty-ui/primitives/navigation",
+ "slug": "navigation/breadcrumb",
+ "props": [
+ {
+ "name": "links",
+ "type": "BreadcrumbItem[]",
+ "required": true,
+ "defaultValue": null,
+ "description": "Ordered trail items. Each item accepts `children`, `href`, `render`, and `title`. The final item represents the current page."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Caller-supplied root element or renderer. Preserve the navigation landmark and forward the supplied props and ref."
+ }
+ ]
+ },
{
"name": "ListItem",
"entryPoint": "twenty-ui/primitives/navigation",
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.module.scss b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.module.scss
new file mode 100644
index 00000000000..12f40d15504
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.module.scss
@@ -0,0 +1,58 @@
+.root {
+ align-items: center;
+ block-size: var(--t-spacing-8);
+ color: var(--t-font-color-tertiary);
+ display: flex;
+ font-family: var(--t-font-family);
+ font-size: var(--t-font-size-md);
+ max-inline-size: 100%;
+ min-inline-size: 0;
+ overflow: hidden;
+}
+
+.list {
+ align-items: center;
+ display: flex;
+ gap: var(--t-spacing-1);
+ list-style: none;
+ margin: 0;
+ max-inline-size: 100%;
+ min-inline-size: 0;
+ padding: 0;
+}
+
+.item {
+ align-items: center;
+ display: flex;
+ flex: 0 0 auto;
+ gap: var(--t-spacing-1);
+ min-inline-size: 0;
+
+ &:last-child {
+ flex: 0 1 auto;
+ }
+}
+
+.content {
+ color: var(--t-font-color-primary);
+ display: block;
+ min-inline-size: 0;
+ overflow: hidden;
+ text-decoration: none;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+
+ &[data-linked] {
+ color: inherit;
+ }
+
+ @include focus-ring;
+
+ &:focus-visible {
+ outline-offset: -2px;
+ }
+}
+
+.separator {
+ flex: 0 0 var(--t-spacing-2);
+}
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.module.scss.d.ts b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.module.scss.d.ts
new file mode 100644
index 00000000000..cbf758dc1a0
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.module.scss.d.ts
@@ -0,0 +1,8 @@
+declare const classNames: {
+ readonly root: 'root';
+ readonly list: 'list';
+ readonly item: 'item';
+ readonly content: 'content';
+ readonly separator: 'separator';
+};
+export default classNames;
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.tsx b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.tsx
new file mode 100644
index 00000000000..3441c079a0d
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/Breadcrumb.tsx
@@ -0,0 +1,44 @@
+import { useRender } from '@base-ui/react/use-render';
+import { clsx } from 'clsx';
+
+import { BreadcrumbItemContent } from './internal/BreadcrumbItemContent';
+import { type BreadcrumbProps } from './types/BreadcrumbProps';
+
+import styles from './Breadcrumb.module.scss';
+
+export const Breadcrumb = ({
+ links,
+ className,
+ render,
+ ref,
+ 'aria-label': ariaLabel = 'Breadcrumb',
+ ...props
+}: BreadcrumbProps) => {
+ return useRender({
+ defaultTagName: 'nav',
+ render,
+ ref,
+ props: {
+ ...props,
+ 'aria-label': ariaLabel,
+ className: clsx(styles.root, className),
+ children: (
+ <ol className={styles.list}>
+ {links.map((link, index) => (
+ <li className={styles.item} key={index}>
+ {index > 0 && (
+ <span className={styles.separator} aria-hidden="true">
+ /
+ </span>
+ )}
+ <BreadcrumbItemContent
+ {...link}
+ current={index === links.length - 1}
+ />
+ </li>
+ ))}
+ </ol>
+ ),
+ },
+ });
+};
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/__stories__/Breadcrumb.stories.tsx b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/__stories__/Breadcrumb.stories.tsx
new file mode 100644
index 00000000000..be15162f73f
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/__stories__/Breadcrumb.stories.tsx
@@ -0,0 +1,172 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { type MouseEvent } from 'react';
+import { expect, fn, userEvent, within } from 'storybook/test';
+
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+
+import { Breadcrumb } from '../Breadcrumb';
+
+const LONG_CURRENT_LABEL =
+ 'A company name that needs more room than the page header';
+
+const meta: Meta<typeof Breadcrumb> = {
+ title: 'Primitives/Navigation/Breadcrumb',
+ component: Breadcrumb,
+ decorators: [ComponentDecorator],
+ parameters: {
+ container: { width: 350 },
+ a11y: A11Y_DEFER_COLOR_CONTRAST,
+ },
+ args: {
+ links: [
+ { children: 'Objects', href: '/objects' },
+ { children: 'Companies', href: '/companies' },
+ { children: 'New' },
+ ],
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof Breadcrumb>;
+
+export const Default: Story = {};
+
+export const Truncation: Story = {
+ args: {
+ links: [
+ { children: 'Objects', href: '/objects' },
+ { children: 'Companies', href: '/companies' },
+ { children: LONG_CURRENT_LABEL },
+ ],
+ },
+};
+
+export const RichContent: Story = {
+ args: {
+ links: [
+ { children: 'Settings', href: '/settings' },
+ {
+ children: <Text render={<span />}>Data model</Text>,
+ title: 'Data model',
+ },
+ ],
+ },
+};
+
+export const LinkedCurrentItem: Story = {
+ args: {
+ links: [
+ { children: 'Objects', href: '/objects' },
+ { children: 'Companies', href: '/companies' },
+ ],
+ },
+};
+
+export const Rtl: Story = { args: { dir: 'rtl' } };
+
+export const Dark: Story = { globals: { colorScheme: 'dark' } };
+
+export const Semantics: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const navigation = canvas.getByRole('navigation', { name: 'Breadcrumb' });
+
+ await expect(within(navigation).getAllByRole('listitem')).toHaveLength(3);
+ await expect(within(navigation).getAllByRole('link')).toHaveLength(2);
+ await expect(canvas.getByText('New')).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ );
+ await expect(
+ canvas.getByRole('link', { name: 'Objects' }),
+ ).not.toHaveAttribute('aria-current');
+
+ for (const separator of canvas.getAllByText('/')) {
+ await expect(separator).toHaveAttribute('aria-hidden', 'true');
+ }
+ },
+};
+
+export const LinkActivation: Story = {
+ args: {
+ ...LinkedCurrentItem.args,
+ onClick: fn((event: MouseEvent<HTMLElement>) => event.preventDefault()),
+ links: [
+ { children: 'Objects', href: '/objects' },
+ {
+ children: 'Companies',
+ href: '/companies',
+ render: (
+ <a href="/companies" data-composed="true">
+ Companies
+ </a>
+ ),
+ },
+ ],
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const objects = canvas.getByRole('link', { name: 'Objects' });
+ const companies = canvas.getByRole('link', { name: 'Companies' });
+
+ await userEvent.tab();
+ await expect(objects).toHaveFocus();
+ await expect(getComputedStyle(objects).outlineStyle).toBe('solid');
+ await expect(getComputedStyle(objects).outlineOffset).toBe('-2px');
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onClick).toHaveBeenCalledTimes(1);
+ await userEvent.tab();
+ await expect(companies).toHaveFocus();
+ await expect(companies).toHaveAttribute('href', '/companies');
+ await expect(companies).toHaveAttribute('data-composed', 'true');
+ await expect(companies).toHaveAttribute('aria-current', 'page');
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onClick).toHaveBeenCalledTimes(2);
+ await userEvent.click(objects);
+ await expect(args.onClick).toHaveBeenCalledTimes(3);
+ },
+};
+
+export const TruncationBehavior: Story = {
+ ...Truncation,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const current = canvas.getByText(LONG_CURRENT_LABEL);
+ const objects = canvas.getByRole('link', { name: 'Objects' });
+ const companies = canvas.getByRole('link', { name: 'Companies' });
+
+ await expect(current.scrollWidth).toBeGreaterThan(current.clientWidth);
+ await expect(getComputedStyle(current).textOverflow).toBe('ellipsis');
+ await expect(current).toHaveAttribute('title', LONG_CURRENT_LABEL);
+ await expect(objects.scrollWidth).toBe(objects.clientWidth);
+ await expect(companies.scrollWidth).toBe(companies.clientWidth);
+ await expect(current.getBoundingClientRect().right).toBeLessThanOrEqual(
+ canvas.getByRole('navigation').getBoundingClientRect().right + 1,
+ );
+ },
+};
+
+export const SingleItem: Story = {
+ args: { links: [{ children: 'Settings' }] },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(canvas.getByText('Settings')).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ );
+ await expect(canvas.queryByRole('link')).not.toBeInTheDocument();
+ await expect(canvas.queryByText('/')).not.toBeInTheDocument();
+ },
+};
+
+export const Empty: Story = {
+ args: { links: [] },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(canvas.getByRole('list')).toBeEmptyDOMElement();
+ await expect(canvas.queryByRole('link')).not.toBeInTheDocument();
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/__tests__/Breadcrumb.test.tsx b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/__tests__/Breadcrumb.test.tsx
new file mode 100644
index 00000000000..df288be84b8
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/__tests__/Breadcrumb.test.tsx
@@ -0,0 +1,11 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+
+import { Breadcrumb } from '../Breadcrumb';
+import styles from '../Breadcrumb.module.scss';
+
+runComponentConformance({
+ name: 'Breadcrumb',
+ element: <Breadcrumb links={[{ children: 'Workspace' }]} />,
+ ownClassName: styles.root,
+ refInstanceOf: HTMLElement,
+});
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/internal/BreadcrumbItemContent.tsx b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/internal/BreadcrumbItemContent.tsx
new file mode 100644
index 00000000000..e991cb5984e
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/internal/BreadcrumbItemContent.tsx
@@ -0,0 +1,32 @@
+import { useRender } from '@base-ui/react/use-render';
+import { isString } from '@sniptt/guards';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import styles from '../Breadcrumb.module.scss';
+import { type BreadcrumbItem } from '../types/BreadcrumbItem';
+
+type BreadcrumbItemContentProps = BreadcrumbItem & {
+ current: boolean;
+};
+
+export const BreadcrumbItemContent = ({
+ children,
+ href,
+ render,
+ title,
+ current,
+}: BreadcrumbItemContentProps) => {
+ return useRender({
+ defaultTagName: isDefined(href) ? 'a' : 'span',
+ render,
+ props: {
+ children,
+ href,
+ title: title ?? (isString(children) ? children : undefined),
+ 'aria-current': current ? 'page' : undefined,
+ 'data-linked': isDefined(href) || undefined,
+ className: styles.content,
+ },
+ });
+};
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/types/BreadcrumbItem.ts b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/types/BreadcrumbItem.ts
new file mode 100644
index 00000000000..81df00b8a4a
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/types/BreadcrumbItem.ts
@@ -0,0 +1,6 @@
+import { type useRender } from '@base-ui/react/use-render';
+
+export type BreadcrumbItem = Pick<
+ useRender.ComponentProps<'a'>,
+ 'children' | 'href' | 'render' | 'title'
+>;
diff --git a/packages/twenty-ui/src/primitives/navigation/Breadcrumb/types/BreadcrumbProps.ts b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/types/BreadcrumbProps.ts
new file mode 100644
index 00000000000..75ef83d3d2a
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/Breadcrumb/types/BreadcrumbProps.ts
@@ -0,0 +1,10 @@
+import { type useRender } from '@base-ui/react/use-render';
+
+import { type BreadcrumbItem } from './BreadcrumbItem';
+
+export type BreadcrumbProps = Omit<
+ useRender.ComponentProps<'nav'>,
+ 'children'
+> & {
+ links: BreadcrumbItem[];
+};
diff --git a/packages/twenty-ui/src/primitives/navigation/index.ts b/packages/twenty-ui/src/primitives/navigation/index.ts
index 05dcf0a10e4..6df8c92487b 100644
--- a/packages/twenty-ui/src/primitives/navigation/index.ts
+++ b/packages/twenty-ui/src/primitives/navigation/index.ts
@@ -7,6 +7,9 @@
* |___/
*/
+export { Breadcrumb } from './Breadcrumb/Breadcrumb';
+export type { BreadcrumbItem } from './Breadcrumb/types/BreadcrumbItem';
+export type { BreadcrumbProps } from './Breadcrumb/types/BreadcrumbProps';
export { ListItem } from './ListItem/ListItem';
export type { ListItemColor } from './ListItem/types/ListItemColor';
export type { ListItemDescriptionPlacement } from './ListItem/types/ListItemDescriptionPlacement';