Skip to content

The open alternative to Salesforce, designed for AI.

Replace responsive hooks with native media queries (#26532)

Raphaël Bosid50c1e0ee6b4
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 edcdf436a00..96f54b65828 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -7,6 +7,7 @@ import { createListItemSandboxFailureTest } from '@/__stories__/twenty-ui-galler
import { pickerListItemsTest } from '@/__stories__/twenty-ui-gallery/utils/pickerListItemsTest';
import { iconButtonElevatedTest } from '@/__stories__/twenty-ui-gallery/utils/iconButtonElevatedTest';
import { buttonControlsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonControlsTest';
+import { responsiveHooksTest } from '@/__stories__/twenty-ui-gallery/utils/responsiveHooksTest';
import { dialogTest } from '@/__stories__/twenty-ui-gallery/utils/dialogTest';
import { dropdownSandboxFailureTest } from '@/__stories__/twenty-ui-gallery/utils/dropdownSandboxFailureTest';
import { type Meta } from '@storybook/react-vite';
@@ -451,6 +452,18 @@ export const ButtonControlsPreact: Story = createGalleryStory({
play: buttonControlsTest,
});
+export const ResponsiveHooksReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-responsive-hooks',
+ runtime: 'react',
+ play: responsiveHooksTest,
+});
+
+export const ResponsiveHooksPreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-responsive-hooks',
+ runtime: 'preact',
+ play: responsiveHooksTest,
+});
+
export const AvatarControlsReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-avatar-controls',
runtime: 'react',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
index 6666cea2a11..71c227e819d 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
@@ -25,6 +25,7 @@ error and can allow additional known errors without requiring them to occur.
| `twenty-ui-alert-dialog` | AlertDialog |
| `twenty-ui-switch` | Switch (interaction coverage in addition to the original input gallery) |
| `twenty-ui-tooltip` | Tooltip (convenience and compound APIs) |
+| `twenty-ui-responsive-hooks` | useIsMobile, useIsTouchDevice, Button hotkeys |
The focused fixtures import public twenty-ui entry points and use
`TwentyUiGalleryCard` for the light theme, mount marker, and `twenty-ui/style.css`.
@@ -52,6 +53,7 @@ No stories are skipped or marked as expected-to-fail by the runner.
| Menu, Select | Opening fails on viewport data and/or missing `nativeEvent.pointerType`. |
| Switch | Activation attempts to construct an unavailable `PointerEvent`. |
| Tooltip | `TooltipReact` opens on hover but remains open after Escape because the SDK does not forward handlers added by `React.cloneElement`. `TooltipPreact` throws on hover because the sandbox lacks `Element.closest`. |
+| Responsive hooks | The sandbox has no `window.matchMedia`, so `useIsMobile` and `useIsTouchDevice` return `false` whatever the host viewport or input. The fixture asserts that fallback and must assert host-derived values once a media-query bridge lands. |
The tooltip stories assert these known failures and must be updated to assert
successful interactions when compatibility is fixed. The surfaces gallery checks
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-responsive-hooks.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-responsive-hooks.front-component.tsx
new file mode 100644
index 00000000000..608161ca7c2
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-responsive-hooks.front-component.tsx
@@ -0,0 +1,33 @@
+import { useState } from 'react';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import { Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+import { useIsMobile, useIsTouchDevice } from 'twenty-ui/utilities';
+import 'twenty-ui/style.css';
+
+const ResponsiveHooks = () => {
+ const isMobile = useIsMobile();
+ const isTouchDevice = useIsTouchDevice();
+ const [activations, setActivations] = useState(0);
+
+ return (
+ <>
+ <Text>Mobile layout: {String(isMobile)}</Text>
+ <Text>Touch input: {String(isTouchDevice)}</Text>
+ <Button hotkeys={['S']} onClick={() => setActivations(activations + 1)}>
+ Save record
+ </Button>
+ <Button onClick={() => setActivations(activations + 1)}>
+ {isTouchDevice ? 'Tap action' : 'Pointer action'}
+ </Button>
+ <Text>Activations: {activations}</Text>
+ </>
+ );
+};
+
+export default defineFrontComponent({
+ universalIdentifier: 'f1cdb7cb-79db-421c-bfb6-9f7c20f03ad1',
+ name: 'twenty-ui-responsive-hooks',
+ description: 'Responsive hooks without a sandbox media-query bridge',
+ component: ResponsiveHooks,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/responsiveHooksTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/responsiveHooksTest.ts
new file mode 100644
index 00000000000..693cfd5636d
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/responsiveHooksTest.ts
@@ -0,0 +1,20 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const responsiveHooksTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+ args,
+}) => {
+ const canvas = within(canvasElement);
+ await expect(
+ await canvas.findByText('Mobile layout: false', {}, { timeout: 10000 }),
+ ).toBeVisible();
+ await expect(canvas.getByText('Touch input: false')).toBeVisible();
+ const save = canvas.getByRole('button', { name: 'Save record' });
+ await expect(within(save).getByText('S')).toBeVisible();
+ await userEvent.click(save);
+ await userEvent.click(canvas.getByRole('button', { name: 'Pointer action' }));
+ await waitFor(() => expect(canvas.getByText('Activations: 2')).toBeVisible());
+ await expect(args.onError).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front/package.json b/packages/twenty-front/package.json
index db0d28004e3..36ebc6129f9 100644
--- a/packages/twenty-front/package.json
+++ b/packages/twenty-front/package.json
@@ -134,7 +134,6 @@
"react-markdown": "^10.1.0",
"react-phone-number-input": "patch:react-phone-number-input@npm%3A3.4.5#../../.yarn/patches/react-phone-number-input-npm-3.4.5-dc2895c306.patch",
"react-qr-code": "^2.0.18",
- "react-responsive": "^9.0.2",
"react-router-dom": "^7.18.4",
"react-textarea-autosize": "^8.4.1",
"remark-gfm": "^4.0.1",
diff --git a/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx b/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx
index 091dc9a6c2c..47a186c67e3 100644
--- a/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx
+++ b/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx
@@ -4,7 +4,7 @@ import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
import { SKELETON_LOADER_HEIGHT_SIZES } from '@/activities/components/SkeletonLoader';
import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/layout/resizable-panel/constants/NavigationDrawerConstraints';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { MainNavigationDrawerItemsSkeletonLoader } from '~/loading/components/MainNavigationDrawerItemsSkeletonLoader';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx b/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx
index ab11d08355c..f85ee585197 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx
@@ -29,7 +29,7 @@ import { useIsAiChatComposerCentered } from '@/ai/hooks/useIsAiChatComposerCente
import { useHasReachedAiChatCreditsCap } from '@/ai/hooks/useHasReachedAiChatCreditsCap';
import { agentChatPendingQuestionComponentSelector } from '@/ai/states/selectors/agentChatPendingQuestionComponentSelector';
import { aiModelsState } from '@/client-config/states/aiModelsState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomComponentSelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentSelectorValue';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadItemMenu.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadItemMenu.test.tsx
index 814b20ebd0b..e5f3faec843 100644
--- a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadItemMenu.test.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadItemMenu.test.tsx
@@ -30,7 +30,8 @@ jest.mock('@/navigation/hooks/useIsNavigationDrawerContentExpanded', () => ({
useIsNavigationDrawerContentExpanded: () => true,
}));
-jest.mock('@/ui/utilities/responsive/hooks/useIsMobile', () => ({
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
useIsMobile: () => false,
}));
diff --git a/packages/twenty-front/src/modules/ai/hooks/useShouldShowAiChatEmptyState.ts b/packages/twenty-front/src/modules/ai/hooks/useShouldShowAiChatEmptyState.ts
index 75469ced5cb..a32c893a6e9 100644
--- a/packages/twenty-front/src/modules/ai/hooks/useShouldShowAiChatEmptyState.ts
+++ b/packages/twenty-front/src/modules/ai/hooks/useShouldShowAiChatEmptyState.ts
@@ -7,7 +7,7 @@ import { agentChatIsStreamingComponentFamilyState } from '@/ai/states/agentChatI
import { agentChatThreadsLoadingState } from '@/ai/states/agentChatThreadsLoadingState';
import { agentChatHasMessageComponentSelector } from '@/ai/states/selectors/agentChatHasMessageComponentSelector';
import { currentAiChatThreadState } from '@/ai/states/currentAiChatThreadState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
import { useAtomComponentSelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentSelectorValue';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
diff --git a/packages/twenty-front/src/modules/command-menu-item/display/components/__stories__/SidePanelCommandMenuItemDisplayPage.stories.tsx b/packages/twenty-front/src/modules/command-menu-item/display/components/__stories__/SidePanelCommandMenuItemDisplayPage.stories.tsx
index b96dae672ef..1c9a58d6e72 100644
--- a/packages/twenty-front/src/modules/command-menu-item/display/components/__stories__/SidePanelCommandMenuItemDisplayPage.stories.tsx
+++ b/packages/twenty-front/src/modules/command-menu-item/display/components/__stories__/SidePanelCommandMenuItemDisplayPage.stories.tsx
@@ -6,8 +6,9 @@ import {
} from '@storybook/react-vite';
import { Provider as JotaiProvider } from 'jotai';
import { HttpResponse, graphql } from 'msw';
-import { Context as ResponsiveContext } from 'react-responsive';
import { MemoryRouter } from 'react-router-dom';
+import { overrideMediaQueryMatches } from 'twenty-ui/testing';
+import { MOBILE_MEDIA_QUERY } from 'twenty-ui/utilities';
import { expect, fn, spyOn, userEvent, waitFor, within } from 'storybook/test';
import { currentUserWorkspaceState } from '@/auth/states/currentUserWorkspaceState';
@@ -170,7 +171,6 @@ type CreateDecoratorParams = {
isNavigationDrawerExpanded?: boolean;
isInPreviewMode?: boolean;
pathname?: string;
- viewportWidth?: number;
colorScheme?: ColorScheme;
permissionFlags?: PermissionFlagType[];
};
@@ -183,7 +183,6 @@ const createDecorator = ({
isNavigationDrawerExpanded = true,
isInPreviewMode = false,
pathname = '/objects/companies',
- viewportWidth = 1280,
colorScheme = 'System',
permissionFlags,
}: CreateDecoratorParams): Decorator => {
@@ -233,29 +232,27 @@ const createDecorator = ({
return (
<JotaiProvider store={jotaiStore}>
- <ResponsiveContext.Provider value={{ width: viewportWidth }}>
- <MemoryRouter initialEntries={[pathname]}>
- <CommandMenuComponentInstanceContext.Provider
- value={{ instanceId: 'story-command-menu' }}
+ <MemoryRouter initialEntries={[pathname]}>
+ <CommandMenuComponentInstanceContext.Provider
+ value={{ instanceId: 'story-command-menu' }}
+ >
+ <CommandMenuContext.Provider
+ value={{
+ displayType: 'listItem',
+ containerType: CommandMenuItemContainerType.CommandMenuList,
+ commandMenuItems,
+ commandMenuContextApi,
+ isInPreviewMode,
+ }}
>
- <CommandMenuContext.Provider
- value={{
- displayType: 'listItem',
- containerType: CommandMenuItemContainerType.CommandMenuList,
- commandMenuItems,
- commandMenuContextApi,
- isInPreviewMode,
- }}
- >
- <BaseThemeProvider>
- <ToastStoryContainer>
- <Story />
- </ToastStoryContainer>
- </BaseThemeProvider>
- </CommandMenuContext.Provider>
- </CommandMenuComponentInstanceContext.Provider>
- </MemoryRouter>
- </ResponsiveContext.Provider>
+ <BaseThemeProvider>
+ <ToastStoryContainer>
+ <Story />
+ </ToastStoryContainer>
+ </BaseThemeProvider>
+ </CommandMenuContext.Provider>
+ </CommandMenuComponentInstanceContext.Provider>
+ </MemoryRouter>
</JotaiProvider>
);
};
@@ -264,6 +261,10 @@ const createDecorator = ({
const meta: Meta<typeof SidePanelCommandMenuItemDisplayPage> = {
title: 'Modules/CommandMenu/SidePanelCommandMenuItemDisplayPage',
component: SidePanelCommandMenuItemDisplayPage,
+ beforeEach: ({ parameters }) =>
+ overrideMediaQueryMatches({
+ [MOBILE_MEDIA_QUERY]: parameters.isMobile === true,
+ }),
decorators: [
ContextStoreDecorator,
ObjectMetadataItemsDecorator,
@@ -545,11 +546,11 @@ export const SearchSidebarWithCaseAndWhitespace: Story = {
};
export const HiddenOnMobile: Story = {
+ parameters: { isMobile: true },
decorators: [
createDecorator({
commandMenuItems: [OTHER_ITEM],
sidePanelSearch: 'sidebar',
- viewportWidth: 375,
}),
],
play: SearchWithoutMatchingItemsAndWithoutFallback.play,
diff --git a/packages/twenty-front/src/modules/command-menu-item/display/hooks/useCommandMenuAppActions.ts b/packages/twenty-front/src/modules/command-menu-item/display/hooks/useCommandMenuAppActions.ts
index 0314a80e8ae..325c1886bed 100644
--- a/packages/twenty-front/src/modules/command-menu-item/display/hooks/useCommandMenuAppActions.ts
+++ b/packages/twenty-front/src/modules/command-menu-item/display/hooks/useCommandMenuAppActions.ts
@@ -4,7 +4,7 @@ import { useNavigationDrawerTogglePresentation } from '@/navigation/hooks/useNav
import { useToggleNavigationDrawer } from '@/navigation/hooks/useToggleNavigationDrawer';
import { sidePanelSearchState } from '@/side-panel/states/sidePanelSearchState';
import { useColorScheme } from '@/ui/theme/hooks/useColorScheme';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { type ColorScheme } from '@/workspace-member/types/WorkspaceMember';
import { useLingui } from '@lingui/react/macro';
diff --git a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
index 519cb96f51b..dcdb7e9825a 100644
--- a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
@@ -5,7 +5,7 @@ import { MainNavigationDrawerModeSwitcher } from '@/navigation/components/MainNa
import { SettingsNavigationDrawerContent } from '@/navigation/components/SettingsNavigationDrawerContent';
import { NavigationDrawer } from '@/ui/navigation/navigation-drawer/components/NavigationDrawer';
import { NavigationDrawerFixedContent } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerFixedContent';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
export type AppNavigationDrawerProps = {
className?: string;
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx
index 64f5c068127..730fd487a27 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx
@@ -13,7 +13,7 @@ import { useSwitchNavigationDrawerMode } from '@/navigation/hooks/useSwitchNavig
import { TooltipDelay } from '@/ui/layout/tooltip/constants/TooltipDelay';
import { NAVIGATION_DRAWER_TABS } from '@/ui/navigation/states/navigationDrawerTabs';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
// Expanded, the row is sized off the page card header beside it so the rules
// read as one line across both columns.
diff --git a/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx b/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx
index 2a3269678ad..b9af9b188e0 100644
--- a/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx
@@ -4,7 +4,7 @@ import { MemoryRouter } from 'react-router-dom';
import { currentMobileNavigationDrawerState } from '@/navigation/states/currentMobileNavigationDrawerState';
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { IconsProviderDecorator } from '~/testing/decorators/IconsProviderDecorator';
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
diff --git a/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx b/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx
index 3a2d2e7c175..efc91eeec0a 100644
--- a/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx
@@ -1,11 +1,14 @@
import { AppNavigationDrawer } from '@/navigation/components/AppNavigationDrawer';
import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { render, screen } from '@testing-library/react';
import { type ReactNode } from 'react';
jest.mock('@/navigation/hooks/useIsSettingsDrawer');
-jest.mock('@/ui/utilities/responsive/hooks/useIsMobile');
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
+ useIsMobile: jest.fn(),
+}));
jest.mock('@/navigation/components/MainNavigationDrawerContent', () => ({
MainNavigationDrawerContent: () => <div>Main content</div>,
diff --git a/packages/twenty-front/src/modules/navigation/components/__tests__/MainNavigationDrawerModeSwitcher.test.tsx b/packages/twenty-front/src/modules/navigation/components/__tests__/MainNavigationDrawerModeSwitcher.test.tsx
index e825acff851..9a4dbac7ac9 100644
--- a/packages/twenty-front/src/modules/navigation/components/__tests__/MainNavigationDrawerModeSwitcher.test.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/__tests__/MainNavigationDrawerModeSwitcher.test.tsx
@@ -18,7 +18,8 @@ jest.mock('@/navigation/hooks/useIsNavigationDrawerContentExpanded');
jest.mock('@/navigation/hooks/useNavigationDrawerModes');
jest.mock('@/navigation/hooks/useSwitchNavigationDrawerMode');
-jest.mock('@/ui/utilities/responsive/hooks/useIsMobile', () => ({
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
useIsMobile: () => false,
}));
diff --git a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useDefaultHomePagePath.test.ts b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useDefaultHomePagePath.test.ts
index 5d405f5f0b4..6b5f11c899d 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useDefaultHomePagePath.test.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useDefaultHomePagePath.test.ts
@@ -28,7 +28,8 @@ import { setTestViewsInMetadataStore } from '~/testing/utils/setTestViewsInMetad
let mockIsMobile = false;
let mockIsInitialObjectViewEnabled = false;
-jest.mock('@/ui/utilities/responsive/hooks/useIsMobile', () => ({
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
useIsMobile: () => mockIsMobile,
}));
diff --git a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx
index 14326541470..ddfe94ebf3a 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx
+++ b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx
@@ -8,7 +8,7 @@ import { navigationDrawerActiveTabState } from '@/ui/navigation/states/navigatio
import { navigationDrawerExpandedMemorizedState } from '@/ui/navigation/states/navigationDrawerExpandedMemorizedState';
import { NAVIGATION_DRAWER_TABS } from '@/ui/navigation/states/navigationDrawerTabs';
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { act, renderHook } from '@testing-library/react';
import { createStore, Provider } from 'jotai';
import { type ReactNode } from 'react';
@@ -17,7 +17,10 @@ import { MemoryRouter, useLocation } from 'react-router-dom';
jest.mock('@/ai/hooks/useReturnFromExpandedAiChat');
jest.mock('@/ai/hooks/useSwitchToNewAiChat');
jest.mock('@/navigation/hooks/useDefaultHomePagePath');
-jest.mock('@/ui/utilities/responsive/hooks/useIsMobile');
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
+ useIsMobile: jest.fn(),
+}));
jest.mock('@/side-panel/hooks/useSidePanelMenu', () => ({
useSidePanelMenu: () => ({ closeSidePanelMenu: jest.fn() }),
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useDefaultHomePagePath.ts b/packages/twenty-front/src/modules/navigation/hooks/useDefaultHomePagePath.ts
index a63045a095e..1f3642f09ba 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/useDefaultHomePagePath.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/useDefaultHomePagePath.ts
@@ -9,7 +9,7 @@ import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilte
import { objectMetadataItemsSelector } from '@/object-metadata/states/objectMetadataItemsSelector';
import { filterReadableActiveObjectMetadataItems } from '@/object-metadata/utils/filterReadableActiveObjectMetadataItems';
import { useObjectPermissions } from '@/object-record/hooks/useObjectPermissions';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue';
import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilyStateValue';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useIsNavigationDrawerContentExpanded.ts b/packages/twenty-front/src/modules/navigation/hooks/useIsNavigationDrawerContentExpanded.ts
index 9f8fc2959ff..cbbed5958f5 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/useIsNavigationDrawerContentExpanded.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/useIsNavigationDrawerContentExpanded.ts
@@ -1,5 +1,5 @@
import { useNavigationDrawerExpanded } from '@/navigation/hooks/useNavigationDrawerExpanded';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
// Whether the navigation content renders its full width rather than the icon
// rail. Mobile has no rail: the content is either a full-width drawer or the
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useIsSettingsDrawer.ts b/packages/twenty-front/src/modules/navigation/hooks/useIsSettingsDrawer.ts
index b4aee03f669..181fde862e6 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/useIsSettingsDrawer.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/useIsSettingsDrawer.ts
@@ -1,7 +1,7 @@
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
import { currentMobileNavigationDrawerState } from '@/navigation/states/currentMobileNavigationDrawerState';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
export const useIsSettingsDrawer = () => {
const isMobile = useIsMobile();
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useOpenSettings.ts b/packages/twenty-front/src/modules/navigation/hooks/useOpenSettings.ts
index c2755b9294f..17022036086 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/useOpenSettings.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/useOpenSettings.ts
@@ -8,7 +8,7 @@ import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMe
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { useCallback } from 'react';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useLocation } from 'react-router-dom';
export const useOpenSettingsMenu = () => {
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts b/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts
index 1f5cbdf5389..4dda249d2cd 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts
@@ -1,4 +1,4 @@
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useLocation, useNavigate } from 'react-router-dom';
import { SettingsPath } from 'twenty-shared/types';
diff --git a/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailMorphRelationSection.tsx b/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailMorphRelationSection.tsx
index 4b5cbef274f..cb17b98f651 100644
--- a/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailMorphRelationSection.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailMorphRelationSection.tsx
@@ -11,7 +11,7 @@ import {
import { type FieldMorphRelationMetadata } from '@/object-record/record-field/ui/types/FieldMetadata';
import { getRecordFieldCardRelationPickerDropdownId } from '@/object-record/record-show/utils/getRecordFieldCardRelationPickerDropdownId';
import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { RecordDetailMorphRelationSectionDropdown } from '@/object-record/record-field-list/record-detail-section/relation/components/RecordDetailMorphRelationSectionDropdown';
diff --git a/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailRelationSection.tsx b/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailRelationSection.tsx
index e31ab585ba3..f00133facdd 100644
--- a/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailRelationSection.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field-list/record-detail-section/relation/components/RecordDetailRelationSection.tsx
@@ -19,7 +19,7 @@ import { recordStoreFamilySelector } from '@/object-record/record-store/states/s
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
import { type ObjectRecord } from '@/object-record/types/ObjectRecord';
import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { indexViewIdFromObjectMetadataItemFamilySelector } from '@/views/states/selectors/indexViewIdFromObjectMetadataItemFamilySelector';
diff --git a/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useResolveOpenRecordIn.test.tsx b/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useResolveOpenRecordIn.test.tsx
index b5239ee18c5..68eb492fd60 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useResolveOpenRecordIn.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useResolveOpenRecordIn.test.tsx
@@ -7,8 +7,9 @@ import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import { act } from 'react';
import { ObjectOpenRecordIn, OpenRecordIn } from 'twenty-shared/types';
-jest.mock('react-responsive', () => ({
- useMediaQuery: jest.fn().mockReturnValue(false),
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
+ useIsMobile: jest.fn().mockReturnValue(false),
}));
jest.mock(
diff --git a/packages/twenty-front/src/modules/object-record/record-show/components/ObjectRecordShowPageBreadcrumb.tsx b/packages/twenty-front/src/modules/object-record/record-show/components/ObjectRecordShowPageBreadcrumb.tsx
index 904447487ed..ac61e1db618 100644
--- a/packages/twenty-front/src/modules/object-record/record-show/components/ObjectRecordShowPageBreadcrumb.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-show/components/ObjectRecordShowPageBreadcrumb.tsx
@@ -13,7 +13,7 @@ import { getRecordShowPageBreadcrumbPaginationLabel } from '@/object-record/reco
import { recordStoreIdentifierFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreIdentifierFamilySelector';
import { RecordTitleCell } from '@/object-record/record-title-cell/components/RecordTitleCell';
import { RecordTitleCellContainerType } from '@/object-record/record-title-cell/types/RecordTitleCellContainerType';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { styled } from '@linaria/react';
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveHoverToCurrentCell.test.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveHoverToCurrentCell.test.tsx
index ae01c708519..6852acffce2 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveHoverToCurrentCell.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveHoverToCurrentCell.test.tsx
@@ -1,6 +1,7 @@
import { renderHook } from '@testing-library/react';
import { Provider as JotaiProvider, useAtomValue } from 'jotai';
import { act } from 'react';
+import { useIsTouchDevice } from 'twenty-ui/utilities';
import { RecordTableComponentInstance } from '@/object-record/record-table/components/RecordTableComponentInstance';
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
@@ -15,17 +16,13 @@ import {
import { useMoveHoverToCurrentCell } from '@/object-record/record-table/record-table-cell/hooks/useMoveHoverToCurrentCell';
import { recordTableHoverPositionComponentState } from '@/object-record/record-table/states/recordTableHoverPositionComponentState';
-jest.mock('react-responsive', () => ({
- useMediaQuery: jest.fn(),
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
+ useIsTouchDevice: jest.fn(),
}));
-const mockUseMediaQuery = jest.requireMock('react-responsive')
- .useMediaQuery as jest.Mock;
-
const mockIsTouchDevice = (isTouchDevice: boolean) => {
- mockUseMediaQuery.mockImplementation(({ query }: { query: string }) =>
- query.includes('hover: none') ? isTouchDevice : false,
- );
+ jest.mocked(useIsTouchDevice).mockReturnValue(isTouchDevice);
};
const createWrapper =
diff --git a/packages/twenty-front/src/modules/onboarding/components/WelcomeOverlay/WelcomeOverlay.tsx b/packages/twenty-front/src/modules/onboarding/components/WelcomeOverlay/WelcomeOverlay.tsx
index 6818ea5121c..5e78ec500c7 100644
--- a/packages/twenty-front/src/modules/onboarding/components/WelcomeOverlay/WelcomeOverlay.tsx
+++ b/packages/twenty-front/src/modules/onboarding/components/WelcomeOverlay/WelcomeOverlay.tsx
@@ -15,7 +15,7 @@ import { isWelcomeAnimationLeavingState } from '@/onboarding/states/isWelcomeAni
import { isWelcomeAnimationVisibleState } from '@/onboarding/states/isWelcomeAnimationVisibleState';
import { welcomeTitleFlightState } from '@/onboarding/states/welcomeTitleFlightState';
import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
const StyledOverlay = styled.div`
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx
index ba21bf0116f..cd4b6610d0a 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx
@@ -20,7 +20,7 @@ import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTab
import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/contexts/TabListComponentInstanceContext';
import { type TabListProps } from '@/ui/layout/tab-list/types/TabListProps';
import { NodeDimension } from '@/ui/utilities/dimensions/components/NodeDimension';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';
import { useClickOutsideListener } from '@/ui/utilities/pointer-event/hooks/useClickOutsideListener';
import { useAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentState';
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListEffect.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListEffect.tsx
index 8c4eeea4a46..b56dc44aca4 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListEffect.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabListEffect.tsx
@@ -3,7 +3,7 @@ import { getPageLayoutTabListInitialActiveTabId } from '@/page-layout/utils/getP
import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';
import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';
import { type TabListProps } from '@/ui/layout/tab-list/types/TabListProps';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { useStore } from 'jotai';
import { useEffect } from 'react';
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx
index b37e887e3f9..65e6a7f70d2 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx
@@ -23,7 +23,7 @@ import { useLayoutRenderingContext } from '@/ui/layout/contexts/LayoutRenderingC
import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';
import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';
import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { styled } from '@linaria/react';
diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsx
index 90b2d99f253..f0d0f5b2070 100644
--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsx
@@ -58,7 +58,8 @@ jest.mock('@/ui/utilities/pointer-event/hooks/useClickOutsideListener', () => ({
useClickOutsideListener: () => ({ toggleClickOutside: jest.fn() }),
}));
-jest.mock('@/ui/utilities/responsive/hooks/useIsMobile', () => ({
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
useIsMobile: () => false,
}));
diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx
index 4cc7ac2d98e..a720d386629 100644
--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx
@@ -122,7 +122,8 @@ jest.mock('@/ui/utilities/state/jotai/hooks/useSetAtomComponentState', () => ({
useSetAtomComponentState: () => mockSetPrerenderedTabIds,
}));
-jest.mock('@/ui/utilities/responsive/hooks/useIsMobile', () => ({
+jest.mock('twenty-ui/utilities', () => ({
+ ...jest.requireActual('twenty-ui/utilities'),
useIsMobile: () => false,
}));
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardHeaderHoverReveal.tsx b/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardHeaderHoverReveal.tsx
index 5b1b3cd3bca..a72762f6015 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardHeaderHoverReveal.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/widget-card/components/WidgetCardHeaderHoverReveal.tsx
@@ -1,7 +1,7 @@
import { widgetCardHoveredComponentFamilyState } from '@/page-layout/widgets/states/widgetCardHoveredComponentFamilyState';
import { WidgetComponentInstanceContext } from '@/page-layout/widgets/states/contexts/WidgetComponentInstanceContext';
import { useComponentInstanceStateContext } from '@/ui/utilities/state/component-state/hooks/useComponentInstanceStateContext';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsDatabaseEventsForm.tsx b/packages/twenty-front/src/modules/settings/components/SettingsDatabaseEventsForm.tsx
index 2a2df08af90..a60fee0cfb7 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsDatabaseEventsForm.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsDatabaseEventsForm.tsx
@@ -1,6 +1,6 @@
import { WebhookEntitySelect } from '@/settings/developers/components/WebhookEntitySelect';
import { Select } from '@/ui/input/components/Select';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsPageContainer.tsx b/packages/twenty-front/src/modules/settings/components/SettingsPageContainer.tsx
index 78994c9f5c0..50d9d8e865e 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsPageContainer.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsPageContainer.tsx
@@ -1,4 +1,4 @@
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';
import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx
index 59d2c6dca93..505c6d6e98d 100644
--- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx
@@ -14,7 +14,7 @@ import { useFieldMetadataItemById } from '@/object-metadata/hooks/useFieldMetada
import { IconPicker } from '@/ui/input/components/IconPicker';
import { Select } from '@/ui/input/components/Select';
import { SettingsTextInput } from '@/ui/input/components/SettingsTextInput';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { isDefined } from 'twenty-shared/utils';
diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationFormCard.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationFormCard.tsx
index 874e442a5a4..5b10fa66fa3 100644
--- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationFormCard.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationFormCard.tsx
@@ -11,7 +11,7 @@ import { SettingsDataModelFieldRelationJunctionForm } from '@/settings/data-mode
import { SettingsDataModelFieldRelationPreviewContent } from '@/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationPreviewContent';
import { SettingsDataModelRelationPreviewImage } from '@/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationPreviewImageCard';
import { SettingsDataModelRelationFieldPreviewSubWidget } from '@/settings/data-model/fields/preview/components/SettingsDataModelRelationFieldPreviewSubWidget';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { isDefined } from 'twenty-shared/utils';
import {
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/__stories__/SidePanelPageLayoutTabSettingsContent.stories.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/__stories__/SidePanelPageLayoutTabSettingsContent.stories.tsx
index 683d992605e..e2496a9538e 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/__stories__/SidePanelPageLayoutTabSettingsContent.stories.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/__stories__/SidePanelPageLayoutTabSettingsContent.stories.tsx
@@ -20,7 +20,7 @@ import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTab
import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/contexts/TabListComponentInstanceContext';
import { focusStackState } from '@/ui/utilities/focus/states/focusStackState';
import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
diff --git a/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
index 1975c0a537f..a4224e2edab 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
@@ -9,7 +9,7 @@ import { SIDE_PANEL_SEARCH_RECORD_PREVIEW_WIDTH } from '@/side-panel/pages/searc
import { useSidePanelSearchRecordPreviewItem } from '@/side-panel/pages/search/hooks/useSidePanelSearchRecordPreviewItem';
import { useSidePanelSearchRecords } from '@/side-panel/pages/search/hooks/useSidePanelSearchRecords';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { css } from '@linaria/core';
import { useLingui } from '@lingui/react/macro';
import { useMemo, useRef } from 'react';
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx
index 90db28b1b0b..952a34264c4 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx
@@ -9,7 +9,7 @@ import { AppNavigationDrawer } from '@/navigation/components/AppNavigationDrawer
import { MobileNavigationBar } from '@/navigation/components/MobileNavigationBar';
import { PageDragDropProvider } from '@/navigation-menu-item/display/dnd/providers/PageDragDropProvider';
import { useShowFullscreen } from '@/ui/layout/fullscreen/hooks/useShowFullscreen';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { Outlet } from 'react-router-dom';
import { themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx
index 842c1aea8ce..8c819b55dee 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx
@@ -4,7 +4,7 @@ import { useCommandMenuHotKeys } from '@/command-menu/hooks/useCommandMenuHotKey
import { RouteContextStoreProvider } from '@/context-store/components/RouteContextStoreProvider';
import { SidePanelForDesktop } from '@/side-panel/components/SidePanelForDesktop';
import { SidePanelPathUrlSyncEffect } from '@/side-panel/routing/components/SidePanelPathUrlSyncEffect';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { Outlet } from 'react-router-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 94d6254eadf..5df826d4775 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
@@ -8,7 +8,7 @@ import {
} from '@/ui/navigation/bread-crumb/components/Breadcrumb';
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 '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
import { createPortal } from 'react-dom';
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx
index 13bd8035c8c..0342a3c98c7 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/PageHeader.tsx
@@ -9,7 +9,7 @@ import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
import { useNavigationDrawerExpanded } from '@/navigation/hooks/useNavigationDrawerExpanded';
import { PAGE_ACTION_CONTAINER_CLICK_OUTSIDE_ID } from '@/ui/layout/page/constants/PageActionContainerClickOutsideId';
import { PAGE_BAR_MIN_HEIGHT } from '@/ui/layout/page/constants/PageBarMinHeight';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { AnimatePresence } from 'framer-motion';
import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components';
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/ShowPageContainer.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/ShowPageContainer.tsx
index 3d078e0a254..40f5688b6fe 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/ShowPageContainer.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/ShowPageContainer.tsx
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';
import { type CSSProperties, type ReactNode } from 'react';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
import { themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabList.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabList.tsx
index 3570a7b5423..e09c5a99764 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabList.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabList.tsx
@@ -8,7 +8,7 @@ import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/con
import { type TabListProps } from '@/ui/layout/tab-list/types/TabListProps';
import { NodeDimension } from '@/ui/utilities/dimensions/components/NodeDimension';
import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentState';
import { styled } from '@linaria/react';
import { useCallback, useMemo } from 'react';
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 7e8c8df88b4..9c5b1d4c5ea 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,5 +1,5 @@
import { MobileBreadcrumb } from '@/ui/navigation/bread-crumb/components/MobileBreadcrumb';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { Fragment, type ReactNode } from 'react';
import { Link } from 'react-router-dom';
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
index df06dae3ef4..69b74d65488 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
@@ -7,7 +7,7 @@ import { MultiWorkspaceDropdownWorkspacesListComponents } from '@/ui/navigation/
import { MULTI_WORKSPACE_DROPDOWN_ID } from '@/ui/navigation/navigation-drawer/constants/MultiWorkspaceDropdownId';
import { MULTI_WORKSPACE_DROPDOWN_MOBILE_BOUNDARY_PADDING } from '@/ui/navigation/navigation-drawer/constants/MultiWorkspaceDropdownMobileBoundaryPadding';
import { multiWorkspaceDropdownState } from '@/ui/navigation/navigation-drawer/states/multiWorkspaceDropdownState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
import { useMemo } from 'react';
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsx
index 42ce76b74b0..46f380bd6e2 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsx
@@ -15,7 +15,7 @@ import {
NAVIGATION_DRAWER_WIDTH_VAR,
navigationDrawerWidthState,
} from '@/ui/navigation/states/navigationDrawerWidthState';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx
index ac1477d9199..031a55eb3d0 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx
@@ -2,7 +2,7 @@ import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer';
import { useNavigationDrawerTogglePresentation } from '@/navigation/hooks/useNavigationDrawerTogglePresentation';
import { useToggleNavigationDrawer } from '@/navigation/hooks/useToggleNavigationDrawer';
import { TooltipDelay } from '@/ui/layout/tooltip/constants/TooltipDelay';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { LightIconButton } from 'twenty-ui/components';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx
index 9f9d4463ae7..bbce9c9b371 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx
@@ -10,7 +10,7 @@ import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme';
import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { useOpenRecordsSearchPageInSidePanel } from '@/side-panel/hooks/useOpenRecordsSearchPageInSidePanel';
import { MultiWorkspaceDropdownButton } from '@/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { NavigationDrawerCollapseButton } from './NavigationDrawerCollapseButton';
const StyledContainer = styled.div`
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
index e8070c80963..f38db6694d2 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
@@ -9,7 +9,7 @@ import { type NavigationDrawerSubItemState } from '@/ui/navigation/navigation-dr
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
import { useMouseDownNavigation } from '@/ui/navigation/utils/hooks/useMouseDownNavigation';
import { type TriggerEventType } from '@/ui/navigation/utils/types/trigger-event.type';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx
index 55418fe8ef4..572d3f7c751 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx
@@ -1,5 +1,5 @@
import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { motion } from 'framer-motion';
import React from 'react';
diff --git a/packages/twenty-front/src/modules/ui/navigation/step-bar/components/Step.tsx b/packages/twenty-front/src/modules/ui/navigation/step-bar/components/Step.tsx
index c3dda29bcc4..f9bf74a2293 100644
--- a/packages/twenty-front/src/modules/ui/navigation/step-bar/components/Step.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/step-bar/components/Step.tsx
@@ -2,7 +2,7 @@ import { styled } from '@linaria/react';
import { motion } from 'framer-motion';
import { AnimatedCheckmark } from '@/ui/navigation/step-bar/components/internal/AnimatedCheckmark/AnimatedCheckmark';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { MOBILE_VIEWPORT, useTheme, themeCssVariables } from 'twenty-ui/theme';
const StyledContainer = styled.div<{ isLast: boolean }>`
diff --git a/packages/twenty-front/src/modules/ui/navigation/step-bar/components/StepBar.tsx b/packages/twenty-front/src/modules/ui/navigation/step-bar/components/StepBar.tsx
index d11506f56ce..a76f265c4e3 100644
--- a/packages/twenty-front/src/modules/ui/navigation/step-bar/components/StepBar.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/step-bar/components/StepBar.tsx
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';
import React from 'react';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { MOBILE_VIEWPORT } from 'twenty-ui/theme';
import { Step, type StepProps } from './Step';
diff --git a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx
index ae92faf2b50..04dab630b7e 100644
--- a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx
+++ b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx
@@ -22,7 +22,7 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer';
import type { SuggestionMenuProps } from '@/ui/suggestion/types/SuggestionMenuProps';
import { getSuggestionMenuItemAnchorId } from '@/ui/suggestion/utils/getSuggestionMenuItemAnchorId';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
import { themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/modules/ui/theme/hooks/useSystemColorScheme.ts b/packages/twenty-front/src/modules/ui/theme/hooks/useSystemColorScheme.ts
index 26420a8e711..4de27d8d4ca 100644
--- a/packages/twenty-front/src/modules/ui/theme/hooks/useSystemColorScheme.ts
+++ b/packages/twenty-front/src/modules/ui/theme/hooks/useSystemColorScheme.ts
@@ -1,35 +1,6 @@
-import { useEffect, useMemo, useState } from 'react';
+import { useMediaQuery } from 'twenty-ui/utilities';
import { type ColorScheme } from '@/workspace-member/types/WorkspaceMember';
-import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
-export const useSystemColorScheme = (): ColorScheme => {
- const mediaQuery = useMemo(
- () => window.matchMedia('(prefers-color-scheme: dark)'),
- [],
- );
-
- const [preferredColorScheme, setPreferredColorScheme] = useState<ColorScheme>(
- isUndefinedOrNull(window.matchMedia) || !mediaQuery.matches
- ? 'Light'
- : 'Dark',
- );
-
- useEffect(() => {
- if (isUndefinedOrNull(window.matchMedia)) {
- return;
- }
-
- const handleChange = (event: MediaQueryListEvent): void => {
- setPreferredColorScheme(event.matches ? 'Dark' : 'Light');
- };
-
- mediaQuery.addEventListener('change', handleChange);
-
- return () => {
- mediaQuery.removeEventListener('change', handleChange);
- };
- }, [mediaQuery]);
-
- return preferredColorScheme;
-};
+export const useSystemColorScheme = (): ColorScheme =>
+ useMediaQuery('(prefers-color-scheme: dark)') ? 'Dark' : 'Light';
diff --git a/packages/twenty-front/src/modules/ui/utilities/responsive/hooks/__tests__/useIsMobile.test.tsx b/packages/twenty-front/src/modules/ui/utilities/responsive/hooks/__tests__/useIsMobile.test.tsx
deleted file mode 100644
index 2bc6772baac..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/responsive/hooks/__tests__/useIsMobile.test.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { renderHook } from '@testing-library/react';
-
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
-
-describe('useIsMobile', () => {
- it('should trigger the callback when clicking outside the specified refs', () => {
- const { result } = renderHook(() => useIsMobile());
-
- expect(result.current).toBe(false);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/responsive/hooks/useIsMobile.ts b/packages/twenty-front/src/modules/ui/utilities/responsive/hooks/useIsMobile.ts
deleted file mode 100644
index 6b51d75e2e4..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/responsive/hooks/useIsMobile.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { useMediaQuery } from 'react-responsive';
-import { MOBILE_VIEWPORT } from 'twenty-ui/theme';
-
-export const useIsMobile = () =>
- useMediaQuery({ query: `(max-width: ${MOBILE_VIEWPORT}px)` });
diff --git a/packages/twenty-front/src/pages/mobile-home/MobileHomePage.tsx b/packages/twenty-front/src/pages/mobile-home/MobileHomePage.tsx
index d7dd3bdb08f..5122a547b5b 100644
--- a/packages/twenty-front/src/pages/mobile-home/MobileHomePage.tsx
+++ b/packages/twenty-front/src/pages/mobile-home/MobileHomePage.tsx
@@ -5,7 +5,7 @@ import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFla
import { MultiWorkspaceDropdownButton } from '@/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton';
import { NavigationDrawerFixedContent } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerFixedContent';
import { NavigationDrawerScrollableContent } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerScrollableContent';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { Navigate } from 'react-router-dom';
import { themeCssVariables } from 'twenty-ui/theme';
diff --git a/packages/twenty-front/src/pages/settings/api-webhooks/SettingsApiWebhooks.tsx b/packages/twenty-front/src/pages/settings/api-webhooks/SettingsApiWebhooks.tsx
index a1c66e13a51..a3f561fa28f 100644
--- a/packages/twenty-front/src/pages/settings/api-webhooks/SettingsApiWebhooks.tsx
+++ b/packages/twenty-front/src/pages/settings/api-webhooks/SettingsApiWebhooks.tsx
@@ -13,7 +13,7 @@ import McpCoverDark from '@/settings/mcp-and-apis/assets/mcp-cover-dark.png';
import McpCoverLight from '@/settings/mcp-and-apis/assets/mcp-cover-light.png';
import { PlaygroundSetupForm } from '@/settings/mcp-and-apis/components/PlaygroundSetupForm';
import { SettingsMcpSetup } from '@/settings/mcp-and-apis/components/SettingsMcpSetup';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useIsMobile } from 'twenty-ui/utilities';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { SettingsPath } from 'twenty-shared/types';
diff --git a/packages/twenty-ui/CHANGELOG.md b/packages/twenty-ui/CHANGELOG.md
index 2d77e71a9d4..dcf50fb43ff 100644
--- a/packages/twenty-ui/CHANGELOG.md
+++ b/packages/twenty-ui/CHANGELOG.md
@@ -4,6 +4,7 @@
### Breaking Changes
+- Removed the unused `useScreenSize` export. `useIsMobile` and `useIsTouchDevice` remain available from `twenty-ui/utilities` and now subscribe to native `matchMedia` changes. Both return `false` during server rendering, initial hydration, and when `matchMedia` is unavailable. `react-responsive` context overrides no longer affect these hooks; use `overrideMediaQueryMatches` from `twenty-ui/testing` to force a result in stories.
- All theme exports now live in `twenty-ui/theme`. The `twenty-ui/theme-constants` entry, `ThemeContext`, `ThemeScopeContext`, and `ThemeContextType` are removed. Read values with `useTheme`, `useThemeColorScheme`, and `useThemeContainer`; configure them with `ThemeProvider`. The top-level theme stylesheet URLs and token values are unchanged.
- Worker apps retain provider-less CSS-variable values. Apps that supplied a context value can pass `THEME_LIGHT` or `THEME_DARK` directly through `ThemeProvider`'s `theme` prop. The in-repo call-recorder, companion, fireflies, Granola, Slack, and Teams apps import `twenty-ui/theme-constants` and must move those imports to `twenty-ui/theme` when they upgrade; call-recorder and Granola must also replace their `ThemeContext` providers with the `theme` prop. Their current pinned UI versions expose neither, so each app needs a coordinated source and dependency upgrade.
- `twenty-ui/testing` no longer exports `RouterDecorator`, `ComponentWithRouterDecorator`, `RouteParams`, `isRouteParams`, or `computeLocation`. Use application-owned router decorators when routing is needed, or `ComponentDecorator` for router-free stories. React Router is no longer a peer dependency.
@@ -15,3 +16,7 @@
- `SegmentedControl` is a radio group. Use `aria-label` or `aria-labelledby` (one is required), `value` or `defaultValue`, and `onValueChange(value, eventDetails)` in place of `ariaLabel`, `value`, and `onChange(value)`. Options take `startIcon` and `'aria-label'` in place of `Icon` and `ariaLabel`. `role` and `width` are removed: use `Tabs` for tab lists and `className` or `style` to size the control. Arrow keys select the next option, Enter no longer selects, and choosing the selected option again no longer calls `onValueChange`.
Keep `twenty-ui`, `twenty-sdk`, and `twenty-client-sdk` versions aligned when upgrading Twenty apps.
+
+### Added
+
+- `twenty-ui/utilities` exports `useMediaQuery`, `MOBILE_MEDIA_QUERY`, and `TOUCH_DEVICE_MEDIA_QUERY`. `twenty-ui/testing` exports `overrideMediaQueryMatches`.
diff --git a/packages/twenty-ui/README.md b/packages/twenty-ui/README.md
index 4227e4fc68c..251029ffcac 100644
--- a/packages/twenty-ui/README.md
+++ b/packages/twenty-ui/README.md
@@ -72,7 +72,7 @@ import { Button } from 'twenty-ui/primitives/input';
| `twenty-ui/primitives/navigation` | Action links, list items, and tabs |
| `twenty-ui/primitives/surfaces` | Cards, dialogs, menus, popovers, and tooltips |
| `twenty-ui/primitives/typography` | Text and headings |
-| `twenty-ui/testing` | Storybook and test decorators |
+| `twenty-ui/testing` | Storybook and test decorators and helpers |
| `twenty-ui/theme` | Design tokens, `ThemeProvider`, and `useTheme` |
| `twenty-ui/utilities` | Hooks and shared utilities |
@@ -82,6 +82,12 @@ import { Button } from 'twenty-ui/primitives/input';
- `twenty-ui/theme-light.css` and `twenty-ui/theme-dark.css` define the design-token CSS variables for each color scheme.
- `ThemeProvider` exposes the active theme through `useTheme()` and applies the `light` / `dark` class. Pass `applyToRoot={false}` with `overrides` to scope a theme to a subtree instead of the document root.
+# Responsive hooks
+
+- `useIsMobile` matches `MOBILE_MEDIA_QUERY` (up to and including `MOBILE_VIEWPORT`). `useIsTouchDevice` matches `TOUCH_DEVICE_MEDIA_QUERY` and is independent of width: branch interaction behavior on it, and layout on `useIsMobile`.
+- `useMediaQuery(query)` subscribes to native `matchMedia` changes and shares one `MediaQueryList` per query. It returns `false` during server rendering and the first hydration render, and wherever `window.matchMedia` is unavailable, including the front component sandbox.
+- To force a result in a story, return `overrideMediaQueryMatches({ [MOBILE_MEDIA_QUERY]: true })` from `beforeEach`; the returned cleanup restores the native `matchMedia`.
+
# Development
Shared component sources live in `src/components/{data-display,feedback,input,layout,navigation,typography}`, with the optional editor in `src/components/code-editor`. Keep each component's types, stories, tests, and private parts beside its implementation. The generated `components` barrel provides the public imports.
diff --git a/packages/twenty-ui/package.json b/packages/twenty-ui/package.json
index 70aba2d9152..d37a3fd93e2 100644
--- a/packages/twenty-ui/package.json
+++ b/packages/twenty-ui/package.json
@@ -77,7 +77,6 @@
"@sniptt/guards": "^0.2.0",
"@tabler/icons-react": "^3.31.0",
"clsx": "^2.1.1",
- "react-responsive": "^9.0.2",
"type-fest": "^4.10.1",
"zod": "^4.1.11"
},
diff --git a/packages/twenty-ui/src/testing/index.ts b/packages/twenty-ui/src/testing/index.ts
index 9c6a2c2e89e..99b050435b7 100644
--- a/packages/twenty-ui/src/testing/index.ts
+++ b/packages/twenty-ui/src/testing/index.ts
@@ -17,3 +17,4 @@ export { CatalogDecorator } from './decorators/CatalogDecorator';
export { ComponentDecorator } from './decorators/ComponentDecorator';
export { AVATAR_URL_MOCK } from './mocks/avatarUrlMock';
export type { CatalogStory } from './types/CatalogStory';
+export { overrideMediaQueryMatches } from './utils/overrideMediaQueryMatches';
diff --git a/packages/twenty-ui/src/testing/utils/__tests__/overrideMediaQueryMatches.test.ts b/packages/twenty-ui/src/testing/utils/__tests__/overrideMediaQueryMatches.test.ts
new file mode 100644
index 00000000000..5a537dc0149
--- /dev/null
+++ b/packages/twenty-ui/src/testing/utils/__tests__/overrideMediaQueryMatches.test.ts
@@ -0,0 +1,59 @@
+import { cleanup, renderHook } from '@testing-library/react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { overrideMediaQueryMatches } from '@ui/testing/utils/overrideMediaQueryMatches';
+import { MOBILE_MEDIA_QUERY } from '@ui/utilities/responsive/constants/MobileMediaQuery';
+import { useIsMobile } from '@ui/utilities/responsive/hooks/useIsMobile';
+
+const createNativeMatchMedia = () =>
+ vi.fn(
+ (query: string) =>
+ ({
+ media: query,
+ matches: false,
+ }) as MediaQueryList,
+ );
+
+afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+});
+
+describe('overrideMediaQueryMatches', () => {
+ it('forces listed queries and passes other queries through', () => {
+ const nativeMatchMedia = createNativeMatchMedia();
+ vi.stubGlobal('matchMedia', nativeMatchMedia);
+
+ overrideMediaQueryMatches({ '(max-width: 768px)': true });
+
+ expect(window.matchMedia('(max-width: 768px)').matches).toBe(true);
+ expect(window.matchMedia('(prefers-color-scheme: dark)').matches).toBe(
+ false,
+ );
+ expect(nativeMatchMedia).toHaveBeenCalledTimes(2);
+ });
+
+ it('forces listed queries when the environment has no matchMedia', () => {
+ vi.stubGlobal('matchMedia', undefined);
+
+ overrideMediaQueryMatches({ [MOBILE_MEDIA_QUERY]: true });
+
+ expect(renderHook(useIsMobile).result.current).toBe(true);
+ expect(window.matchMedia('(prefers-color-scheme: dark)').matches).toBe(
+ false,
+ );
+ });
+
+ it('restores the native matchMedia on cleanup', () => {
+ const nativeMatchMedia = createNativeMatchMedia();
+ vi.stubGlobal('matchMedia', nativeMatchMedia);
+
+ const restoreMatchMedia = overrideMediaQueryMatches({
+ '(max-width: 768px)': true,
+ });
+ restoreMatchMedia();
+
+ expect(window.matchMedia).toBe(nativeMatchMedia);
+ expect(window.matchMedia('(max-width: 768px)').matches).toBe(false);
+ });
+});
diff --git a/packages/twenty-ui/src/testing/utils/overrideMediaQueryMatches.ts b/packages/twenty-ui/src/testing/utils/overrideMediaQueryMatches.ts
new file mode 100644
index 00000000000..fd80cc5c23e
--- /dev/null
+++ b/packages/twenty-ui/src/testing/utils/overrideMediaQueryMatches.ts
@@ -0,0 +1,39 @@
+import { isFunction } from '@sniptt/guards';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+const createStaticMediaQueryList = (query: string): MediaQueryList =>
+ Object.assign(new EventTarget(), {
+ media: query,
+ matches: false,
+ onchange: null,
+ addListener: () => {},
+ removeListener: () => {},
+ });
+
+export const overrideMediaQueryMatches = (
+ matchesByQuery: Partial<Record<string, boolean>>,
+) => {
+ const originalMatchMedia = window.matchMedia;
+
+ window.matchMedia = (query: string) => {
+ const mediaQueryList = isFunction(originalMatchMedia)
+ ? originalMatchMedia.call(window, query)
+ : createStaticMediaQueryList(query);
+ const overriddenMatches = matchesByQuery[query];
+
+ if (!isDefined(overriddenMatches)) {
+ return mediaQueryList;
+ }
+
+ Object.defineProperty(mediaQueryList, 'matches', {
+ value: overriddenMatches,
+ });
+
+ return mediaQueryList;
+ };
+
+ return () => {
+ window.matchMedia = originalMatchMedia;
+ };
+};
diff --git a/packages/twenty-ui/src/utilities/index.ts b/packages/twenty-ui/src/utilities/index.ts
index 9c27c9be13e..39dd833a7dc 100644
--- a/packages/twenty-ui/src/utilities/index.ts
+++ b/packages/twenty-ui/src/utilities/index.ts
@@ -17,9 +17,11 @@ export { themeColorSchema } from './color/utils/themeColorSchema';
export { getOsControlSymbol } from './device/getOsControlSymbol';
export { getOsShortcutSeparator } from './device/getOsShortcutSeparator';
export { getUserDevice } from './device/getUserDevice';
+export { MOBILE_MEDIA_QUERY } from './responsive/constants/MobileMediaQuery';
+export { TOUCH_DEVICE_MEDIA_QUERY } from './responsive/constants/TouchDeviceMediaQuery';
export { useIsMobile } from './responsive/hooks/useIsMobile';
export { useIsTouchDevice } from './responsive/hooks/useIsTouchDevice';
-export { useScreenSize } from './screen-size/hooks/useScreenSize';
+export { useMediaQuery } from './responsive/hooks/useMediaQuery';
export type { ClickOutsideAttributes } from './types/ClickOutsideAttributes';
export type { Nullable } from './types/Nullable';
export { getSafeUrl } from './utils/getSafeUrl';
diff --git a/packages/twenty-ui/src/utilities/responsive/__stories__/ResponsiveHooks.stories.tsx b/packages/twenty-ui/src/utilities/responsive/__stories__/ResponsiveHooks.stories.tsx
new file mode 100644
index 00000000000..c7607e1bf54
--- /dev/null
+++ b/packages/twenty-ui/src/utilities/responsive/__stories__/ResponsiveHooks.stories.tsx
@@ -0,0 +1,75 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, userEvent, within } from 'storybook/test';
+
+import { Button } from '@ui/primitives/input';
+import { Text } from '@ui/primitives/typography';
+import { ComponentDecorator, overrideMediaQueryMatches } from '@ui/testing';
+import { MOBILE_MEDIA_QUERY } from '../constants/MobileMediaQuery';
+import { TOUCH_DEVICE_MEDIA_QUERY } from '../constants/TouchDeviceMediaQuery';
+import { useIsMobile } from '../hooks/useIsMobile';
+import { useIsTouchDevice } from '../hooks/useIsTouchDevice';
+
+const ResponsiveControls = () => {
+ const isMobile = useIsMobile();
+ const isTouchDevice = useIsTouchDevice();
+ const [activations, setActivations] = useState(0);
+
+ return (
+ <>
+ <Text>Mobile layout: {String(isMobile)}</Text>
+ <Text>Touch input: {String(isTouchDevice)}</Text>
+ <Button hotkeys={['S']} onClick={() => setActivations(activations + 1)}>
+ Save record
+ </Button>
+ <Button onClick={() => setActivations(activations + 1)}>
+ {isTouchDevice ? 'Tap action' : 'Pointer action'}
+ </Button>
+ <Text>Activations: {activations}</Text>
+ </>
+ );
+};
+
+const meta: Meta<typeof ResponsiveControls> = {
+ title: 'UI/Utilities/Responsive Hooks',
+ component: ResponsiveControls,
+ decorators: [ComponentDecorator],
+ beforeEach: ({ parameters }) =>
+ overrideMediaQueryMatches({
+ [MOBILE_MEDIA_QUERY]: parameters.isMobile === true,
+ [TOUCH_DEVICE_MEDIA_QUERY]: parameters.isTouchDevice === true,
+ }),
+};
+
+export default meta;
+
+type Story = StoryObj<typeof ResponsiveControls>;
+
+export const DesktopPointer: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(canvas.getByText('Mobile layout: false')).toBeVisible();
+ await expect(canvas.getByText('Touch input: false')).toBeVisible();
+ const save = canvas.getByRole('button', { name: 'Save record' });
+ await expect(within(save).getByText('S')).toBeVisible();
+ await userEvent.click(save);
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Pointer action' }),
+ );
+ await expect(canvas.getByText('Activations: 2')).toBeVisible();
+ },
+};
+
+export const MobileTouch: Story = {
+ parameters: { isMobile: true, isTouchDevice: true },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(canvas.getByText('Mobile layout: true')).toBeVisible();
+ await expect(canvas.getByText('Touch input: true')).toBeVisible();
+ const save = canvas.getByRole('button', { name: 'Save record' });
+ await expect(within(save).queryByText('S')).not.toBeInTheDocument();
+ await userEvent.click(save);
+ await userEvent.click(canvas.getByRole('button', { name: 'Tap action' }));
+ await expect(canvas.getByText('Activations: 2')).toBeVisible();
+ },
+};
diff --git a/packages/twenty-ui/src/utilities/responsive/constants/MobileMediaQuery.ts b/packages/twenty-ui/src/utilities/responsive/constants/MobileMediaQuery.ts
new file mode 100644
index 00000000000..c2bd4f6214e
--- /dev/null
+++ b/packages/twenty-ui/src/utilities/responsive/constants/MobileMediaQuery.ts
@@ -0,0 +1,3 @@
+import { MOBILE_VIEWPORT } from '@ui/theme';
+
+export const MOBILE_MEDIA_QUERY = `(max-width: ${MOBILE_VIEWPORT}px)`;
diff --git a/packages/twenty-ui/src/utilities/responsive/constants/TouchDeviceMediaQuery.ts b/packages/twenty-ui/src/utilities/responsive/constants/TouchDeviceMediaQuery.ts
new file mode 100644
index 00000000000..b14fd0b023e
--- /dev/null
+++ b/packages/twenty-ui/src/utilities/responsive/constants/TouchDeviceMediaQuery.ts
@@ -0,0 +1 @@
+export const TOUCH_DEVICE_MEDIA_QUERY = '(hover: none) and (pointer: coarse)';
diff --git a/packages/twenty-ui/src/utilities/responsive/hooks/__tests__/isMobile.test.tsx b/packages/twenty-ui/src/utilities/responsive/hooks/__tests__/isMobile.test.tsx
deleted file mode 100644
index 708733136b6..00000000000
--- a/packages/twenty-ui/src/utilities/responsive/hooks/__tests__/isMobile.test.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { renderHook } from '@testing-library/react';
-import { useIsMobile } from '@ui/utilities/responsive/hooks/useIsMobile';
-
-describe('useIsMobile', () => {
- it('should trigger the callback when clicking outside the specified refs', () => {
- const { result } = renderHook(() => useIsMobile());
-
- expect(result.current).toBe(false);
- });
-});
diff --git a/packages/twenty-ui/src/utilities/responsive/hooks/__tests__/useMediaQuery.test.tsx b/packages/twenty-ui/src/utilities/responsive/hooks/__tests__/useMediaQuery.test.tsx
new file mode 100644
index 00000000000..378b896ae5d
--- /dev/null
+++ b/packages/twenty-ui/src/utilities/responsive/hooks/__tests__/useMediaQuery.test.tsx
@@ -0,0 +1,211 @@
+import { act, cleanup, renderHook } from '@testing-library/react';
+import { StrictMode } from 'react';
+import { hydrateRoot } from 'react-dom/client';
+import { renderToString } from 'react-dom/server';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { MOBILE_MEDIA_QUERY } from '@ui/utilities/responsive/constants/MobileMediaQuery';
+import { TOUCH_DEVICE_MEDIA_QUERY } from '@ui/utilities/responsive/constants/TouchDeviceMediaQuery';
+import { useIsMobile } from '@ui/utilities/responsive/hooks/useIsMobile';
+import { useIsTouchDevice } from '@ui/utilities/responsive/hooks/useIsTouchDevice';
+import { useMediaQuery } from '../useMediaQuery';
+
+const createMediaQueryList = ({
+ media,
+ matches = false,
+}: {
+ media: string;
+ matches?: boolean;
+}) => {
+ const target = new EventTarget();
+ const mediaQueryList = {
+ media,
+ matches,
+ onchange: null,
+ addListener: vi.fn(),
+ removeListener: vi.fn(),
+ addEventListener: vi.fn(target.addEventListener.bind(target)),
+ removeEventListener: vi.fn(target.removeEventListener.bind(target)),
+ dispatchEvent: target.dispatchEvent.bind(target),
+ } satisfies MediaQueryList;
+
+ return {
+ mediaQueryList,
+ setMatches: (nextMatches: boolean) => {
+ mediaQueryList.matches = nextMatches;
+ target.dispatchEvent(new Event('change'));
+ },
+ };
+};
+
+const useResponsiveState = () => ({
+ isMobile: useIsMobile(),
+ isTouchDevice: useIsTouchDevice(),
+});
+
+afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+});
+
+describe('responsive media queries', () => {
+ it('reads initial matches and updates viewport and input capability independently', () => {
+ const mobile = createMediaQueryList({
+ media: MOBILE_MEDIA_QUERY,
+ matches: true,
+ });
+ const touch = createMediaQueryList({ media: TOUCH_DEVICE_MEDIA_QUERY });
+ vi.stubGlobal(
+ 'matchMedia',
+ vi.fn((query: string) =>
+ query === MOBILE_MEDIA_QUERY
+ ? mobile.mediaQueryList
+ : touch.mediaQueryList,
+ ),
+ );
+ const { result } = renderHook(useResponsiveState);
+
+ expect(window.matchMedia).toHaveBeenCalledWith(MOBILE_MEDIA_QUERY);
+ expect(window.matchMedia).toHaveBeenCalledWith(TOUCH_DEVICE_MEDIA_QUERY);
+ expect(result.current).toEqual({ isMobile: true, isTouchDevice: false });
+ act(() => {
+ mobile.setMatches(false);
+ touch.setMatches(true);
+ });
+ expect(result.current).toEqual({ isMobile: false, isTouchDevice: true });
+ act(() => touch.setMatches(false));
+ expect(result.current).toEqual({ isMobile: false, isTouchDevice: false });
+ });
+
+ it('replaces the subscription when the query changes and cleans up on unmount', () => {
+ const mobile = createMediaQueryList({ media: MOBILE_MEDIA_QUERY });
+ const touch = createMediaQueryList({
+ media: TOUCH_DEVICE_MEDIA_QUERY,
+ matches: true,
+ });
+ vi.stubGlobal('matchMedia', (query: string) =>
+ query === MOBILE_MEDIA_QUERY
+ ? mobile.mediaQueryList
+ : touch.mediaQueryList,
+ );
+ const { result, rerender, unmount } = renderHook(
+ (query: string) => useMediaQuery(query),
+ { initialProps: MOBILE_MEDIA_QUERY, wrapper: StrictMode },
+ );
+ expect(result.current).toBe(false);
+ rerender(TOUCH_DEVICE_MEDIA_QUERY);
+ expect(result.current).toBe(true);
+ act(() => mobile.setMatches(true));
+ expect(result.current).toBe(true);
+ unmount();
+
+ for (const { mediaQueryList } of [mobile, touch]) {
+ expect(mediaQueryList.removeEventListener.mock.calls).toEqual(
+ mediaQueryList.addEventListener.mock.calls,
+ );
+ }
+ });
+
+ it('rechecks a query changed between render and subscription', () => {
+ const { mediaQueryList } = createMediaQueryList({
+ media: MOBILE_MEDIA_QUERY,
+ });
+ mediaQueryList.addEventListener.mockImplementation(() => {
+ mediaQueryList.matches = true;
+ });
+ vi.stubGlobal('matchMedia', () => mediaQueryList);
+ const { result } = renderHook(useIsMobile);
+ expect(result.current).toBe(true);
+ });
+
+ it('shares one media query list per query across mounted hooks', () => {
+ const mobile = createMediaQueryList({ media: MOBILE_MEDIA_QUERY });
+ const matchMedia = vi.fn(() => mobile.mediaQueryList);
+ vi.stubGlobal('matchMedia', matchMedia);
+ const first = renderHook(useIsMobile);
+ const second = renderHook(useIsMobile);
+
+ expect(matchMedia).toHaveBeenCalledTimes(1);
+ act(() => mobile.setMatches(true));
+ expect([first.result.current, second.result.current]).toEqual([true, true]);
+ });
+
+ it('reads a replaced matchMedia implementation instead of the cached list', () => {
+ const desktop = createMediaQueryList({ media: MOBILE_MEDIA_QUERY });
+ vi.stubGlobal('matchMedia', () => desktop.mediaQueryList);
+ const { unmount } = renderHook(useIsMobile);
+ unmount();
+
+ const mobile = createMediaQueryList({
+ media: MOBILE_MEDIA_QUERY,
+ matches: true,
+ });
+ vi.stubGlobal('matchMedia', () => mobile.mediaQueryList);
+ const { result } = renderHook(useIsMobile);
+
+ expect(result.current).toBe(true);
+ });
+
+ it('returns false without matchMedia, regardless of viewport width', () => {
+ vi.stubGlobal('matchMedia', undefined);
+ vi.stubGlobal('innerWidth', 375);
+ const { result } = renderHook(useResponsiveState);
+ expect(result.current).toEqual({ isMobile: false, isTouchDevice: false });
+ });
+
+ it('uses the server snapshot even when native queries match', () => {
+ const { mediaQueryList } = createMediaQueryList({
+ media: MOBILE_MEDIA_QUERY,
+ matches: true,
+ });
+ vi.stubGlobal('matchMedia', () => mediaQueryList);
+ const ResponsiveState = () => <output>{String(useIsMobile())}</output>;
+
+ expect(renderToString(<ResponsiveState />)).toBe('<output>false</output>');
+ expect(mediaQueryList.addEventListener).not.toHaveBeenCalled();
+ });
+
+ it('renders on the server without window and hydrates before reading client matches', async () => {
+ const snapshots: ReturnType<typeof useResponsiveState>[] = [];
+ const ResponsiveState = () => {
+ const state = useResponsiveState();
+ snapshots.push(state);
+ return <output>{JSON.stringify(state)}</output>;
+ };
+ vi.stubGlobal('window', undefined);
+ const html = renderToString(<ResponsiveState />);
+ vi.unstubAllGlobals();
+ expect(snapshots).toEqual([{ isMobile: false, isTouchDevice: false }]);
+
+ const mobile = createMediaQueryList({
+ media: MOBILE_MEDIA_QUERY,
+ matches: true,
+ });
+ const touch = createMediaQueryList({
+ media: TOUCH_DEVICE_MEDIA_QUERY,
+ matches: true,
+ });
+ vi.stubGlobal('matchMedia', (query: string) =>
+ query === MOBILE_MEDIA_QUERY
+ ? mobile.mediaQueryList
+ : touch.mediaQueryList,
+ );
+ const container = document.createElement('div');
+ container.innerHTML = html;
+ const onRecoverableError = vi.fn();
+ const root = await act(() =>
+ hydrateRoot(container, <ResponsiveState />, { onRecoverableError }),
+ );
+ expect(snapshots[1]).toEqual({ isMobile: false, isTouchDevice: false });
+ expect(container.textContent).toBe(
+ JSON.stringify({ isMobile: true, isTouchDevice: true }),
+ );
+ expect(onRecoverableError).not.toHaveBeenCalled();
+ await act(() => root.unmount());
+ for (const { mediaQueryList } of [mobile, touch]) {
+ expect(mediaQueryList.removeEventListener.mock.calls).toEqual(
+ mediaQueryList.addEventListener.mock.calls,
+ );
+ }
+ });
+});
diff --git a/packages/twenty-ui/src/utilities/responsive/hooks/useIsMobile.ts b/packages/twenty-ui/src/utilities/responsive/hooks/useIsMobile.ts
index 69458b8915e..9c763d942c4 100644
--- a/packages/twenty-ui/src/utilities/responsive/hooks/useIsMobile.ts
+++ b/packages/twenty-ui/src/utilities/responsive/hooks/useIsMobile.ts
@@ -1,5 +1,4 @@
-import { MOBILE_VIEWPORT } from '@ui/theme';
-import { useMediaQuery } from 'react-responsive';
+import { MOBILE_MEDIA_QUERY } from '@ui/utilities/responsive/constants/MobileMediaQuery';
+import { useMediaQuery } from '@ui/utilities/responsive/hooks/useMediaQuery';
-export const useIsMobile = () =>
- useMediaQuery({ query: `(max-width: ${MOBILE_VIEWPORT}px)` });
+export const useIsMobile = () => useMediaQuery(MOBILE_MEDIA_QUERY);
diff --git a/packages/twenty-ui/src/utilities/responsive/hooks/useIsTouchDevice.ts b/packages/twenty-ui/src/utilities/responsive/hooks/useIsTouchDevice.ts
index 596e3cdbd36..fca52f3479a 100644
--- a/packages/twenty-ui/src/utilities/responsive/hooks/useIsTouchDevice.ts
+++ b/packages/twenty-ui/src/utilities/responsive/hooks/useIsTouchDevice.ts
@@ -1,8 +1,8 @@
-import { useMediaQuery } from 'react-responsive';
+import { TOUCH_DEVICE_MEDIA_QUERY } from '@ui/utilities/responsive/constants/TouchDeviceMediaQuery';
+import { useMediaQuery } from '@ui/utilities/responsive/hooks/useMediaQuery';
// Viewport width tells us how much room we have to lay things out, not how the
// user points at them: a narrow window on a desktop still hovers, a tablet in
// landscape never does. Interaction behaviour must branch on this, not on
// useIsMobile.
-export const useIsTouchDevice = () =>
- useMediaQuery({ query: '(hover: none) and (pointer: coarse)' });
+export const useIsTouchDevice = () => useMediaQuery(TOUCH_DEVICE_MEDIA_QUERY);
diff --git a/packages/twenty-ui/src/utilities/responsive/hooks/useMediaQuery.ts b/packages/twenty-ui/src/utilities/responsive/hooks/useMediaQuery.ts
new file mode 100644
index 00000000000..f8b9faa9fb8
--- /dev/null
+++ b/packages/twenty-ui/src/utilities/responsive/hooks/useMediaQuery.ts
@@ -0,0 +1,11 @@
+import { useSyncExternalStore } from 'react';
+
+import { getMediaQueryStore } from '@ui/utilities/responsive/internal/getMediaQueryStore';
+
+const getServerSnapshot = () => false;
+
+export const useMediaQuery = (query: string) => {
+ const { subscribe, getSnapshot } = getMediaQueryStore(query);
+
+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
+};
diff --git a/packages/twenty-ui/src/utilities/responsive/internal/getMediaQueryStore.ts b/packages/twenty-ui/src/utilities/responsive/internal/getMediaQueryStore.ts
new file mode 100644
index 00000000000..0ddcab05756
--- /dev/null
+++ b/packages/twenty-ui/src/utilities/responsive/internal/getMediaQueryStore.ts
@@ -0,0 +1,66 @@
+import { isFunction } from '@sniptt/guards';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+type MediaQueryStore = {
+ getSnapshot: () => boolean;
+ subscribe: (onStoreChange: () => void) => () => void;
+};
+
+const UNSUPPORTED_MEDIA_QUERY_STORE: MediaQueryStore = {
+ getSnapshot: () => false,
+ subscribe: () => () => {},
+};
+
+const mediaQueryStoresByMatchMediaImplementation = new WeakMap<
+ Window['matchMedia'],
+ Map<string, MediaQueryStore>
+>();
+
+const createMediaQueryStore = (
+ mediaQueryList: MediaQueryList,
+): MediaQueryStore => ({
+ getSnapshot: () => mediaQueryList.matches,
+ subscribe: (onStoreChange) => {
+ mediaQueryList.addEventListener('change', onStoreChange);
+
+ return () => mediaQueryList.removeEventListener('change', onStoreChange);
+ },
+});
+
+const getMediaQueryStoresByQuery = (matchMedia: Window['matchMedia']) => {
+ const cachedMediaQueryStoresByQuery =
+ mediaQueryStoresByMatchMediaImplementation.get(matchMedia);
+
+ if (isDefined(cachedMediaQueryStoresByQuery)) {
+ return cachedMediaQueryStoresByQuery;
+ }
+
+ const mediaQueryStoresByQuery = new Map<string, MediaQueryStore>();
+
+ mediaQueryStoresByMatchMediaImplementation.set(
+ matchMedia,
+ mediaQueryStoresByQuery,
+ );
+
+ return mediaQueryStoresByQuery;
+};
+
+export const getMediaQueryStore = (query: string): MediaQueryStore => {
+ if (typeof window === 'undefined' || !isFunction(window.matchMedia)) {
+ return UNSUPPORTED_MEDIA_QUERY_STORE;
+ }
+
+ const mediaQueryStoresByQuery = getMediaQueryStoresByQuery(window.matchMedia);
+ const cachedMediaQueryStore = mediaQueryStoresByQuery.get(query);
+
+ if (isDefined(cachedMediaQueryStore)) {
+ return cachedMediaQueryStore;
+ }
+
+ const mediaQueryStore = createMediaQueryStore(window.matchMedia(query));
+
+ mediaQueryStoresByQuery.set(query, mediaQueryStore);
+
+ return mediaQueryStore;
+};
diff --git a/packages/twenty-ui/src/utilities/screen-size/hooks/useScreenSize.ts b/packages/twenty-ui/src/utilities/screen-size/hooks/useScreenSize.ts
deleted file mode 100644
index 2363af5dbf5..00000000000
--- a/packages/twenty-ui/src/utilities/screen-size/hooks/useScreenSize.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { useEffect, useState } from 'react';
-
-export const useScreenSize = () => {
- const [screenSize, setScreenSize] = useState({
- width: window.innerWidth,
- height: window.innerHeight,
- });
-
- useEffect(() => {
- const handleResize = () => {
- setScreenSize({
- width: window.innerWidth,
- height: window.innerHeight,
- });
- };
-
- window.addEventListener('resize', handleResize);
-
- return () => {
- window.removeEventListener('resize', handleResize);
- };
- }, []);
-
- return screenSize;
-};
diff --git a/yarn.lock b/yarn.lock
index c30106fb350..f1eced191e9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -28099,13 +28099,6 @@ __metadata:
languageName: node
linkType: hard
-"css-mediaquery@npm:^0.1.2":
- version: 0.1.2
- resolution: "css-mediaquery@npm:0.1.2"
- checksum: 10c0/b7825a78f52ce8a8198e004fcad0d7be1d3c9a0463ecd05ba31a0f2c94fb81468ad6f4d7bf715a6ca775696e7a17500c2a339b5216a6d0f789cbf78f9454d048
- languageName: node
- linkType: hard
-
"css-select@npm:^5.1.0":
version: 5.1.0
resolution: "css-select@npm:5.1.0"
@@ -34081,13 +34074,6 @@ __metadata:
languageName: node
linkType: hard
-"hyphenate-style-name@npm:^1.0.0":
- version: 1.1.0
- resolution: "hyphenate-style-name@npm:1.1.0"
- checksum: 10c0/bfe88deac2414a41a0d08811e277c8c098f23993d6a1eb17f14a0f11b54c4d42865a63d3cfe1914668eefb9a188e2de58f38b55a179a238fd1fef606893e194f
- languageName: node
- linkType: hard
-
"ical-generator@npm:^11.0.0":
version: 11.0.0
resolution: "ical-generator@npm:11.0.0"
@@ -38507,15 +38493,6 @@ __metadata:
languageName: node
linkType: hard
-"matchmediaquery@npm:^0.3.0":
- version: 0.3.1
- resolution: "matchmediaquery@npm:0.3.1"
- dependencies:
- css-mediaquery: "npm:^0.1.2"
- checksum: 10c0/19a254e0a1eb639fcc6aa7428a6e2d36cb5646a165579897e771580653e470b43d7f4a224c522700dbf1d8f19fb7c63a9719e0a6017727ade967155a2ae89fea
- languageName: node
- linkType: hard
-
"math-intrinsics@npm:1.1.0, math-intrinsics@npm:^1.1.0":
version: 1.1.0
resolution: "math-intrinsics@npm:1.1.0"
@@ -43619,7 +43596,7 @@ __metadata:
languageName: node
linkType: hard
-"prop-types@npm:15.x, prop-types@npm:^15.6.1, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1":
+"prop-types@npm:15.x, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1":
version: 15.8.1
resolution: "prop-types@npm:15.8.1"
dependencies:
@@ -44689,20 +44666,6 @@ __metadata:
languageName: node
linkType: hard
-"react-responsive@npm:^9.0.2":
- version: 9.0.2
- resolution: "react-responsive@npm:9.0.2"
- dependencies:
- hyphenate-style-name: "npm:^1.0.0"
- matchmediaquery: "npm:^0.3.0"
- prop-types: "npm:^15.6.1"
- shallow-equal: "npm:^1.2.1"
- peerDependencies:
- react: ">=16.8.0"
- checksum: 10c0/c58b30d8b8ff993edbc73f7de59a2d86d8abd6380b06a9b41667c3bdd5401e5e710fa1d0fdac21368759ab9b958e8b479a111329a06e9b0241ee08f500b37a20
- languageName: node
- linkType: hard
-
"react-router-dom@npm:^7.18.4":
version: 7.18.4
resolution: "react-router-dom@npm:7.18.4"
@@ -47148,13 +47111,6 @@ __metadata:
languageName: node
linkType: hard
-"shallow-equal@npm:^1.2.1":
- version: 1.2.1
- resolution: "shallow-equal@npm:1.2.1"
- checksum: 10c0/51e03abadd97c9ebe590547d92db9148446962a3f23a3a0fb1ba2fccab80af881eef0ff1f8ccefd3f066c0bc5a4c8ca53706194813b95c8835fa66448a843a26
- languageName: node
- linkType: hard
-
"sharp-ico@npm:0.1.5":
version: 0.1.5
resolution: "sharp-ico@npm:0.1.5"
@@ -50182,7 +50138,6 @@ __metadata:
react-markdown: "npm:^10.1.0"
react-phone-number-input: "patch:react-phone-number-input@npm%3A3.4.5#../../.yarn/patches/react-phone-number-input-npm-3.4.5-dc2895c306.patch"
react-qr-code: "npm:^2.0.18"
- react-responsive: "npm:^9.0.2"
react-router-dom: "npm:^7.18.4"
react-textarea-autosize: "npm:^8.4.1"
remark-gfm: "npm:^4.0.1"
@@ -50593,7 +50548,6 @@ __metadata:
react: "npm:^19.2.0"
react-docgen-typescript: "npm:^2.2.2"
react-dom: "npm:^19.2.0"
- react-responsive: "npm:^9.0.2"
sass: "npm:^1.83.0"
sass-embedded: "npm:^1.83.0"
size-limit: "npm:^12.1.0"