Skip to content

The open alternative to Salesforce, designed for AI.

Keep icon widths in flex layouts (#28523)

Raphaël Bosi84c56856f66a
diff --git a/packages/twenty-docs/ui/icons.mdx b/packages/twenty-docs/ui/icons.mdx
index 51f604d87f7..f1bdeb93e38 100644
--- a/packages/twenty-docs/ui/icons.mdx
+++ b/packages/twenty-docs/ui/icons.mdx
@@ -28,6 +28,8 @@ Tabler icons accept `size` (number or CSS length), `stroke` (stroke width), `col
Custom icons that do not accept accessible attributes need a wrapper with the appropriate label or `aria-hidden`. `className` and `style` are also available only where listed. Import a specific icon when possible to avoid loading the dynamic catalog.
+Exported icons keep their requested width in flex layouts, including inside buttons. Let adjacent text truncate or let the parent wrap or scroll when space is limited. Where an icon supports `className` or `style`, you can explicitly override `flex-shrink` for a layout that needs it. Illustration containers also preserve their width.
+
## Dynamic icon names
Use `IconsProvider` and `Icon` when names are chosen at runtime. The provider loads the complete icon map asynchronously; bundles built without code splitting, such as front components, include the whole map. Before loading completes, and for unknown names, `Icon` renders `Icon123`. The dynamic map differs from the named export catalog; do not assume every brand or illustration export can be resolved by name.
diff --git a/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaFieldHeader.tsx b/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaFieldHeader.tsx
index fed2e3d8e44..78a6cb271da 100644
--- a/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaFieldHeader.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaFieldHeader.tsx
@@ -56,10 +56,6 @@ const StyledTitle = styled.span`
display: flex;
gap: ${themeCssVariables.spacing[1]};
min-width: 0;
-
- & > svg {
- flex-shrink: 0;
- }
`;
const StyledName = styled.span`
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx b/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx
index 92a4c39ef84..13256c8f8c3 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx
@@ -14,7 +14,6 @@ const StyledContainer = styled.div`
padding: ${themeCssVariables.spacing[1]} 0;
svg {
- flex-shrink: 0;
margin-top: 1px;
}
`;
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutGridResizeHandle.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutGridResizeHandle.tsx
index d73349fd3d0..d8c6a916ea2 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutGridResizeHandle.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutGridResizeHandle.tsx
@@ -33,7 +33,6 @@ const StyledCornerIconWrapper = styled.div<{
& > svg {
color: transparent;
- flex-shrink: 0;
pointer-events: none;
transform: ${({ position }) => {
if (position === 'se') {
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx
index 426a971f459..a64a8be2bf2 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx
@@ -40,10 +40,6 @@ const StyledCardHeader = styled.div`
font-size: ${themeCssVariables.font.size.md};
font-weight: ${themeCssVariables.font.weight.medium};
gap: ${themeCssVariables.spacing[1]};
-
- svg {
- flex-shrink: 0;
- }
`;
const StyledStatusTag = styled.div`
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx
index ad96418626c..1e6acd6d132 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx
@@ -70,10 +70,6 @@ const StyledOptionLabelRow = styled.div`
overflow-wrap: anywhere;
`;
-const StyledSelectedIcon = styled(IconCheck)`
- flex-shrink: 0;
-`;
-
const StyledRecommended = styled.span`
color: ${themeCssVariables.font.color.light};
flex-shrink: 0;
@@ -116,9 +112,7 @@ export const SettingsAdminChatAskQuestionsQuestion = ({
return (
<StyledOptionRow key={optionIndex} isSelected={isSelected}>
<StyledOptionLabelRow>
- {isSelected && (
- <StyledSelectedIcon size={14} color={theme.color.blue} />
- )}
+ {isSelected && <IconCheck size={14} color={theme.color.blue} />}
<TextWithChatReferences text={option.label} />
{option.isRecommended === true && (
<StyledRecommended>· {t`Recommended`}</StyledRecommended>
@@ -135,7 +129,7 @@ export const SettingsAdminChatAskQuestionsQuestion = ({
{isNonEmptyString(freeText) && (
<StyledOptionRow isSelected>
<StyledOptionLabelRow>
- <StyledSelectedIcon size={14} color={theme.color.blue} />
+ <IconCheck size={14} color={theme.color.blue} />
{t`Other`}
</StyledOptionLabelRow>
<StyledOptionDescription>
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsCustomizeVideoModal.tsx b/packages/twenty-front/src/modules/settings/components/SettingsCustomizeVideoModal.tsx
index 490cd5e5725..d47b8479469 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsCustomizeVideoModal.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsCustomizeVideoModal.tsx
@@ -48,10 +48,6 @@ const StyledTitle = styled.div`
gap: ${themeCssVariables.spacing[1]};
min-width: 0;
padding-left: ${themeCssVariables.spacing[5]};
-
- & > svg {
- flex-shrink: 0;
- }
`;
const StyledTitleText = styled.span`
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsListItemCardContent.tsx b/packages/twenty-front/src/modules/settings/components/SettingsListItemCardContent.tsx
index 04bebc97771..148273abb02 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsListItemCardContent.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsListItemCardContent.tsx
@@ -21,10 +21,6 @@ const StyledRowContainer = styled.div`
padding: ${themeCssVariables.spacing[2]};
padding-left: ${themeCssVariables.spacing[3]};
position: relative;
-
- > svg {
- flex-shrink: 0;
- }
}
`;
diff --git a/packages/twenty-front/src/modules/ui/icon/components/ColoredIcon.tsx b/packages/twenty-front/src/modules/ui/icon/components/ColoredIcon.tsx
index 70db0f3dbd3..ab111e52e8b 100644
--- a/packages/twenty-front/src/modules/ui/icon/components/ColoredIcon.tsx
+++ b/packages/twenty-front/src/modules/ui/icon/components/ColoredIcon.tsx
@@ -1,12 +1,7 @@
-import { css } from '@linaria/core';
import { getIconTileColorShades } from 'twenty-ui/components/data-display';
import { type IconComponent } from 'twenty-ui/icon';
import { useTheme } from 'twenty-ui/theme';
-const iconClassName = css`
- flex-shrink: 0;
-`;
-
type ColoredIconProps = {
Icon: IconComponent;
color?: string | null;
@@ -24,7 +19,6 @@ export const ColoredIcon = ({
return (
<Icon
- className={iconClassName}
size={size ?? theme.icon.size.md}
stroke={stroke ?? theme.icon.stroke.md}
color={getIconTileColorShades(color).iconColor}
diff --git a/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRulePreview.tsx b/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRulePreview.tsx
index dd7ec0be7c5..ba7570cfeb4 100644
--- a/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRulePreview.tsx
+++ b/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRulePreview.tsx
@@ -90,10 +90,6 @@ const StyledFieldLabel = styled.div`
gap: ${themeCssVariables.spacing[1]};
min-width: 0;
overflow-wrap: anywhere;
-
- > svg {
- flex-shrink: 0;
- }
`;
const StyledValue = styled.span<{ isEmpty: boolean }>`
diff --git a/packages/twenty-ui/src/assets/icons/.svgrrc.json b/packages/twenty-ui/src/assets/icons/.svgrrc.json
new file mode 100644
index 00000000000..730a806dc87
--- /dev/null
+++ b/packages/twenty-ui/src/assets/icons/.svgrrc.json
@@ -0,0 +1,5 @@
+{
+ "svgProps": {
+ "data-twenty-icon": ""
+ }
+}
diff --git a/packages/twenty-ui/src/icon/components/IconChartBarHorizontal.module.scss b/packages/twenty-ui/src/icon/components/IconChartBarHorizontal.module.scss
index fc0cf1ef70a..06a0058c149 100644
--- a/packages/twenty-ui/src/icon/components/IconChartBarHorizontal.module.scss
+++ b/packages/twenty-ui/src/icon/components/IconChartBarHorizontal.module.scss
@@ -1,4 +1,5 @@
.rotatedIconWrapper {
+ flex-shrink: 0;
display: inline-flex;
transform: rotate(90deg);
}
diff --git a/packages/twenty-ui/src/icon/components/IllustrationIconWrapper.module.scss b/packages/twenty-ui/src/icon/components/IllustrationIconWrapper.module.scss
index 0f1fd4dce2d..9960cc822fc 100644
--- a/packages/twenty-ui/src/icon/components/IllustrationIconWrapper.module.scss
+++ b/packages/twenty-ui/src/icon/components/IllustrationIconWrapper.module.scss
@@ -3,5 +3,6 @@
border: 0.75px solid var(--t-border-color-medium);
border-radius: var(--t-border-radius-md);
display: flex;
+ flex-shrink: 0;
justify-content: center;
}
diff --git a/packages/twenty-ui/src/icon/components/ThinkingOrbitLoaderIcon.tsx b/packages/twenty-ui/src/icon/components/ThinkingOrbitLoaderIcon.tsx
index a8f55319748..523c105b7c2 100644
--- a/packages/twenty-ui/src/icon/components/ThinkingOrbitLoaderIcon.tsx
+++ b/packages/twenty-ui/src/icon/components/ThinkingOrbitLoaderIcon.tsx
@@ -11,6 +11,7 @@ export const ThinkingOrbitLoaderIcon = ({
}: ThinkingOrbitLoaderIconProps) => {
return (
<svg
+ data-twenty-icon=""
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
diff --git a/packages/twenty-ui/src/icon/components/__stories__/Icon.stories.tsx b/packages/twenty-ui/src/icon/components/__stories__/Icon.stories.tsx
index 8b540ef590c..550d7e253e9 100644
--- a/packages/twenty-ui/src/icon/components/__stories__/Icon.stories.tsx
+++ b/packages/twenty-ui/src/icon/components/__stories__/Icon.stories.tsx
@@ -1,4 +1,14 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, within } from 'storybook/test';
+
+import { IconUser } from '@ui/icon/components/TablerIcons';
+import { IconBrandGemini } from '@ui/icon/components/IconBrandGemini';
+import { IllustrationIconArray } from '@ui/icon/components/IllustrationIconArray';
+import { IconChartBarHorizontal } from '@ui/icon/components/IconChartBarHorizontal';
+import { ThinkingOrbitLoaderIcon } from '@ui/icon/components/ThinkingOrbitLoaderIcon';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { Chip } from '@ui/primitives/data-display/Chip/Chip';
+import { Text } from '@ui/primitives/typography/Text/Text';
import { IconsProvider } from '@ui/icon/providers/IconsProvider';
import { ComponentDecorator } from '@ui/testing/decorators/ComponentDecorator';
@@ -55,3 +65,115 @@ export const InvalidName: Story = {
name: 'NonExistentIcon',
},
};
+
+export const ConstrainedRows: Story = {
+ render: () => (
+ <div style={{ display: 'grid', gap: 12 }}>
+ <div
+ role="group"
+ aria-label="Tabler icon"
+ style={{ display: 'flex', width: 96, gap: 8 }}
+ >
+ <IconUser size={24} aria-hidden="true" />
+ <Text truncate>People with a long display name</Text>
+ </div>
+ <div
+ role="group"
+ aria-label="Brand icon"
+ style={{ display: 'flex', width: 96, gap: 8 }}
+ >
+ <IconBrandGemini size={24} />
+ <Text truncate>Gemini with a long display name</Text>
+ </div>
+ <div
+ role="group"
+ aria-label="Illustration icon"
+ style={{ display: 'flex', width: 96, gap: 8 }}
+ >
+ <IllustrationIconArray size={24} />
+ <Text truncate>Array with a long display name</Text>
+ </div>
+ <div
+ role="group"
+ aria-label="Wrapped icon"
+ style={{ display: 'flex', width: 96, gap: 8 }}
+ >
+ <IconChartBarHorizontal size={24} />
+ <Text truncate>Chart with a long display name</Text>
+ </div>
+ <div
+ role="group"
+ aria-label="Loader icon"
+ style={{ display: 'flex', width: 96, gap: 8 }}
+ >
+ <ThinkingOrbitLoaderIcon size={24} />
+ <Text truncate>Thinking about a long request</Text>
+ </div>
+ <Chip
+ role="group"
+ aria-label="Chip icon"
+ startElement={<IconBrandGemini size={14} />}
+ maxWidth={96}
+ >
+ Gemini with a long display name
+ </Chip>
+ <Button startIcon={<IconUser />} style={{ width: 96 }}>
+ People with a long display name
+ </Button>
+ </div>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ for (const name of [
+ 'Tabler icon',
+ 'Brand icon',
+ 'Illustration icon',
+ 'Wrapped icon',
+ 'Loader icon',
+ ]) {
+ const row = canvas.getByRole('group', { name });
+ const icon = row.querySelector('svg');
+
+ await expect(icon).not.toBeNull();
+ await expect(icon?.getBoundingClientRect().width).toBe(24);
+ }
+
+ const chipIcon = canvas
+ .getByRole('group', { name: 'Chip icon' })
+ .querySelector('svg');
+
+ await expect(chipIcon).not.toBeNull();
+ await expect(chipIcon?.getBoundingClientRect().width).toBe(14);
+
+ const button = canvas.getByRole('button', {
+ name: 'People with a long display name',
+ });
+ const buttonIcon = button.querySelector('svg');
+
+ await expect(buttonIcon).not.toBeNull();
+ await expect(buttonIcon?.getBoundingClientRect().width).toBe(14);
+ },
+};
+
+export const ExplicitShrink: Story = {
+ render: () => (
+ <div
+ role="group"
+ aria-label="Shrinking icon"
+ style={{ display: 'flex', width: 96, gap: 8 }}
+ >
+ <IconUser size={24} style={{ flexShrink: 1 }} aria-hidden="true" />
+ <Text style={{ flexShrink: 0 }}>People with a long display name</Text>
+ </div>
+ ),
+ play: async ({ canvasElement }) => {
+ const row = within(canvasElement).getByRole('group', {
+ name: 'Shrinking icon',
+ });
+ const icon = row.querySelector('svg');
+
+ await expect(icon).not.toBeNull();
+ await expect(icon?.getBoundingClientRect().width).toBeLessThan(24);
+ },
+};
diff --git a/packages/twenty-ui/src/icon/components/__tests__/SvgIcons.test.tsx b/packages/twenty-ui/src/icon/components/__tests__/SvgIcons.test.tsx
new file mode 100644
index 00000000000..c44f057d81f
--- /dev/null
+++ b/packages/twenty-ui/src/icon/components/__tests__/SvgIcons.test.tsx
@@ -0,0 +1,15 @@
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import IconGoogleRaw from '@assets/icons/google.svg?react';
+
+describe('SVG icon generation', () => {
+ it('marks imported SVG roots for shared icon styling without caller attributes', () => {
+ render(<IconGoogleRaw role="img" aria-label="Google" />);
+
+ expect(screen.getByRole('img', { name: 'Google' })).toHaveAttribute(
+ 'data-twenty-icon',
+ '',
+ );
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss b/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss
index 2e678e91ae1..703ad4d567b 100644
--- a/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss
+++ b/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss
@@ -28,9 +28,6 @@
corner-shape: round;
text-decoration: none;
- & > svg {
- flex-shrink: 0;
- }
&[data-truncate] > .label {
min-inline-size: 0;
}
diff --git a/packages/twenty-ui/src/styles/base/reset.scss b/packages/twenty-ui/src/styles/base/reset.scss
index 24bb9d61a8e..40b14adba55 100644
--- a/packages/twenty-ui/src/styles/base/reset.scss
+++ b/packages/twenty-ui/src/styles/base/reset.scss
@@ -5,6 +5,10 @@
box-sizing: border-box;
}
+ :where(.tabler-icon, [data-twenty-icon]) {
+ flex-shrink: 0;
+ }
+
button {
margin: 0;
padding: 0;