Skip to content

The open alternative to Salesforce, designed for AI.

Add shared Text typography props (#28527)

Raphaël Bosi279ba3aec2a1
diff --git a/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx b/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
index 127f841638c..4ebaadca81a 100644
--- a/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
@@ -15,6 +15,10 @@
Allows the tooltip even when the text is not truncated.
</ParamField>
+<ParamField body="color" type="&quot;light&quot; | &quot;primary&quot; | &quot;secondary&quot; | &quot;tertiary&quot;">
+ Semantic text color. Omitted values inherit; native style supports runtime colors.
+</ParamField>
+
<ParamField body="isFocusable" type="boolean">
Adds an optional tab stop. Native tabIndex and focusable render elements also open the tooltip on focus.
</ParamField>
@@ -31,6 +35,10 @@
Replaces the default div. Native props, styles, handlers and ref target the displayed text, not the popup.
</ParamField>
+<ParamField body="size" type="&quot;lg&quot; | &quot;md&quot; | &quot;sm&quot; | &quot;xl&quot; | &quot;xs&quot; | &quot;xxl&quot; | &quot;xxs&quot;">
+ Font size from the theme scale. Omitted values inherit; this does not set height.
+</ParamField>
+
<ParamField body="text" type="string | number | bigint | boolean | ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | Iterable&lt;ReactNode&gt; | ReactPortal | Promise&lt;...&gt; | null | undefined" required>
Caller-owned text or React content. Non-string content requires `tooltipContent`. URLs stay plain text.
</ParamField>
@@ -50,3 +58,7 @@
<ParamField body="truncate" type="boolean">
Single-line ellipsis by default. Set false to wrap. Cannot be combined with `lineClamp`.
</ParamField>
+
+<ParamField body="weight" type="&quot;medium&quot; | &quot;regular&quot; | &quot;semibold&quot;">
+ Theme font weight. Omitted values inherit.
+</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/typography/text.mdx b/packages/twenty-docs/snippets/ui/generated/typography/text.mdx
index 1685330010d..bd2b4756877 100644
--- a/packages/twenty-docs/snippets/ui/generated/typography/text.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/typography/text.mdx
@@ -11,6 +11,10 @@
* npx nx generate:ui twenty-docs
*/}
+<ParamField body="color" type="&quot;light&quot; | &quot;primary&quot; | &quot;secondary&quot; | &quot;tertiary&quot;">
+ Semantic text color. Omitted values inherit; native style supports runtime colors.
+</ParamField>
+
<ParamField body="lineClamp" type="number">
Positive integer limiting the number of visible lines. Cannot be combined with `truncate`.
</ParamField>
@@ -19,6 +23,14 @@
Replaces the default div. Native props and the ref target the rendered text element.
</ParamField>
+<ParamField body="size" type="&quot;lg&quot; | &quot;md&quot; | &quot;sm&quot; | &quot;xl&quot; | &quot;xs&quot; | &quot;xxl&quot; | &quot;xxs&quot;">
+ Font size from the theme scale. Omitted values inherit; this does not set height.
+</ParamField>
+
<ParamField body="truncate" type="boolean">
Truncates one line with an ellipsis. Cannot be combined with `lineClamp`.
</ParamField>
+
+<ParamField body="weight" type="&quot;medium&quot; | &quot;regular&quot; | &quot;semibold&quot;">
+ Theme font weight. Omitted values inherit.
+</ParamField>
diff --git a/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx b/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx
index 8c5cfa38343..d4c27c79d13 100644
--- a/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx
+++ b/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx
@@ -35,6 +35,24 @@ export const RecordTitle = () => (
Constrain the width of the surrounding layout so truncation can occur. `isFocusable` gives the text a tab stop and opens the tooltip on focus or click. Keep essential information available to users who cannot hover.
+## Choose typography
+
+`size`, `weight` and `color` match [Text](/ui/primitives/typography/text). They are optional and inherit independently when omitted. Explicit typography applies to the displayed text; the tooltip retains its shared appearance.
+
+```tsx
+import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
+
+export const WorkspaceCaption = () => (
+ <OverflowingTextWithTooltip
+ text="Quarterly account review and renewal preparation"
+ size="xs"
+ weight="semibold"
+ color="light"
+ style={{ maxWidth: 220 }}
+ />
+);
+```
+
## Multiline content
```tsx
@@ -82,7 +100,7 @@ React content requires a plain-string `tooltipContent`. With string text, that p
`alwaysShowTooltip` allows the tooltip even without truncation. `tooltipDelay` controls the hover delay and defaults to 500 milliseconds. `tooltipPlace` defaults to `bottom`.
-Native attributes, styles, class names, event handlers, and refs target the displayed Text element, a `div` by default. `render` can replace that element while retaining truncation and tooltip behavior. `OverflowingTextWithTooltipProps` is exported from `twenty-ui/primitives/typography`. Typography inherits from the surrounding layout. Set `truncate={false}` to wrap; choose either `truncate` or `lineClamp`. Focusable rendered elements and a caller-supplied `tabIndex` also reveal the tooltip on focus. Use [Text](/ui/primitives/typography/text) and [Tooltip](/ui/primitives/surfaces/tooltip) directly when you need custom composition. Interactive popup content belongs in [Popover](/ui/primitives/surfaces/popover).
+Native attributes, styles, class names, event handlers, and refs target the displayed Text element, a `div` by default. `render` can replace that element while retaining truncation and tooltip behavior. `OverflowingTextWithTooltipProps` is exported from `twenty-ui/primitives/typography`. Typography inherits from the surrounding layout unless an explicit typography prop is supplied. Set `truncate={false}` to wrap; choose either `truncate` or `lineClamp`. Focusable rendered elements and a caller-supplied `tabIndex` also reveal the tooltip on focus. Use [Text](/ui/primitives/typography/text) and [Tooltip](/ui/primitives/surfaces/tooltip) directly when you need custom composition. Interactive popup content belongs in [Popover](/ui/primitives/surfaces/popover).
## Explicit links
@@ -104,7 +122,7 @@ Use a single anchor for the whole label, or supply individual anchors in React c
## Migration
-Replace `displayedMaxRows` with `lineClamp`. The removed `size` option controlled height, not font size; use native `style` or `className` for sizing. Move intentional URL recognition into caller-owned content. No automatic linkification remains in this component.
+Replace `displayedMaxRows` with `lineClamp`. The former `size="small"` and `size="large"` options controlled height, not font size. `large` set a 16px height. The new `size` selects theme font sizes and accepts no legacy aliases; use native `style` or `className` for height constraints. `color` now accepts semantic colors; move arbitrary CSS colors to `style={{ color: customColor }}`. Move intentional URL recognition into caller-owned content. No automatic linkification remains in this component.
## Props
diff --git a/packages/twenty-docs/ui/primitives/typography/text.mdx b/packages/twenty-docs/ui/primitives/typography/text.mdx
index 9e0ad84ce93..7ff6c0ed1ec 100644
--- a/packages/twenty-docs/ui/primitives/typography/text.mdx
+++ b/packages/twenty-docs/ui/primitives/typography/text.mdx
@@ -1,13 +1,13 @@
---
title: Text
-description: Render text with single-line truncation or a limited number of lines.
+description: Compose theme typography with single-line truncation or a limited number of lines.
---
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import TextReference from '/snippets/ui/generated/typography/text.mdx';
-`Text` provides overflow handling. It renders a `div` by default and inherits typography from its surroundings.
+`Text` provides typography and overflow handling. It renders a `div` by default. Omit `size`, `weight` and `color` to keep inheriting typography from its surroundings.
<StoryEmbed
storyId="ui-typography-text--display"
@@ -29,6 +29,42 @@ export const ContactName = () => (
);
```
+## Choose typography
+
+`size` uses the existing theme scale. It changes font size, with no height, font-family or line-height default:
+
+| Size | Theme value |
+| ----- | ----------- |
+| `xxs` | `0.625rem` |
+| `xs` | `0.85rem` |
+| `sm` | `0.92rem` |
+| `md` | `1rem` |
+| `lg` | `1.23rem` |
+| `xl` | `1.54rem` |
+| `xxl` | `1.85rem` |
+
+`weight` accepts `regular` (400), `medium` (500) or `semibold` (600). `color` accepts `primary`, `secondary`, `tertiary` or `light`. Each omitted prop inherits independently. The visual size does not change the semantic element.
+
+<StoryEmbed
+ storyId="ui-typography-text--typography-catalog"
+ title="Text typography scale"
+ height={410}
+/>
+
+For captions, compose the small size, semibold weight and light color:
+
+```tsx
+import { Text } from 'twenty-ui/primitives/typography';
+
+export const Caption = () => (
+ <Text size="xs" weight="semibold" color="light">
+ Workspace
+ </Text>
+);
+```
+
+Use native `style` for runtime colors and parent-layout constraints. Caller classes and render composition target the same text element. Text adds no typography defaults when these props are omitted.
+
## Limit the number of lines
<StoryEmbed
@@ -69,3 +105,7 @@ Truncation affects the visual presentation; it does not shorten the text in the
Native attributes, children, refs, class names, and styles target the rendered text element. `TextProps` is exported from `twenty-ui/primitives/typography`. Text content is rendered unchanged, including caller-provided links.
<TextReference />
+
+## Migration
+
+`color` now selects a semantic theme color. Move arbitrary CSS color values from a native `color` attribute to `style={{ color: customColor }}`. Existing styles, classes and render composition continue to target the text element.
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupDraggableHeader.tsx b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupDraggableHeader.tsx
index fda94c08a18..26a48f0dcc8 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupDraggableHeader.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupDraggableHeader.tsx
@@ -40,13 +40,9 @@ export const FieldsConfigurationGroupDraggableHeader = ({
color={themeCssVariables.font.color.tertiary}
/>
</StyledIconContainer>
- <StyledDisplayLabel>{text}</StyledDisplayLabel>
+ <Text size="xs" weight="semibold" color="light">
+ {text}
+ </Text>
</StyledContainer>
);
};
-
-const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
diff --git a/packages/twenty-front/src/modules/settings/accounts/components/message-folders/SettingsAccountsMessageFoldersCard.tsx b/packages/twenty-front/src/modules/settings/accounts/components/message-folders/SettingsAccountsMessageFoldersCard.tsx
index ea2df752b49..63053a301d4 100644
--- a/packages/twenty-front/src/modules/settings/accounts/components/message-folders/SettingsAccountsMessageFoldersCard.tsx
+++ b/packages/twenty-front/src/modules/settings/accounts/components/message-folders/SettingsAccountsMessageFoldersCard.tsx
@@ -142,11 +142,15 @@ export const SettingsAccountsMessageFoldersCard = () => {
/>
</StyledSearchInputContainer>
<StyledLabelContainer>
- <StyledDisplayLabel>{t`Folders`}</StyledDisplayLabel>
+ <Text size="xs" weight="semibold" color="light">{t`Folders`}</Text>
</StyledLabelContainer>
<StyledSectionHeader>
- <StyledDisplayLabel>{t`Toggle all folders`}</StyledDisplayLabel>
+ <Text
+ size="xs"
+ weight="semibold"
+ color="light"
+ >{t`Toggle all folders`}</Text>
<TableCell
align="right"
padding={`0 ${themeCssVariables.spacing[1]} 0 ${themeCssVariables.spacing[2]}`}
@@ -174,9 +178,3 @@ export const SettingsAccountsMessageFoldersCard = () => {
</Section.Root>
);
};
-
-const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
diff --git a/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/field-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableAllHeaderRow.tsx b/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/field-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableAllHeaderRow.tsx
index 84aaeb0ae31..aea6655330d 100644
--- a/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/field-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableAllHeaderRow.tsx
+++ b/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/field-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableAllHeaderRow.tsx
@@ -102,7 +102,7 @@ export const SettingsRolePermissionsObjectLevelObjectFieldPermissionTableAllHead
return (
<>
<StyledSectionHeader>
- <StyledDisplayLabel>{t`All`}</StyledDisplayLabel>
+ <Text size="xs" weight="semibold" color="light">{t`All`}</Text>
<div></div>
<>
{shouldShowEmptyTableHeader && <div />}
@@ -131,9 +131,3 @@ export const SettingsRolePermissionsObjectLevelObjectFieldPermissionTableAllHead
</>
);
};
-
-const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelGroup.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelGroup.tsx
index 98e14f6d855..204ffa4cafc 100644
--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelGroup.tsx
+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelGroup.tsx
@@ -31,15 +31,11 @@ export const SidePanelGroup = ({ heading, children }: SidePanelGroupProps) => {
return (
<>
<StyledGroupHeadingContainer>
- <StyledDisplayLabel>{heading}</StyledDisplayLabel>
+ <Text size="xs" weight="semibold" color="light">
+ {heading}
+ </Text>
</StyledGroupHeadingContainer>
<StyledGroup>{children}</StyledGroup>
</>
);
};
-
-const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
diff --git a/packages/twenty-front/src/modules/ui/field/display/utils/getChipLabel.tsx b/packages/twenty-front/src/modules/ui/field/display/utils/getChipLabel.tsx
index 158c9588ff1..f35a82d85bf 100644
--- a/packages/twenty-front/src/modules/ui/field/display/utils/getChipLabel.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/utils/getChipLabel.tsx
@@ -1,7 +1,6 @@
import { t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { Text } from 'twenty-ui/primitives/typography';
-import { themeCssVariables } from 'twenty-ui/theme';
export const getChipLabel = (value: string | null | undefined) => {
if (isNonEmptyString(value)) {
@@ -13,10 +12,7 @@ export const getChipLabel = (value: string | null | undefined) => {
return {
text,
content: (
- <Text
- render={<span />}
- style={{ color: themeCssVariables.font.color.tertiary }}
- >
+ <Text render={<span />} color="tertiary">
{text}
</Text>
),
diff --git a/packages/twenty-front/src/modules/ui/layout/line/components/LabeledDivider.tsx b/packages/twenty-front/src/modules/ui/layout/line/components/LabeledDivider.tsx
index 1e62ae32357..d97764e0005 100644
--- a/packages/twenty-front/src/modules/ui/layout/line/components/LabeledDivider.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/line/components/LabeledDivider.tsx
@@ -12,9 +12,6 @@ const StyledContainer = styled.div<{ noMargin: boolean }>`
`;
const StyledLabel = styled(Text)`
- color: ${themeCssVariables.font.color.light};
- font-size: 11px;
- font-weight: ${themeCssVariables.font.weight.semiBold};
margin-inline: ${themeCssVariables.spacing[2]};
`;
@@ -40,7 +37,13 @@ export const LabeledDivider = ({
return (
<StyledContainer role="separator" aria-label={children} noMargin={noMargin}>
<Separator aria-hidden style={separatorStyle} />
- <StyledLabel render={<span />} style={{ color }}>
+ <StyledLabel
+ size="xs"
+ weight="semibold"
+ color="light"
+ render={<span />}
+ style={{ color }}
+ >
{children}
</StyledLabel>
{textPosition === 'center' && (
diff --git a/packages/twenty-front/src/modules/ui/layout/table/components/TableSection.tsx b/packages/twenty-front/src/modules/ui/layout/table/components/TableSection.tsx
index bac2752045a..91615d179c2 100644
--- a/packages/twenty-front/src/modules/ui/layout/table/components/TableSection.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/table/components/TableSection.tsx
@@ -53,7 +53,9 @@ export const TableSection = ({
isExpanded={isExpanded}
onClick={handleToggleSection}
>
- <StyledDisplayLabel>{title}</StyledDisplayLabel>
+ <Text size="xs" weight="semibold" color="light">
+ {title}
+ </Text>
{isExpanded ? (
<IconChevronUp
size={theme.icon.size.md}
@@ -76,9 +78,3 @@ export const TableSection = ({
</>
);
};
-
-const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
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 aee8dd4413f..bc294c5bcb6 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
@@ -9,10 +9,6 @@ import { Text } from 'twenty-ui/primitives/typography';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';
const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: ${themeCssVariables.font.size.xs};
- font-weight: var(--t-font-weight-semi-bold);
-
.section-title-container:hover & {
color: ${themeCssVariables.font.color.tertiary};
}
@@ -98,7 +94,9 @@ export const NavigationDrawerSectionTitle = ({
return (
<StyledTitle className="section-title-container">
<StyledLabelContainer onClick={handleTitleClick}>
- <StyledDisplayLabel>{label}</StyledDisplayLabel>
+ <StyledDisplayLabel size="xs" weight="semibold" color="light">
+ {label}
+ </StyledDisplayLabel>
{isOpen !== undefined && (
<StyledChevron>
<MotionIconChevronRight
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-edges/components/WorkflowDiagramEdgeLabel.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-edges/components/WorkflowDiagramEdgeLabel.tsx
index 9aca3e4ec0d..09a28aba8c2 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-edges/components/WorkflowDiagramEdgeLabel.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-edges/components/WorkflowDiagramEdgeLabel.tsx
@@ -33,13 +33,9 @@ export const WorkflowDiagramEdgeLabel = ({
return (
<StyledContainer>
{isDefined(elseIfIndex) && <StyledNumber>{elseIfIndex}</StyledNumber>}
- <StyledDisplayLabel>{label}</StyledDisplayLabel>
+ <Text size="xs" weight="semibold" color="light">
+ {label}
+ </Text>
</StyledContainer>
);
};
-
-const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowNodeLabel.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowNodeLabel.tsx
index c2c77875c6b..1c2bed834bf 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowNodeLabel.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowNodeLabel.tsx
@@ -26,13 +26,14 @@ export const WorkflowNodeLabel = ({
return (
<StyledNodeLabelWrapper className={className}>
- <StyledDisplayLabel color={labelColor}>{children}</StyledDisplayLabel>
+ <Text
+ size="xs"
+ weight="semibold"
+ color="light"
+ style={{ color: labelColor }}
+ >
+ {children}
+ </Text>
</StyledNodeLabelWrapper>
);
};
-
-const StyledDisplayLabel = styled(Text)<{ color: string }>`
- color: ${({ color }) => color};
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsx
index 78ae56db719..e830a804946 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsx
@@ -64,9 +64,6 @@ import {
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
const StyledFeatureFlagName = styled(OverflowingTextWithTooltip)`
- color: ${themeCssVariables.font.color.primary};
- font-size: ${themeCssVariables.font.size.md};
- font-weight: ${themeCssVariables.font.weight.regular};
min-width: 0;
`;
@@ -256,6 +253,9 @@ export const SettingsAdminWorkspaceDetail = () => {
overflow: 'hidden',
Cell: ({ item }) => (
<StyledFeatureFlagName
+ size="md"
+ weight="regular"
+ color="primary"
text={<>{item.label}</>}
tooltipContent={item.id}
tooltipPlace="top"
diff --git a/packages/twenty-ui/CHANGELOG.md b/packages/twenty-ui/CHANGELOG.md
index 3f2ad65cc2e..6133f1f64dc 100644
--- a/packages/twenty-ui/CHANGELOG.md
+++ b/packages/twenty-ui/CHANGELOG.md
@@ -4,6 +4,11 @@
### Breaking changes
+`Text` and `OverflowingTextWithTooltip` now offer optional theme `size`, `weight` and `color` props. Omitted props preserve inherited typography. Native `color` strings must move to `style={{ color: customColor }}`; `color` accepts `primary`, `secondary`, `tertiary` and `light`.
+
+`OverflowingTextWithTooltip.size` now means font size (`xxs` through `xxl`). The previously removed `small`/`large` height options are not aliases; replace the old `large` 16px height with a native style when needed.
+
+
Removed `MenuItem`, `MenuItemAvatar`, `MenuItemDraggable`, `MenuItemSuggestion` and `MenuPicker` from `twenty-ui/components/navigation` and the aggregate exports. Their props types and `MenuItemDraggableGripMode` are also removed. Applications must migrate these imports before upgrading.
| Removed API | Replacement |
diff --git a/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts b/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts
index 87e2cb037f0..1b225ff354a 100644
--- a/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts
+++ b/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts
@@ -1,6 +1,10 @@
import { type OverflowingTextWithTooltipProps } from '../src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps';
export const OVERFLOWING_TEXT_WITH_TOOLTIP_PROP_DESCRIPTIONS = {
+ size: 'Font size from the theme scale. Omitted values inherit; this does not set height.',
+ weight: 'Theme font weight. Omitted values inherit.',
+ color:
+ 'Semantic text color. Omitted values inherit; native style supports runtime colors.',
text: 'Caller-owned text or React content. Non-string content requires `tooltipContent`. URLs stay plain text.',
tooltipContent:
'Plain text displayed in the tooltip. Defaults to nonempty string `text`.',
diff --git a/packages/twenty-ui/docs/textPropDescriptions.ts b/packages/twenty-ui/docs/textPropDescriptions.ts
index 731ed8141f2..8f8258fd13f 100644
--- a/packages/twenty-ui/docs/textPropDescriptions.ts
+++ b/packages/twenty-ui/docs/textPropDescriptions.ts
@@ -1,6 +1,10 @@
import { type TextProps } from '../src/primitives/typography/Text/types/TextProps';
export const TEXT_PROP_DESCRIPTIONS = {
+ size: 'Font size from the theme scale. Omitted values inherit; this does not set height.',
+ weight: 'Theme font weight. Omitted values inherit.',
+ color:
+ 'Semantic text color. Omitted values inherit; native style supports runtime colors.',
truncate:
'Truncates one line with an ellipsis. Cannot be combined with `lineClamp`.',
lineClamp:
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 5bc47d9be67..b5d3d2f7736 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -2488,6 +2488,13 @@
"defaultValue": null,
"description": "Allows the tooltip even when the text is not truncated."
},
+ {
+ "name": "color",
+ "type": "\"light\" | \"primary\" | \"secondary\" | \"tertiary\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Semantic text color. Omitted values inherit; native style supports runtime colors."
+ },
{
"name": "isFocusable",
"type": "boolean",
@@ -2516,6 +2523,13 @@
"defaultValue": null,
"description": "Replaces the default div. Native props, styles, handlers and ref target the displayed text, not the popup."
},
+ {
+ "name": "size",
+ "type": "\"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\" | \"xxs\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Font size from the theme scale. Omitted values inherit; this does not set height."
+ },
{
"name": "text",
"type": "string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | null | undefined",
@@ -2550,6 +2564,13 @@
"required": false,
"defaultValue": null,
"description": "Single-line ellipsis by default. Set false to wrap. Cannot be combined with `lineClamp`."
+ },
+ {
+ "name": "weight",
+ "type": "\"medium\" | \"regular\" | \"semibold\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Theme font weight. Omitted values inherit."
}
]
},
@@ -10666,6 +10687,13 @@
"entryPoint": "twenty-ui/primitives/typography",
"slug": "typography/text",
"props": [
+ {
+ "name": "color",
+ "type": "\"light\" | \"primary\" | \"secondary\" | \"tertiary\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Semantic text color. Omitted values inherit; native style supports runtime colors."
+ },
{
"name": "lineClamp",
"type": "number",
@@ -10680,12 +10708,26 @@
"defaultValue": null,
"description": "Replaces the default div. Native props and the ref target the rendered text element."
},
+ {
+ "name": "size",
+ "type": "\"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\" | \"xxs\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Font size from the theme scale. Omitted values inherit; this does not set height."
+ },
{
"name": "truncate",
"type": "boolean",
"required": false,
"defaultValue": null,
"description": "Truncates one line with an ellipsis. Cannot be combined with `lineClamp`."
+ },
+ {
+ "name": "weight",
+ "type": "\"medium\" | \"regular\" | \"semibold\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Theme font weight. Omitted values inherit."
}
]
},
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/Dropdown.module.scss b/packages/twenty-ui/src/components/navigation/Dropdown/Dropdown.module.scss
index 656587cc086..01e8f1c8804 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/Dropdown.module.scss
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/Dropdown.module.scss
@@ -123,8 +123,6 @@
}
.status {
- color: var(--t-font-color-secondary);
- font-size: var(--t-font-size-sm);
padding: var(--t-spacing-2);
}
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__tests__/Dropdown.status.test.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__tests__/Dropdown.status.test.tsx
new file mode 100644
index 00000000000..bbbcc7272fa
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__tests__/Dropdown.status.test.tsx
@@ -0,0 +1,45 @@
+import { render, screen } from '@testing-library/react';
+import { createRef } from 'react';
+import { describe, expect, it } from 'vitest';
+
+import { Dropdown } from '../Dropdown';
+
+import styles from '../Dropdown.module.scss';
+
+describe('Dropdown status parts', () => {
+ it.each([
+ { name: 'empty', Component: Dropdown.Empty, expectedBusy: 'false' },
+ { name: 'loading', Component: Dropdown.Loading, expectedBusy: 'true' },
+ ])(
+ 'preserves the native $name adapter contract with shared typography',
+ ({ Component, expectedBusy }) => {
+ const ref = createRef<HTMLDivElement>();
+
+ render(
+ <Component
+ ref={ref}
+ color="rebeccapurple"
+ className="consumer-status"
+ style={{ marginTop: '7px' }}
+ role="note"
+ aria-live="off"
+ aria-busy="false"
+ >
+ Status content
+ </Component>,
+ );
+
+ const status = screen.getByRole('status');
+
+ expect(ref.current).toBe(status);
+ expect(status).toHaveAttribute('color', 'rebeccapurple');
+ expect(status).toHaveAttribute('aria-live', 'polite');
+ expect(status).toHaveAttribute('aria-busy', expectedBusy);
+ expect(status).toHaveAttribute('data-size', 'sm');
+ expect(status).toHaveAttribute('data-color', 'secondary');
+ expect(status).toHaveClass(styles.status, 'consumer-status');
+ expect(status.style.marginTop).toBe('7px');
+ expect(status).toHaveTextContent('Status content');
+ },
+ );
+});
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownEmpty.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownEmpty.tsx
index 1042b656297..2e80be9985d 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownEmpty.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownEmpty.tsx
@@ -6,11 +6,16 @@ import { Text } from '@ui/primitives/typography/Text/Text';
import styles from '../Dropdown.module.scss';
export const DropdownEmpty = ({
+ color: nativeColor,
className,
...props
}: ComponentPropsWithRef<'div'>) => (
<Text
+ // oxlint-disable-next-line react/jsx-props-no-spreading
{...props}
+ render={<div color={nativeColor} />}
+ size="sm"
+ color="secondary"
role="status"
aria-live="polite"
className={clsx(styles.status, className)}
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownLoading.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownLoading.tsx
index 3c523deae5c..c1c53af101d 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownLoading.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownLoading.tsx
@@ -6,11 +6,16 @@ import { Text } from '@ui/primitives/typography/Text/Text';
import styles from '../Dropdown.module.scss';
export const DropdownLoading = ({
+ color: nativeColor,
className,
...props
}: ComponentPropsWithRef<'div'>) => (
<Text
+ // oxlint-disable-next-line react/jsx-props-no-spreading
{...props}
+ render={<div color={nativeColor} />}
+ size="sm"
+ color="secondary"
role="status"
aria-live="polite"
aria-busy="true"
diff --git a/packages/twenty-ui/src/primitives/input/Field/internal/FieldLabel.module.scss b/packages/twenty-ui/src/primitives/input/Field/internal/FieldLabel.module.scss
index de60e7cfe68..6b323a50d78 100644
--- a/packages/twenty-ui/src/primitives/input/Field/internal/FieldLabel.module.scss
+++ b/packages/twenty-ui/src/primitives/input/Field/internal/FieldLabel.module.scss
@@ -1,7 +1,7 @@
.label {
color: var(--t-font-color-light);
display: block;
- font-size: 11px;
+ font-size: var(--t-font-size-xs);
font-weight: var(--t-font-weight-semi-bold);
margin-bottom: var(--t-spacing-1);
}
diff --git a/packages/twenty-ui/src/primitives/typography/Heading/types/HeadingProps.ts b/packages/twenty-ui/src/primitives/typography/Heading/types/HeadingProps.ts
index 6fe3cd8fe42..e4a5db884f5 100644
--- a/packages/twenty-ui/src/primitives/typography/Heading/types/HeadingProps.ts
+++ b/packages/twenty-ui/src/primitives/typography/Heading/types/HeadingProps.ts
@@ -1,7 +1,10 @@
import { type useRender } from '@base-ui/react/use-render';
+import { type TypographyColor } from '../../internal/TypographyColor';
+import { type TypographyFontSize } from '../../internal/TypographyFontSize';
+
export type HeadingProps = Omit<useRender.ComponentProps<'h2'>, 'color'> & {
level?: 1 | 2 | 3 | 4 | 5 | 6;
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
- color?: 'primary' | 'secondary' | 'tertiary';
+ size?: Exclude<TypographyFontSize, 'xxs'>;
+ color?: Exclude<TypographyColor, 'light'>;
};
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss
index a870d8a69f0..d563eebc7f5 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss
@@ -3,14 +3,20 @@
cursor: inherit;
font-family: inherit;
- font-size: inherit;
- font-weight: inherit;
height: auto;
max-width: 100%;
overflow-wrap: break-word;
text-decoration: inherit;
white-space: pre-wrap;
+ &:where(:not([data-size])) {
+ font-size: inherit;
+ }
+
+ &:where(:not([data-weight])) {
+ font-weight: inherit;
+ }
+
&[data-content-overflowing] {
cursor: pointer;
}
@@ -21,12 +27,18 @@
cursor: inherit;
font-family: inherit;
- font-size: inherit;
- font-weight: inherit;
height: auto;
max-width: 100%;
text-decoration: inherit;
+ &:where(:not([data-size])) {
+ font-size: inherit;
+ }
+
+ &:where(:not([data-weight])) {
+ font-weight: inherit;
+ }
+
&[data-content-overflowing] {
cursor: pointer;
}
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
index 8ee9cf43186..e713f4ece61 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
@@ -17,6 +17,9 @@ import styles from './OverflowingTextWithTooltip.module.scss';
export const OverflowingTextWithTooltip = memo(
function OverflowingTextWithTooltip({
text,
+ size,
+ weight,
+ color,
isTooltipMultiline,
truncate,
lineClamp,
@@ -97,6 +100,9 @@ export const OverflowingTextWithTooltip = memo(
},
props,
)}
+ size={size}
+ weight={weight}
+ color={color}
>
{text}
</Text>
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx
index 986de1bacb1..6c051e6d0c6 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx
@@ -1,5 +1,6 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { type MouseEvent } from 'react';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
import { Text } from '@ui/primitives/typography/Text/Text';
import { Button } from '@ui/primitives/input/Button/Button';
@@ -56,12 +57,20 @@ export const SingleLineOverflowing: Story = {
export const SingleLineNotOverflowing: Story = {
args: {
text: 'Short',
+ isFocusable: true,
+ tooltipDelay: 0,
},
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('overflow-text');
- await userEvent.hover(tooltip);
+ const text = canvas.getByTestId('overflow-text');
+ const body = within(canvasElement.ownerDocument.body);
+
+ await expect(text.scrollWidth).toBeLessThanOrEqual(text.clientWidth);
+ await userEvent.tab();
+ await expect(text).toHaveFocus();
+ await userEvent.hover(text);
+ await expect(body.queryByRole('tooltip')).not.toBeInTheDocument();
},
};
@@ -219,18 +228,28 @@ export const ExplicitLink: Story = {
),
style: { maxWidth: 200, display: 'block' },
tooltipDelay: 0,
+ title: 'Read documentation',
+ onFocus: fn(),
+ onPointerEnter: fn(),
+ onClick: fn((event: MouseEvent<HTMLElement>) => event.preventDefault()),
},
- play: async ({ canvasElement }) => {
+ play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);
const link = canvas.getByRole('link');
await expect(canvas.getAllByRole('link')).toHaveLength(1);
await expect(link.scrollWidth).toBeGreaterThan(link.clientWidth);
await userEvent.tab();
await expect(link).toHaveFocus();
+ await expect(args.onFocus).toHaveBeenCalledOnce();
+ await expect(link).toHaveAttribute('title', 'Read documentation');
const body = within(canvasElement.ownerDocument.body);
- await expect(await body.findByRole('tooltip')).toHaveTextContent(
- link.textContent ?? '',
- );
+ const popup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(popup).toHaveTextContent(link.textContent ?? '');
+ await userEvent.click(link);
+ await expect(args.onPointerEnter).toHaveBeenCalled();
+ await expect(args.onClick).toHaveBeenCalledOnce();
await userEvent.keyboard('{Escape}');
await waitFor(() =>
expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
@@ -243,21 +262,48 @@ export const Focusable: Story = {
decorators: [ComponentDecorator],
render: (args) => (
<>
- <OverflowingTextWithTooltip {...args} data-testid="overflow-text" />
+ <OverflowingTextWithTooltip
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ data-testid="overflow-text"
+ />
<Button>Next action</Button>
</>
),
- args: { text: longText, isFocusable: true, tooltipDelay: 0 },
+ args: {
+ text: 'Clickable label',
+ tooltipContent: 'Additional information',
+ alwaysShowTooltip: true,
+ isFocusable: true,
+ tooltipDelay: 0,
+ },
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const text = canvas.getByTestId('overflow-text');
+ const body = within(canvasElement.ownerDocument.body);
+
await userEvent.tab();
await expect(text).toHaveFocus();
- const body = within(canvasElement.ownerDocument.body);
- await expect(await body.findByRole('tooltip')).toHaveTextContent(longText);
+ const popup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(popup).toHaveTextContent('Additional information');
await userEvent.hover(text);
await userEvent.unhover(text);
- await waitFor(() => expect(body.getByRole('tooltip')).toBeVisible());
+ await waitFor(() => expect(popup).toBeVisible());
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ await expect(text).toHaveFocus();
+ await userEvent.click(text);
+ const reopenedPopup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(reopenedPopup).toBeVisible());
+ await expect(reopenedPopup).toHaveTextContent('Additional information');
+ await expect(text).toHaveFocus();
+ await userEvent.unhover(text);
+ await waitFor(() => expect(reopenedPopup).toBeVisible());
await userEvent.tab();
await expect(
canvas.getByRole('button', { name: 'Next action' }),
@@ -267,3 +313,59 @@ export const Focusable: Story = {
);
},
};
+
+export const Typography: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <Text
+ size="xxl"
+ weight="semibold"
+ color="secondary"
+ style={{ maxWidth: 220 }}
+ >
+ <OverflowingTextWithTooltip text="Inherited text" />
+ <OverflowingTextWithTooltip
+ text="Explicit typography with overflowing content"
+ size="lg"
+ weight="regular"
+ color="primary"
+ tooltipDelay={0}
+ isFocusable
+ />
+ </Text>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const inherited = canvas.getByText('Inherited text');
+ const explicit = canvas.getByText(
+ 'Explicit typography with overflowing content',
+ );
+ const inheritedStyle = getComputedStyle(inherited);
+ const explicitStyle = getComputedStyle(explicit);
+ const rootFontSize = Number.parseFloat(
+ getComputedStyle(canvasElement.ownerDocument.documentElement).fontSize,
+ );
+
+ await expect(Number.parseFloat(inheritedStyle.fontSize)).toBeCloseTo(
+ rootFontSize * 1.85,
+ 1,
+ );
+ await expect(inheritedStyle.fontWeight).toBe('600');
+ await expect(Number.parseFloat(explicitStyle.fontSize)).toBeCloseTo(
+ rootFontSize * 1.23,
+ 1,
+ );
+ await expect(explicitStyle.fontWeight).toBe('400');
+ await expect(explicit.scrollWidth).toBeGreaterThan(explicit.clientWidth);
+ await userEvent.hover(explicit);
+
+ const popup = await within(canvasElement.ownerDocument.body).findByRole(
+ 'tooltip',
+ );
+
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(
+ Number.parseFloat(getComputedStyle(popup).fontSize),
+ ).toBeCloseTo(rootFontSize * 0.92, 1);
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltipInteractions.stories.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltipInteractions.stories.tsx
new file mode 100644
index 00000000000..c76ffe6e66c
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltipInteractions.stories.tsx
@@ -0,0 +1,159 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { ComponentDecorator } from '@ui/testing';
+
+import { OverflowingTextWithTooltip } from '../OverflowingTextWithTooltip';
+
+const LONG_LABEL =
+ 'Quarterly account review and renewal preparation for the current workspace';
+
+const meta: Meta<typeof OverflowingTextWithTooltip> = {
+ title: 'UI/Surfaces/OverflowingTextWithTooltip/Interactions',
+ component: OverflowingTextWithTooltip,
+ tags: ['!autodocs'],
+ decorators: [ComponentDecorator],
+ args: { style: { maxWidth: 200 } },
+ render: (args) => (
+ <OverflowingTextWithTooltip
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ data-testid="overflow-text"
+ />
+ ),
+};
+
+export default meta;
+type Story = StoryObj<typeof OverflowingTextWithTooltip>;
+
+export const ExplicitChildLink: Story = {
+ args: {
+ text: (
+ <Text render={<a href="https://twenty.com" aria-label="Documentation" />}>
+ Documentation
+ </Text>
+ ),
+ tooltipContent: 'Open the documentation',
+ alwaysShowTooltip: true,
+ tooltipDelay: 0,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const text = canvas.getByTestId('overflow-text');
+ const link = canvas.getByRole('link', { name: 'Documentation' });
+ const body = within(canvasElement.ownerDocument.body);
+
+ await expect(text).not.toHaveAttribute('tabindex');
+ await userEvent.tab();
+ await expect(link).toHaveFocus();
+ const popup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(popup).toHaveTextContent('Open the documentation');
+ await userEvent.hover(link);
+ await userEvent.unhover(link);
+ await waitFor(() => expect(popup).toBeVisible());
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ await expect(link).toHaveFocus();
+ },
+};
+
+export const CallerTabIndex: Story = {
+ args: {
+ text: 'Keyboard label',
+ tabIndex: 0,
+ alwaysShowTooltip: true,
+ tooltipDelay: 0,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const text = canvas.getByTestId('overflow-text');
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.tab();
+ await expect(text).toHaveFocus();
+ const popup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(popup).toHaveTextContent('Keyboard label');
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ },
+};
+
+export const EmptyTooltipLabel: Story = {
+ args: {
+ text: <Text render={<span />}>Value</Text>,
+ tooltipContent: '',
+ alwaysShowTooltip: true,
+ isFocusable: true,
+ tooltipDelay: 0,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const text = canvas.getByTestId('overflow-text');
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.tab();
+ await expect(text).toHaveFocus();
+ await userEvent.hover(text);
+ await expect(body.queryByRole('tooltip')).not.toBeInTheDocument();
+ },
+};
+
+export const NestedTooltipPriority: Story = {
+ render: () => (
+ <Text
+ style={{
+ display: 'grid',
+ gridTemplateColumns: 'minmax(0, 1fr)',
+ gap: 'var(--t-spacing-2)',
+ width: 200,
+ }}
+ >
+ <Tooltip content="Field label" delay={0}>
+ <Text>
+ <OverflowingTextWithTooltip text="Short value" tooltipDelay={0} />
+ </Text>
+ </Tooltip>
+ <Tooltip content="Field label" delay={0}>
+ <Text>
+ <OverflowingTextWithTooltip text={LONG_LABEL} tooltipDelay={0} />
+ </Text>
+ </Tooltip>
+ </Text>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const shortValue = canvas.getByText('Short value');
+ const longValue = canvas.getByText(LONG_LABEL);
+ const body = within(canvasElement.ownerDocument.body);
+
+ await expect(shortValue.scrollWidth).toBeLessThanOrEqual(
+ shortValue.clientWidth,
+ );
+ await userEvent.hover(shortValue);
+ const parentPopup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(parentPopup).toBeVisible());
+ await expect(parentPopup).toHaveTextContent('Field label');
+ await userEvent.unhover(shortValue);
+ await waitFor(() =>
+ expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ await expect(longValue.scrollWidth).toBeGreaterThan(longValue.clientWidth);
+ await userEvent.hover(longValue);
+ const nestedPopup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(nestedPopup).toBeVisible());
+ await expect(nestedPopup).toHaveTextContent(LONG_LABEL);
+ await expect(body.getAllByRole('tooltip')).toHaveLength(1);
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowingTextTooltipModeProvider.stories.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowingTextTooltipModeProvider.stories.tsx
index 9edaea5ba6a..f6208db1c05 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowingTextTooltipModeProvider.stories.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowingTextTooltipModeProvider.stories.tsx
@@ -1,4 +1,8 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, fireEvent, userEvent, waitFor, within } from 'storybook/test';
+
+import { Button } from '@ui/primitives/input/Button/Button';
import {
OverflowingTextTooltipModeProvider,
@@ -37,3 +41,80 @@ type Story = StoryObj<typeof OverflowingTextTooltipModeProvider>;
export const Display: Story = {};
export const Disabled: Story = { args: { mode: 'disabled' } };
+
+export const DisabledInteractions: Story = {
+ args: { mode: 'disabled' },
+ render: ({ mode }) => (
+ <OverflowingTextTooltipModeProvider mode={mode}>
+ <Text style={{ maxWidth: 220 }}>
+ <OverflowingTextWithTooltip
+ text="Quarterly account review and renewal preparation"
+ alwaysShowTooltip
+ isFocusable
+ tooltipDelay={0}
+ />
+ </Text>
+ </OverflowingTextTooltipModeProvider>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const text = canvas.getByText(
+ 'Quarterly account review and renewal preparation',
+ );
+ const body = within(canvasElement.ownerDocument.body);
+
+ await expect(text.scrollWidth).toBeGreaterThan(text.clientWidth);
+ await userEvent.hover(text);
+ await userEvent.tab();
+ await expect(text).toHaveFocus();
+ await expect(body.queryByRole('tooltip')).not.toBeInTheDocument();
+ },
+};
+
+export const MeasureOnOpen: Story = {
+ args: { mode: 'measure-on-open' },
+ render: function Render({ mode }) {
+ const [text, setText] = useState('Short label');
+
+ return (
+ <OverflowingTextTooltipModeProvider mode={mode}>
+ <Text style={{ maxWidth: 220 }}>
+ <OverflowingTextWithTooltip text={text} tooltipDelay={0} />
+ <Button
+ onClick={() =>
+ setText('Quarterly account review and renewal preparation')
+ }
+ >
+ Expand label
+ </Button>
+ </Text>
+ </OverflowingTextTooltipModeProvider>
+ );
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const text = canvas.getByText('Short label');
+ const body = within(canvasElement.ownerDocument.body);
+
+ await expect(text.scrollWidth).toBeLessThanOrEqual(text.clientWidth);
+ await userEvent.hover(text);
+ await expect(body.queryByRole('tooltip')).not.toBeInTheDocument();
+ await userEvent.unhover(text);
+ await userEvent.click(canvas.getByRole('button', { name: 'Expand label' }));
+ await waitFor(() =>
+ expect(text.scrollWidth).toBeGreaterThan(text.clientWidth),
+ );
+ await expect(text).toHaveTextContent(
+ 'Quarterly account review and renewal preparation',
+ );
+ await expect(text).not.toHaveAttribute('data-content-overflowing');
+ await fireEvent.mouseEnter(text);
+ await fireEvent.mouseMove(text);
+ const popup = await body.findByRole('tooltip');
+
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(popup).toHaveTextContent(
+ 'Quarterly account review and renewal preparation',
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx
index 9a7a2dc9405..3f619e89f1b 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx
@@ -1,29 +1,13 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import { describe, expect, it, vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
import { createRef } from 'react';
-import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
-import styles from '../OverflowingTextWithTooltip.module.scss';
+import { describe, expect, it } from 'vitest';
-import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
import { OverflowingTextTooltipModeProvider } from '../OverflowingTextTooltipModeProvider';
import { OverflowingTextWithTooltip } from '../OverflowingTextWithTooltip';
-const setTextDimensions = ({
- element,
- clientWidth,
- scrollWidth,
-}: {
- element: HTMLElement;
- clientWidth: number;
- scrollWidth: number;
-}) => {
- Object.defineProperties(element, {
- clientWidth: { value: clientWidth },
- scrollWidth: { value: scrollWidth },
- });
-};
+import styles from '../OverflowingTextWithTooltip.module.scss';
runComponentConformance({
name: 'OverflowingTextWithTooltip',
@@ -33,6 +17,28 @@ runComponentConformance({
});
describe('OverflowingTextWithTooltip', () => {
+ it('forwards semantic typography to the displayed text without adding native attributes', () => {
+ render(
+ <OverflowingTextWithTooltip
+ text="Caption"
+ size="xs"
+ weight="semibold"
+ color="light"
+ render={<span />}
+ />,
+ );
+
+ const text = screen.getByText('Caption');
+
+ expect(text.tagName).toBe('SPAN');
+ expect(text).toHaveAttribute('data-size', 'xs');
+ expect(text).toHaveAttribute('data-weight', 'semibold');
+ expect(text).toHaveAttribute('data-color', 'light');
+ expect(text).not.toHaveAttribute('size');
+ expect(text).not.toHaveAttribute('weight');
+ expect(text).not.toHaveAttribute('color');
+ });
+
it('keeps URL strings plain inside a caller-provided anchor', () => {
render(
<a href="https://twenty.com">
@@ -44,236 +50,51 @@ describe('OverflowingTextWithTooltip', () => {
expect(screen.getByRole('link')).toHaveTextContent('https://twenty.com');
});
- it('preserves explicit child links and their focus without adding a tab stop', async () => {
- const user = userEvent.setup();
+ it('preserves explicit child links without adding a tab stop', () => {
render(
<OverflowingTextWithTooltip
text={<a href="https://twenty.com">Documentation</a>}
tooltipContent="Open the documentation"
alwaysShowTooltip
- tooltipDelay={0}
data-testid="text"
/>,
);
- const link = screen.getByRole('link', { name: 'Documentation' });
expect(screen.getByTestId('text')).not.toHaveAttribute('tabindex');
- await user.tab();
- expect(link).toHaveFocus();
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Open the documentation',
+ expect(screen.getByRole('link', { name: 'Documentation' })).toHaveAttribute(
+ 'href',
+ 'https://twenty.com',
);
- await user.hover(link);
- await user.unhover(link);
- expect(screen.getByRole('tooltip')).toBeVisible();
- await user.keyboard('{Escape}');
- await waitFor(() =>
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(),
- );
- expect(link).toHaveFocus();
});
- it('targets the rendered anchor with native props, ref and composed handlers', async () => {
- const user = userEvent.setup();
+ it('targets the rendered anchor with native props and ref', () => {
const ref = createRef<HTMLDivElement>();
- const onFocus = vi.fn();
- const onPointerEnter = vi.fn();
- const onClick = vi.fn((event) => event.preventDefault());
+
render(
<OverflowingTextWithTooltip
text="Documentation"
render={<a href="https://twenty.com" aria-label="Documentation" />}
ref={ref}
title="Read documentation"
- onFocus={onFocus}
- onPointerEnter={onPointerEnter}
- onClick={onClick}
- tooltipDelay={0}
/>,
);
const link = screen.getByRole('link', { name: 'Documentation' });
- setTextDimensions({ element: link, clientWidth: 80, scrollWidth: 160 });
+
expect(ref.current).toBe(link);
expect(link).toHaveAttribute('title', 'Read documentation');
- await user.tab();
- expect(onFocus).toHaveBeenCalledOnce();
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Documentation',
- );
- await user.click(link);
- expect(onPointerEnter).toHaveBeenCalled();
- expect(onClick).toHaveBeenCalledOnce();
- });
-
- it('uses caller tabIndex for focus even when the convenience tab stop is off', async () => {
- const user = userEvent.setup();
- render(
- <OverflowingTextWithTooltip
- text="Keyboard label"
- tabIndex={0}
- alwaysShowTooltip
- />,
- );
- const text = screen.getByText('Keyboard label');
- await user.tab();
- expect(text).toHaveFocus();
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Keyboard label',
- );
- });
-
- it('does not open without a nonempty tooltip label', async () => {
- const user = userEvent.setup();
- render(
- <OverflowingTextWithTooltip
- text={<span>Value</span>}
- tooltipContent=""
- alwaysShowTooltip
- isFocusable
- />,
- );
- await user.tab();
- await user.hover(screen.getByText('Value'));
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
- });
-
- it('lets a parent tooltip open when the nested text fits', async () => {
- const user = userEvent.setup();
-
- render(
- <Tooltip content="Field label" delay={0}>
- <div>
- <OverflowingTextWithTooltip text="Short value" tooltipDelay={0} />
- </div>
- </Tooltip>,
- );
-
- const text = screen.getByText('Short value');
-
- setTextDimensions({ element: text, clientWidth: 100, scrollWidth: 80 });
-
- await user.hover(text);
-
- expect(await screen.findByRole('tooltip')).toHaveTextContent('Field label');
- });
-
- it('gives the nested tooltip priority when its text is truncated', async () => {
- const user = userEvent.setup();
-
- render(
- <Tooltip content="Field label" delay={0}>
- <div>
- <OverflowingTextWithTooltip text="Truncated value" tooltipDelay={0} />
- </div>
- </Tooltip>,
- );
-
- const text = screen.getByText('Truncated value');
-
- setTextDimensions({ element: text, clientWidth: 80, scrollWidth: 160 });
-
- await user.hover(text);
-
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Truncated value',
- );
- expect(screen.getAllByRole('tooltip')).toHaveLength(1);
});
- it('opens only when the text is truncated without adding a layout wrapper', async () => {
- const user = userEvent.setup();
+ it('renders the displayed text without a layout wrapper', () => {
const { container } = render(
- <OverflowingTextWithTooltip text="Truncated label" tooltipDelay={0} />,
+ <OverflowingTextWithTooltip text="Truncated label" />,
);
- const text = screen.getByText('Truncated label');
-
- setTextDimensions({ element: text, clientWidth: 80, scrollWidth: 160 });
-
- expect(container.firstElementChild).toBe(text);
-
- await user.hover(text);
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Truncated label',
+ expect(container.firstElementChild).toBe(
+ screen.getByText('Truncated label'),
);
});
- it('keeps text that fits hidden on keyboard focus', async () => {
- const user = userEvent.setup();
-
- render(<OverflowingTextWithTooltip text="Short label" isFocusable />);
-
- const text = screen.getByText('Short label');
-
- setTextDimensions({ element: text, clientWidth: 100, scrollWidth: 80 });
-
- await user.tab();
-
- expect(text).toHaveFocus();
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
- });
-
- it('opens on focus and dismisses with Escape while retaining focus', async () => {
- const user = userEvent.setup();
-
- render(
- <OverflowingTextWithTooltip
- text="Short label"
- tooltipContent="Additional information"
- alwaysShowTooltip
- isFocusable
- />,
- );
-
- const text = screen.getByText('Short label');
-
- await user.tab();
-
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Additional information',
- );
-
- await user.keyboard('{Escape}');
-
- await waitFor(() => {
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
- });
- expect(text).toHaveFocus();
- });
-
- it('keeps the tooltip open while a clicked label retains focus', async () => {
- const user = userEvent.setup();
-
- render(
- <OverflowingTextWithTooltip
- text="Clickable label"
- alwaysShowTooltip
- isFocusable
- tooltipDelay={0}
- />,
- );
-
- const text = screen.getByText('Clickable label');
-
- await user.click(text);
-
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Clickable label',
- );
- expect(text).toHaveFocus();
-
- await user.unhover(text);
-
- expect(screen.getByRole('tooltip')).toBeVisible();
-
- await user.tab();
-
- await waitFor(() => {
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
- });
- });
-
it('lays out each value by its own direction', () => {
render(
<div dir="rtl">
@@ -289,9 +110,9 @@ describe('OverflowingTextWithTooltip', () => {
expect(screen.getByText('הטמעת CRM לאקמה')).toHaveAttribute('dir', 'auto');
});
- it('renders only the text when the tooltip mode is disabled', async () => {
- const user = userEvent.setup();
+ it('preserves the text element and ref when the tooltip mode is disabled', () => {
const ref = createRef<HTMLDivElement>();
+
render(
<OverflowingTextTooltipModeProvider mode="disabled">
<OverflowingTextWithTooltip
@@ -299,76 +120,11 @@ describe('OverflowingTextWithTooltip', () => {
ref={ref}
alwaysShowTooltip
isFocusable
- tooltipDelay={0}
/>
</OverflowingTextTooltipModeProvider>,
);
- const text = screen.getByText('Truncated label');
- expect(ref.current).toBe(text);
-
- await user.hover(text);
- await user.tab();
-
- expect(text).toHaveFocus();
+ expect(ref.current).toBe(screen.getByText('Truncated label'));
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
});
-
- it('opens for a truncated label entered without a pointerenter when measured on open', async () => {
- render(
- <OverflowingTextTooltipModeProvider mode="measure-on-open">
- <OverflowingTextWithTooltip text="Truncated label" tooltipDelay={0} />
- </OverflowingTextTooltipModeProvider>,
- );
-
- const text = screen.getByText('Truncated label');
- setTextDimensions({ element: text, clientWidth: 80, scrollWidth: 160 });
-
- fireEvent.mouseEnter(text);
- fireEvent.mouseMove(text);
-
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'Truncated label',
- );
- });
-
- it('stays closed for a label that fits when measured on open', async () => {
- const user = userEvent.setup();
- render(
- <OverflowingTextTooltipModeProvider mode="measure-on-open">
- <OverflowingTextWithTooltip text="Short label" tooltipDelay={0} />
- </OverflowingTextTooltipModeProvider>,
- );
-
- await user.hover(screen.getByText('Short label'));
-
- expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
- });
-
- it('measures a label that becomes truncated after mount when opening', async () => {
- const user = userEvent.setup();
- const { rerender } = render(
- <OverflowingTextTooltipModeProvider mode="measure-on-open">
- <OverflowingTextWithTooltip text="Label" tooltipDelay={0} />
- </OverflowingTextTooltipModeProvider>,
- );
-
- rerender(
- <OverflowingTextTooltipModeProvider mode="measure-on-open">
- <OverflowingTextWithTooltip
- text="A much longer label"
- tooltipDelay={0}
- />
- </OverflowingTextTooltipModeProvider>,
- );
-
- const text = screen.getByText('A much longer label');
- setTextDimensions({ element: text, clientWidth: 80, scrollWidth: 160 });
-
- await user.hover(text);
-
- expect(await screen.findByRole('tooltip')).toHaveTextContent(
- 'A much longer label',
- );
- });
});
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps.ts b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps.ts
index 1cc1ae97f68..ae6addce737 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps.ts
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps.ts
@@ -2,12 +2,14 @@ import { type useRender } from '@base-ui/react/use-render';
import { type ReactNode } from 'react';
import { type TooltipSide } from '@ui/primitives/surfaces/Tooltip/types/TooltipSide';
+import { type TextTypographyProps } from '@ui/primitives/typography/Text/internal/TextTypographyProps';
import { type TextTruncationProps } from '@ui/primitives/typography/Text/internal/TextTruncationProps';
export type OverflowingTextWithTooltipProps = Omit<
useRender.ComponentProps<'div'>,
- 'children'
+ 'children' | 'color'
> &
+ TextTypographyProps &
TextTruncationProps & {
isTooltipMultiline?: boolean;
tooltipDelay?: number;
diff --git a/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss b/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss
index a8448503b61..e7017efd1ea 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss
+++ b/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss
@@ -1,3 +1,61 @@
+.typography {
+ &:where([data-size='xxs']) {
+ font-size: var(--t-font-size-xxs);
+ }
+
+ &:where([data-size='xs']) {
+ font-size: var(--t-font-size-xs);
+ }
+
+ &:where([data-size='sm']) {
+ font-size: var(--t-font-size-sm);
+ }
+
+ &:where([data-size='md']) {
+ font-size: var(--t-font-size-md);
+ }
+
+ &:where([data-size='lg']) {
+ font-size: var(--t-font-size-lg);
+ }
+
+ &:where([data-size='xl']) {
+ font-size: var(--t-font-size-xl);
+ }
+
+ &:where([data-size='xxl']) {
+ font-size: var(--t-font-size-xxl);
+ }
+
+ &:where([data-weight='regular']) {
+ font-weight: var(--t-font-weight-regular);
+ }
+
+ &:where([data-weight='medium']) {
+ font-weight: var(--t-font-weight-medium);
+ }
+
+ &:where([data-weight='semibold']) {
+ font-weight: var(--t-font-weight-semi-bold);
+ }
+
+ &:where([data-color='primary']) {
+ color: var(--t-font-color-primary);
+ }
+
+ &:where([data-color='secondary']) {
+ color: var(--t-font-color-secondary);
+ }
+
+ &:where([data-color='tertiary']) {
+ color: var(--t-font-color-tertiary);
+ }
+
+ &:where([data-color='light']) {
+ color: var(--t-font-color-light);
+ }
+}
+
.truncate {
overflow: hidden;
text-overflow: ellipsis;
diff --git a/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss.d.ts b/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss.d.ts
index b734d2cebb5..fb2c1c7a1d2 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss.d.ts
+++ b/packages/twenty-ui/src/primitives/typography/Text/Text.module.scss.d.ts
@@ -1,4 +1,5 @@
declare const classNames: {
+ readonly typography: 'typography';
readonly truncate: 'truncate';
readonly lineClamp: 'lineClamp';
};
diff --git a/packages/twenty-ui/src/primitives/typography/Text/Text.tsx b/packages/twenty-ui/src/primitives/typography/Text/Text.tsx
index fd582db208e..9d92b83789f 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/Text.tsx
+++ b/packages/twenty-ui/src/primitives/typography/Text/Text.tsx
@@ -10,6 +10,9 @@ import styles from './Text.module.scss';
export const Text = ({
render,
+ size,
+ weight,
+ color,
truncate,
lineClamp,
className,
@@ -25,7 +28,11 @@ export const Text = ({
ref,
props: {
...props,
+ 'data-size': size,
+ 'data-weight': weight,
+ 'data-color': color,
className: clsx(
+ styles.typography,
truncate && styles.truncate,
shouldClamp && styles.lineClamp,
className,
diff --git a/packages/twenty-ui/src/primitives/typography/Text/__stories__/Text.stories.tsx b/packages/twenty-ui/src/primitives/typography/Text/__stories__/Text.stories.tsx
index d4301bc2d08..07d8c0b9421 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/__stories__/Text.stories.tsx
+++ b/packages/twenty-ui/src/primitives/typography/Text/__stories__/Text.stories.tsx
@@ -113,3 +113,82 @@ export const CatalogDark: CatalogStory<Story, typeof Text> = {
tags: ['!autodocs'],
globals: { colorScheme: 'dark' },
};
+
+const TEXT_SIZES = ['xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;
+
+export const TypographyCatalog: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <Text style={{ display: 'grid', gap: 'var(--t-spacing-2)' }}>
+ {TEXT_SIZES.map((size) => (
+ <Text key={size} size={size} color="primary">
+ {size} text
+ </Text>
+ ))}
+ <Text size="md" weight="regular" color="primary">
+ Regular body text
+ </Text>
+ <Text size="md" weight="medium" color="secondary">
+ Medium secondary text
+ </Text>
+ <Text size="md" weight="semibold" color="primary">
+ Semibold body text
+ </Text>
+ </Text>
+ ),
+};
+
+export const Typography: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <Text
+ role="group"
+ aria-label="Typography examples"
+ size="lg"
+ weight="medium"
+ color="secondary"
+ style={{ display: 'grid', gap: 'var(--t-spacing-2)' }}
+ >
+ <Text>Inherited typography</Text>
+ <Text size="xs" weight="semibold" color="primary">
+ Caption typography
+ </Text>
+ <Text color="secondary" style={{ color: 'var(--t-font-color-primary)' }}>
+ Runtime color
+ </Text>
+ </Text>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const parent = canvas.getByRole('group', { name: 'Typography examples' });
+ const inherited = canvas.getByText('Inherited typography');
+ const caption = canvas.getByText('Caption typography');
+ const runtime = canvas.getByText('Runtime color');
+ const parentStyle = getComputedStyle(parent);
+ const inheritedStyle = getComputedStyle(inherited);
+ const captionStyle = getComputedStyle(caption);
+ const runtimeStyle = getComputedStyle(runtime);
+ const rootFontSize = Number.parseFloat(
+ getComputedStyle(canvasElement.ownerDocument.documentElement).fontSize,
+ );
+
+ for (const property of [
+ 'fontSize',
+ 'fontWeight',
+ 'color',
+ 'fontFamily',
+ 'lineHeight',
+ ] as const) {
+ await expect(inheritedStyle[property]).toBe(parentStyle[property]);
+ }
+
+ await expect(Number.parseFloat(captionStyle.fontSize)).toBeCloseTo(
+ rootFontSize * 0.85,
+ 1,
+ );
+ await expect(captionStyle.fontWeight).toBe('600');
+ await expect(runtimeStyle.color).toBe(
+ runtimeStyle.getPropertyValue('--t-font-color-primary').trim(),
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx b/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx
index 0b6c3978a87..f05bdaa9cb8 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx
+++ b/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx
@@ -14,6 +14,40 @@ runComponentConformance({
});
describe('Text', () => {
+ it('preserves native typography without selecting a theme modifier', () => {
+ render(
+ <Text style={{ color: 'rebeccapurple', fontSize: '18px' }}>
+ Inherited
+ </Text>,
+ );
+
+ const text = screen.getByText('Inherited');
+
+ expect(text).not.toHaveAttribute('data-size');
+ expect(text).not.toHaveAttribute('data-weight');
+ expect(text).not.toHaveAttribute('data-color');
+ expect(text.style.color).toBe('rebeccapurple');
+ expect(text.style.fontSize).toBe('18px');
+ });
+
+ it('targets semantic typography at the rendered text element', () => {
+ render(
+ <Text size="xs" weight="semibold" color="light" render={<span />}>
+ Caption
+ </Text>,
+ );
+
+ const text = screen.getByText('Caption');
+
+ expect(text.tagName).toBe('SPAN');
+ expect(text).toHaveAttribute('data-size', 'xs');
+ expect(text).toHaveAttribute('data-weight', 'semibold');
+ expect(text).toHaveAttribute('data-color', 'light');
+ expect(text).not.toHaveAttribute('size');
+ expect(text).not.toHaveAttribute('weight');
+ expect(text).not.toHaveAttribute('color');
+ });
+
it('renders caller-owned semantic content without automatic links', () => {
render(
<Text render={<p />} truncate>
diff --git a/packages/twenty-ui/src/primitives/typography/Text/internal/TextTypographyProps.ts b/packages/twenty-ui/src/primitives/typography/Text/internal/TextTypographyProps.ts
new file mode 100644
index 00000000000..c4b6aa4f259
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Text/internal/TextTypographyProps.ts
@@ -0,0 +1,8 @@
+import { type TypographyColor } from '../../internal/TypographyColor';
+import { type TypographyFontSize } from '../../internal/TypographyFontSize';
+
+export type TextTypographyProps = {
+ size?: TypographyFontSize;
+ weight?: 'regular' | 'medium' | 'semibold';
+ color?: TypographyColor;
+};
diff --git a/packages/twenty-ui/src/primitives/typography/Text/types/TextProps.ts b/packages/twenty-ui/src/primitives/typography/Text/types/TextProps.ts
index 2430b38141f..ed059829f07 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/types/TextProps.ts
+++ b/packages/twenty-ui/src/primitives/typography/Text/types/TextProps.ts
@@ -1,5 +1,8 @@
import { type useRender } from '@base-ui/react/use-render';
+import { type TextTypographyProps } from '../internal/TextTypographyProps';
import { type TextTruncationProps } from '../internal/TextTruncationProps';
-export type TextProps = useRender.ComponentProps<'div'> & TextTruncationProps;
+export type TextProps = Omit<useRender.ComponentProps<'div'>, 'color'> &
+ TextTypographyProps &
+ TextTruncationProps;
diff --git a/packages/twenty-ui/src/primitives/typography/internal/Label/Label.module.scss b/packages/twenty-ui/src/primitives/typography/internal/Label/Label.module.scss
deleted file mode 100644
index 21a490a5fae..00000000000
--- a/packages/twenty-ui/src/primitives/typography/internal/Label/Label.module.scss
+++ /dev/null
@@ -1,12 +0,0 @@
-.label {
- color: var(--t-font-color-light);
- font-weight: var(--t-font-weight-semi-bold);
-}
-
-.default {
- font-size: 11px;
-}
-
-.small {
- font-size: 9px;
-}
diff --git a/packages/twenty-ui/src/primitives/typography/internal/Label/Label.module.scss.d.ts b/packages/twenty-ui/src/primitives/typography/internal/Label/Label.module.scss.d.ts
deleted file mode 100644
index 17dd1e5c592..00000000000
--- a/packages/twenty-ui/src/primitives/typography/internal/Label/Label.module.scss.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare const classNames: {
- readonly label: 'label';
- readonly default: 'default';
- readonly small: 'small';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/primitives/typography/internal/Label/Label.tsx b/packages/twenty-ui/src/primitives/typography/internal/Label/Label.tsx
deleted file mode 100644
index c9c6c71d65e..00000000000
--- a/packages/twenty-ui/src/primitives/typography/internal/Label/Label.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { clsx } from 'clsx';
-
-import styles from './Label.module.scss';
-
-export type LabelVariant = 'default' | 'small';
-
-type LabelProps = {
- variant?: LabelVariant;
- children?: React.ReactNode;
- className?: string;
-};
-
-export const Label = ({
- variant = 'default',
- children,
- className,
-}: LabelProps) => {
- return (
- <div className={clsx(styles.label, styles[variant], className)}>
- {children}
- </div>
- );
-};
diff --git a/packages/twenty-ui/src/primitives/typography/internal/Label/__stories__/Label.stories.tsx b/packages/twenty-ui/src/primitives/typography/internal/Label/__stories__/Label.stories.tsx
deleted file mode 100644
index 5e5693b32bb..00000000000
--- a/packages/twenty-ui/src/primitives/typography/internal/Label/__stories__/Label.stories.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-
-import { A11Y_DEFER_COLOR_CONTRAST } from '@ui/testing/a11yParameters';
-import { CatalogDecorator } from '@ui/testing/decorators/CatalogDecorator';
-import { ComponentDecorator } from '@ui/testing/decorators/ComponentDecorator';
-import { type CatalogStory } from '@ui/testing/types/CatalogStory';
-
-import {
- Label,
- type LabelVariant,
-} from '@ui/primitives/typography/internal/Label/Label';
-
-const meta: Meta<typeof Label> = {
- title: 'UI/Typography/Label',
- component: Label,
- decorators: [ComponentDecorator],
-};
-
-export default meta;
-
-type Story = StoryObj<typeof Label>;
-
-export const Default: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- decorators: [ComponentDecorator],
- args: {
- children: 'Label',
- },
-};
-
-export const Catalog: CatalogStory<Story, typeof Label> = {
- decorators: [CatalogDecorator],
- args: {
- children: 'Label',
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- catalog: {
- dimensions: [
- {
- name: 'Variant',
- values: ['default', 'small'] satisfies LabelVariant[],
- props: (variant: LabelVariant) => ({ variant }),
- },
- ],
- },
- },
-};
diff --git a/packages/twenty-ui/src/primitives/typography/internal/TypographyColor.ts b/packages/twenty-ui/src/primitives/typography/internal/TypographyColor.ts
new file mode 100644
index 00000000000..4baa5ad50ec
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/internal/TypographyColor.ts
@@ -0,0 +1,6 @@
+import { type ThemeType } from '@ui/theme';
+
+export type TypographyColor = keyof Pick<
+ ThemeType['font']['color'],
+ 'primary' | 'secondary' | 'tertiary' | 'light'
+>;
diff --git a/packages/twenty-ui/src/primitives/typography/internal/TypographyFontSize.ts b/packages/twenty-ui/src/primitives/typography/internal/TypographyFontSize.ts
new file mode 100644
index 00000000000..24e53d7afa7
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/internal/TypographyFontSize.ts
@@ -0,0 +1,3 @@
+import { type ThemeType } from '@ui/theme';
+
+export type TypographyFontSize = keyof ThemeType['font']['size'];