Skip to content

The open alternative to Salesforce, designed for AI.

Keep full Tag labels at their natural width (#28300)

Raphaël Bosia0ddc844e88e
diff --git a/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdx b/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdx
index 8d1ec227268..e9845349dba 100644
--- a/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdx
@@ -32,7 +32,7 @@
</ParamField>
<ParamField body="truncate" type="boolean" default="true">
- Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to show the full label without a tooltip.
+ Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to keep the full label at its natural width without a tooltip, even inside a narrower parent.
</ParamField>
<ParamField body="variant" type="&quot;ghost&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;" default="soft">
diff --git a/packages/twenty-docs/ui/primitives/data-display/tag.mdx b/packages/twenty-docs/ui/primitives/data-display/tag.mdx
index bd724a66f6b..a63928a3b00 100644
--- a/packages/twenty-docs/ui/primitives/data-display/tag.mdx
+++ b/packages/twenty-docs/ui/primitives/data-display/tag.mdx
@@ -91,23 +91,19 @@ Compose an interactive owner through `render`. Put its click handler, native att
## Long labels
-By default, `truncate={true}` truncates constrained string labels and exposes their full text in a tooltip on hover. Set `truncate={false}` to display the full label without a tooltip. The surrounding layout still owns the available width.
+By default, `truncate={true}` truncates constrained string labels and exposes their full text in a tooltip on hover. Set `truncate={false}` to keep the full label at its natural width without a tooltip, even when its parent is narrower. The parent layout owns wrapping, scrolling, and clipping.
```tsx
import { Tag } from 'twenty-ui/primitives/data-display';
export const FullCategoryLabel = () => (
- <Tag
- color="green"
- truncate={false}
- style={{ minWidth: 'fit-content', padding: 0 }}
- >
+ <Tag color="green" truncate={false}>
Enterprise customer
</Tag>
);
```
-Use native styles for spacing and layout. This example keeps the full label width and removes padding. Node children remain caller-owned content, so compose their text, translations, and intentional links directly.
+Node children remain caller-owned content, so compose their text, translations, and intentional links directly.
## Props
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx
index 59bc33d1477..5d4b966ace8 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx
@@ -99,7 +99,7 @@ const TagControls = () => {
>
Tag documentation
</Tag>
- <Tag color="gray" truncate={false} style={{ padding: 0 }}>
+ <Tag color="gray" truncate={false}>
<a href="#tag-records" target="_self">
Intentional tag link
</a>
@@ -107,14 +107,11 @@ const TagControls = () => {
<Tag color="blue" title="Truncated tag" style={{ width: 100 }}>
A long tag label that should truncate
</Tag>
- <Tag
- color="blue"
- title="Full tag"
- truncate={false}
- style={{ minWidth: 'fit-content' }}
- >
- A long tag label shown in full
- </Tag>
+ <div style={{ display: 'flex', width: 100 }}>
+ <Tag color="blue" title="Full tag" truncate={false}>
+ A long tag label shown in full
+ </Tag>
+ </div>
</div>
),
},
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tagControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tagControlsTest.ts
index 06251a0b189..787934d8387 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tagControlsTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tagControlsTest.ts
@@ -66,7 +66,6 @@ export const tagControlsTest: TwentyUiGalleryPlayFunction = async (context) => {
expect(nodeLink).toHaveAttribute('href', '#tag-records');
expect(nodeLink.parentElement?.parentElement?.tagName).toBe('SPAN');
- expect(nodeLink.parentElement?.parentElement).toHaveStyle({ padding: '0px' });
expect(canvas.getByText('Static tag')).toBeVisible();
const truncatedText = canvas.getByText(
@@ -82,6 +81,7 @@ export const tagControlsTest: TwentyUiGalleryPlayFunction = async (context) => {
);
});
expect(fullTag).not.toHaveAttribute('data-truncate');
+ expect(fullTag.getBoundingClientRect().width).toBeGreaterThan(100);
expect(getComputedStyle(fullText).textOverflow).toBe('clip');
expect(fullText.scrollWidth).toBe(fullText.clientWidth);
expect(fullText).not.toHaveAttribute('tabindex');
diff --git a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx
index 177c35a66e1..b6a3ebeaeac 100644
--- a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx
+++ b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx
@@ -48,10 +48,6 @@ const StyledHeaderRight = styled.div`
gap: ${themeCssVariables.spacing[1]};
`;
-const StyledExecutionStatusTag = styled(Tag)`
- min-width: fit-content;
-`;
-
const StyledTitle = styled.span`
color: ${themeCssVariables.font.color.primary};
font-size: ${themeCssVariables.font.size.md};
@@ -210,7 +206,7 @@ export const CodeExecutionDisplay = ({
<StyledTitle>{t`Python Code Execution`}</StyledTitle>
</StyledHeaderLeft>
<StyledHeaderRight>
- <StyledExecutionStatusTag
+ <Tag
color={
status === 'success'
? 'turquoise'
@@ -222,7 +218,7 @@ export const CodeExecutionDisplay = ({
truncate={false}
>
{statusText}
- </StyledExecutionStatusTag>
+ </Tag>
</StyledHeaderRight>
</StyledHeader>
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx
index 9928dc0e0dc..2ac1591acfa 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx
@@ -25,10 +25,6 @@ const StyledContainer = styled.div`
gap: ${themeCssVariables.spacing[2]};
`;
-const StyledAttemptsTag = styled(Tag)`
- min-width: fit-content;
-`;
-
export const SettingsAdminJobStateBadge = ({
state,
attemptsMade = 1,
@@ -40,12 +36,12 @@ export const SettingsAdminJobStateBadge = ({
<StyledContainer>
<Tag color={color}>{state}</Tag>
{showAttempts && (
- <StyledAttemptsTag color="red" weight="medium" truncate={false}>
+ <Tag color="red" weight="medium" truncate={false}>
{plural(attemptsMade, {
one: `${attemptsMade} attempt`,
other: `${attemptsMade} attempts`,
})}
- </StyledAttemptsTag>
+ </Tag>
)}
</StyledContainer>
);
diff --git a/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx b/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx
index 334753c8f33..985281b41b2 100644
--- a/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx
+++ b/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx
@@ -17,10 +17,6 @@ const StyledTagsWrapper = styled.div`
gap: ${themeCssVariables.spacing[1]};
`;
-const StyledTrialTag = styled(Tag)`
- min-width: fit-content;
-`;
-
export const PlansTags = ({ plan, isTrialPeriod = false }: PlansTagsProps) => {
return (
<StyledTagsWrapper>
@@ -28,9 +24,9 @@ export const PlansTags = ({ plan, isTrialPeriod = false }: PlansTagsProps) => {
{t(BILLING_PLAN_LABELS[plan])}
</Tag>
{isTrialPeriod && (
- <StyledTrialTag color="blue" truncate={false}>
+ <Tag color="blue" truncate={false}>
{t`Trial`}
- </StyledTrialTag>
+ </Tag>
)}
</StyledTagsWrapper>
);
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
index ae6308cae44..a85f3ea268a 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
@@ -13,7 +13,6 @@ import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableLi
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader/DropdownMenuHeader';
import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
-import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { MenuItemDraggable } from 'twenty-ui/components/navigation';
@@ -22,10 +21,6 @@ import { Tag } from 'twenty-ui/primitives/data-display';
import { type WidgetConfiguration } from '~/generated-metadata/graphql';
import { moveArrayItem } from '~/utils/array/moveArrayItem';
-const StyledOptionTag = styled(Tag)`
- min-width: fit-content;
-`;
-
type ChartManualSortSubMenuContentProps = {
fieldMetadataItem: FieldMetadataItem;
axis: 'primary' | 'secondary';
@@ -109,9 +104,9 @@ export const ChartManualSortSubMenuContent = ({
gripMode="always"
isDragDisabled={sortedOptions.length === 1}
text={
- <StyledOptionTag truncate={false} color={option.color}>
+ <Tag truncate={false} color={option.color}>
{option.label}
- </StyledOptionTag>
+ </Tag>
}
/>
}
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
index b0bfcb3e317..a46b5440353 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
@@ -17,10 +17,6 @@ const StyledContainer = styled.div`
width: 100%;
`;
-const StyledSelectedOptionTag = styled(Tag)`
- min-width: fit-content;
-`;
-
export const MultiSelectDisplay = ({
values,
options,
@@ -39,7 +35,7 @@ export const MultiSelectDisplay = ({
return (
<StyledContainer className={className}>
{selectedOptions.map((selectedOption, index) => (
- <StyledSelectedOptionTag
+ <Tag
truncate={false}
key={index}
color={selectedOption.color ?? 'transparent'}
@@ -48,7 +44,7 @@ export const MultiSelectDisplay = ({
}
>
{selectedOption.label}
- </StyledSelectedOptionTag>
+ </Tag>
))}
</StyledContainer>
);
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsx
index 7aade7aa045..23b1b7f1afb 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsx
@@ -1,4 +1,3 @@
-import { styled } from '@linaria/react';
import { type IconComponent } from 'twenty-ui/icon';
import { Tag } from 'twenty-ui/primitives/data-display';
import { type ThemeColor } from 'twenty-ui/theme';
@@ -10,16 +9,12 @@ type SelectDisplayProps = {
Icon?: IconComponent;
};
-const StyledSelectTag = styled(Tag)`
- min-width: fit-content;
-`;
-
export const SelectDisplay = ({ color, label, Icon }: SelectDisplayProps) => (
- <StyledSelectTag
+ <Tag
truncate={false}
color={color}
startIcon={isDefined(Icon) ? <Icon /> : undefined}
>
{label}
- </StyledSelectTag>
+ </Tag>
);
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
index 9b3a42b73df..dc1435cbac2 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
@@ -6,7 +6,6 @@ import { type ApplicationDisplayData } from '@/applications/types/ApplicationDis
import { StyledNameTableCell } from '@/settings/data-model/object-details/components/SettingsObjectItemTableRowStyledComponents';
import { TableCell } from '@/ui/layout/table/components/TableCell';
import { TableRow } from '@/ui/layout/table/components/TableRow';
-import { styled } from '@linaria/react';
import { msg, t } from '@lingui/core/macro';
import { type MessageDescriptor } from '@lingui/core';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
@@ -38,12 +37,6 @@ const SOURCE_TYPE_LABELS: Record<
[ApplicationRegistrationSourceType.TARBALL]: msg`Tarball`,
};
-const StyledUpdateTag = styled(Tag)`
- && {
- min-width: fit-content;
- }
-`;
-
export const SettingsApplicationTableRow = ({
action,
application,
@@ -70,9 +63,9 @@ export const SettingsApplicationTableRow = ({
<TableCell gap={themeCssVariables.spacing[2]} minWidth="0">
<OverflowingTextWithTooltip text={descriptionSummary} />
{hasUpdate === true && (
- <StyledUpdateTag color="blue" weight="medium">
+ <Tag color="blue" weight="medium" truncate={false}>
{t`Update`}
- </StyledUpdateTag>
+ </Tag>
)}
</TableCell>
<TableCell
diff --git a/packages/twenty-ui/docs/tagPropDescriptions.ts b/packages/twenty-ui/docs/tagPropDescriptions.ts
index bda295874c0..634d40c2cd2 100644
--- a/packages/twenty-ui/docs/tagPropDescriptions.ts
+++ b/packages/twenty-ui/docs/tagPropDescriptions.ts
@@ -7,7 +7,7 @@ export const TAG_PROP_DESCRIPTIONS = {
startIcon:
'Decorative icon before the label. Hidden from assistive technology.',
truncate:
- 'Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to show the full label without a tooltip.',
+ 'Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to keep the full label at its natural width without a tooltip, even inside a narrower parent.',
borderStyle: 'Border style used by the outline variant.',
render:
'Replaces the default span. Compose a button or link to provide explicit interaction semantics.',
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 918379b0065..376767b270b 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -11159,7 +11159,7 @@
"type": "boolean",
"required": false,
"defaultValue": "true",
- "description": "Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to show the full label without a tooltip."
+ "description": "Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to keep the full label at its natural width without a tooltip, even inside a narrower parent."
},
{
"name": "variant",
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OVERFLOWING_LIST_STORY_ITEMS.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OVERFLOWING_LIST_STORY_ITEMS.tsx
index 440b6d4abe9..af5b4cf3692 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OVERFLOWING_LIST_STORY_ITEMS.tsx
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OVERFLOWING_LIST_STORY_ITEMS.tsx
@@ -6,12 +6,7 @@ export const OVERFLOWING_LIST_STORY_ITEMS = [
'Priority',
'Renewal',
].map((label) => (
- <Tag
- key={label}
- color="blue"
- truncate={false}
- style={{ width: 80, minWidth: 'fit-content' }}
- >
+ <Tag key={label} color="blue" truncate={false} style={{ width: 80 }}>
{label}
</Tag>
));
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.interactions.stories.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.interactions.stories.tsx
index bc3976550c7..adf64bbcb71 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.interactions.stories.tsx
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.interactions.stories.tsx
@@ -778,12 +778,7 @@ export const DescendantContentUpdates: Story = {
style: { width: 200 },
children: [
<OverflowingListMutableTag key="customer" />,
- <Tag
- key="partner"
- color="green"
- truncate={false}
- style={{ minWidth: 'fit-content' }}
- >
+ <Tag key="partner" color="green" truncate={false}>
Partner
</Tag>,
],
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx
index ca36175dff1..72a7fd2d3b5 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx
@@ -9,7 +9,6 @@ export const OverflowingListMutableTag = () => {
<Tag
color="blue"
truncate={false}
- style={{ minWidth: 'fit-content' }}
render={
<button
type="button"
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx
index 72d0aa3913f..6e2d9478f58 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx
@@ -18,12 +18,7 @@ export const OverflowingListResizeExample = () => {
style={{ width: isNarrow ? 100 : 360 }}
>
{['Customer', 'Partner', 'Priority', 'Renewal'].map((label) => (
- <Tag
- key={label}
- color="blue"
- truncate={false}
- style={{ minWidth: 'fit-content' }}
- >
+ <Tag key={label} color="blue" truncate={false}>
{hasLongLabels ? `${label} with a longer label` : label}
</Tag>
))}
diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss
index 3b8661dad35..67e234173f6 100644
--- a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss
+++ b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss
@@ -19,6 +19,10 @@
min-inline-size: 0;
text-align: inherit;
+ &:not([data-truncate]) {
+ min-inline-size: fit-content;
+ }
+
&:is(button, a, [role='button'], [role='link']) {
cursor: pointer;
}
diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsx b/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsx
index 1ebf28c5e3f..551034f0a36 100644
--- a/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsx
+++ b/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsx
@@ -62,7 +62,7 @@ export const WithoutTruncation: Story = {
color: 'green',
children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
truncate: false,
- style: { minWidth: 'fit-content' },
+ title: 'Full category label',
},
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
@@ -70,21 +70,6 @@ export const WithoutTruncation: Story = {
},
};
-export const WithoutPadding: Story = {
- ...Display,
- args: {
- ...Display.args,
- style: { padding: 0 },
- title: 'Unpadded category',
- },
- play: async ({ canvasElement }) => {
- const tag = within(canvasElement).getByTitle('Unpadded category');
-
- await expect(tag).toBeVisible();
- await expect(getComputedStyle(tag).padding).toBe('0px');
- },
-};
-
export const Truncation: Story = {
...WithLongText,
play: async ({ canvasElement }) => {
@@ -109,11 +94,20 @@ export const Truncation: Story = {
export const FullLabel: Story = {
...WithoutTruncation,
+ args: {
+ ...WithoutTruncation.args,
+ variant: 'outline',
+ startIcon: <IconUser />,
+ },
play: async ({ canvasElement }) => {
const text = within(canvasElement).getByText(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
);
+ const tag = within(canvasElement).getByTitle('Full category label');
+
+ await expect(tag.getBoundingClientRect().width).toBeGreaterThan(100);
+ await expect(tag.getBoundingClientRect().height).toBe(22);
await expect(getComputedStyle(text).textOverflow).not.toBe('ellipsis');
await expect(text.scrollWidth).toBeLessThanOrEqual(text.clientWidth);
await userEvent.hover(text);
@@ -188,7 +182,6 @@ export const PointerAndKeyboard: Story = {
ref: fn(),
color: 'blue',
variant: 'solid',
- style: { padding: 0 },
},
render: ({ onClick, ...args }) => (
<Tag {...args} render={<button type="button" onClick={onClick} />} />
@@ -204,7 +197,6 @@ export const PointerAndKeyboard: Story = {
await expect(control).toHaveFocus();
await expect(args.ref).toHaveBeenCalledWith(control);
await expect(control).toHaveAttribute('data-variant', 'solid');
- await expect(getComputedStyle(control).padding).toBe('0px');
await expect(args.onClick).toHaveBeenLastCalledWith(
expect.objectContaining({ type: 'click' }),
);