Skip to content

The open alternative to Salesforce, designed for AI.

Extract shared form field row (#28608)

Raphaël Bosie1e70d67a973
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.json
index 2ed1a7a8d32..ac040cae71a 100644
--- a/packages/twenty-docs/docs.json
+++ b/packages/twenty-docs/docs.json
@@ -656,6 +656,7 @@
"ui/components/input/country-select",
"ui/components/input/currency-picker",
"ui/components/input/phone-country-picker",
+ "ui/components/input/form-field-row",
"ui/components/input/image-input",
"ui/components/input/search-input",
"ui/components/input/number-stepper",
diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.json
index 529516a62bf..573da241eee 100644
--- a/packages/twenty-docs/navigation/base-structure.json
+++ b/packages/twenty-docs/navigation/base-structure.json
@@ -677,6 +677,7 @@
"ui/components/input/country-select",
"ui/components/input/currency-picker",
"ui/components/input/phone-country-picker",
+ "ui/components/input/form-field-row",
"ui/components/input/image-input",
"ui/components/input/search-input",
"ui/components/input/number-stepper",
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/form-field-row.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/form-field-row.mdx
new file mode 100644
index 00000000000..2acf1b3e5be
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/form-field-row.mdx
@@ -0,0 +1,64 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file
+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten
+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs
+ * |___/
+ *
+ * This file is generated from the documentation data in packages/twenty-ui/generated.
+ * To update it, edit the component prop types or design tokens in twenty-ui and run:
+ * npx nx generate:ui twenty-docs
+ */}
+
+<ParamField body="children" type="ReactNode" required>
+ Field content, such as plain inputs, recipient chips, selectors or toggles. The caller owns input labels, state and click-to-focus behavior.
+</ParamField>
+
+<ParamField body="className" type="string">
+ CSS class applied to the group root.
+</ParamField>
+
+<ParamField body="hasDivider" type="boolean" default="true">
+ Shows a decorative bottom divider. Set false on the final row when the surrounding surface supplies its own border.
+</ParamField>
+
+<ParamField body="isHoverable" type="boolean" default="false">
+ Enables a neutral hover background independently of click handlers. Keyboard focus remains on nested controls without changing the row background.
+</ParamField>
+
+<ParamField body="label" type="string">
+ Optional visible field label and default group name. Supply aria-label or aria-labelledby when the label is omitted. Label each nested input separately.
+</ParamField>
+
+<ParamField body="labelWidth" type="Width&lt;string | number&gt;" default="80">
+ Preferred label column width, capped at 40% of the row. Numbers use pixels; use the same width for aligned sibling rows.
+</ParamField>
+
+<ParamField body="onClick" type="MouseEventHandler&lt;HTMLDivElement&gt;">
+ Native group click handler. Providing a handler shows a pointer cursor; the caller guards nested-control and portaled events as needed.
+</ParamField>
+
+<ParamField body="ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref forwarded to the group root div.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+ Customizes the group root. Forward its props and ref.
+</ParamField>
+
+<ParamField body="startIcon" type="ReactNode">
+ Optional decorative icon before the label. The caller controls icon dimensions.
+</ParamField>
+
+<ParamField body="style" type="CSSProperties">
+ Inline styles applied to the group root.
+</ParamField>
+
+<ParamField body="trailing" type="ReactNode">
+ Optional trailing content. Nested controls retain their own keyboard focus and event behavior.
+</ParamField>
+
+<ParamField body="trailingProps" type="Omit&lt;DetailedHTMLProps&lt;HTMLAttributes&lt;HTMLDivElement&gt;, HTMLDivElement&gt;, &quot;children&quot;&gt;">
+ Native props, event handlers and ref applied to the trailing content wrapper. The wrapper is rendered only when trailing content is present; className is merged with the shared layout class.
+</ParamField>
diff --git a/packages/twenty-docs/ui/components/input/form-field-row.mdx b/packages/twenty-docs/ui/components/input/form-field-row.mdx
new file mode 100644
index 00000000000..96033bc2303
--- /dev/null
+++ b/packages/twenty-docs/ui/components/input/form-field-row.mdx
@@ -0,0 +1,62 @@
+---
+title: FormFieldRow
+description: Align a field label, content and trailing controls in a shared row.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+import FormFieldRowReference from '/snippets/ui/generated/components/input/form-field-row.mdx';
+
+`FormFieldRow` lays out a field label, optional decorative icon, field content and trailing controls. Use it for composer fields or other aligned field groups. Your application owns field values, validation, permissions and persistence.
+
+<StoryEmbed
+ storyId="ui-input-formfieldrow--display"
+ title="Form field row"
+ height={110}
+/>
+
+## Usage
+
+```tsx
+import { useState } from 'react';
+import { FormFieldRow, LightButton } from 'twenty-ui/components/input';
+import { Input } from 'twenty-ui/primitives/input';
+
+export const SubjectField = () => {
+ const [subject, setSubject] = useState('Project update');
+
+ return (
+ <FormFieldRow
+ label="Subject"
+ hasDivider={false}
+ trailing={
+ <LightButton size="sm" onClick={() => setSubject('')}>
+ Clear
+ </LightButton>
+ }
+ >
+ <Input
+ variant="plain"
+ aria-label="Subject"
+ value={subject}
+ onValueChange={setSubject}
+ />
+ </FormFieldRow>
+ );
+};
+```
+
+## Layout and labels
+
+`labelWidth` defaults to 80 pixels and accepts a CSS width. Use the same value on sibling rows to align their labels. The label column is capped at 40% of the row, and content can wrap in narrow layouts. `startIcon` is decorative; the caller supplies its dimensions. Set `hasDivider={false}` on a final row when the surrounding surface provides its border.
+
+The root is a group named by `label`. Supply `aria-label` or `aria-labelledby` when the visible label is omitted, and label each nested input separately. The row does not move focus or disable nested controls. Those controls retain their own keyboard behavior and focus styling.
+
+## Events and customization
+
+Native attributes, event handlers, `className`, `style`, `ref` and `render` apply to the group root. Forward supplied props and ref when replacing the root through `render`. An `onClick` handler shows a pointer cursor. The caller owns click-to-focus behavior and guards events from nested controls or portals when needed. `isHoverable` independently enables a neutral hover background.
+
+`trailingProps` applies native attributes, handlers and ref to the existing trailing wrapper. Its `className` is merged with the shared layout class. Use its `onClick` handler to stop a trailing action from triggering a row click handler. The wrapper exists only when `trailing` has renderable content.
+
+## Props
+
+<FormFieldRowReference />
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx
index 9ee61b18697..b1cb06bcb90 100644
--- a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx
+++ b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx
@@ -247,7 +247,7 @@ export const CalendarEventComposerFields = ({
{t`Add a meeting link`}
</StyledRowDescription>
</ComposerFieldRow>
- <ComposerFieldRow label={t`Description`}>
+ <ComposerFieldRow label={t`Description`} hasDivider={false}>
<TextArea
textAreaId="calendar-event-composer-description"
variant="transparent"
diff --git a/packages/twenty-front/src/modules/activities/components/ComposerFieldRow.tsx b/packages/twenty-front/src/modules/activities/components/ComposerFieldRow.tsx
index 3c21e848fdb..f2135714cf3 100644
--- a/packages/twenty-front/src/modules/activities/components/ComposerFieldRow.tsx
+++ b/packages/twenty-front/src/modules/activities/components/ComposerFieldRow.tsx
@@ -1,82 +1,25 @@
-import { styled } from '@linaria/react';
import { type MouseEvent, type MouseEventHandler, type ReactNode } from 'react';
-import { isDefined } from 'twenty-shared/utils';
import { doNotTranslate } from 'twenty-shared/i18n';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-import { COMPOSER_LABEL_MIN_WIDTH } from '@/activities/constants/ComposerLabelMinWidth';
-
-const ROW_MIN_HEIGHT = '40px';
+import { isDefined } from 'twenty-shared/utils';
+import { FormFieldRow } from 'twenty-ui/components/input';
const NESTED_CONTROL_SELECTOR = doNotTranslate(
'input, textarea, button, a[href], [role="button"]',
);
-const StyledContent = styled.div`
- align-items: center;
- display: flex;
- flex: 1;
- min-width: 0;
- padding: 0 ${themeCssVariables.spacing[2]};
-
- & :focus-visible {
- outline: none;
- }
-`;
-
-const StyledRow = styled.div<{ $clickable: boolean }>`
- align-items: center;
- border-bottom: 1px solid ${themeCssVariables.border.color.light};
- box-sizing: border-box;
- cursor: ${({ $clickable }) => ($clickable ? 'pointer' : 'default')};
- display: flex;
- gap: ${themeCssVariables.spacing[3]};
- min-height: ${ROW_MIN_HEIGHT};
- padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[1]}
- ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[3]};
- width: 100%;
-
- &:hover {
- background-color: ${({ $clickable }) =>
- $clickable
- ? themeCssVariables.background.transparent.lighter
- : 'transparent'};
- }
-
- &:has(${StyledContent} :focus-visible) {
- background-color: ${themeCssVariables.background.transparent.lighter};
- }
-
- &:last-of-type {
- border-bottom: none;
- }
-`;
-
-const StyledLabel = styled.span`
- color: ${themeCssVariables.font.color.tertiary};
- flex-shrink: 0;
- font-size: ${themeCssVariables.font.size.md};
- font-weight: ${themeCssVariables.font.weight.regular};
- min-width: ${COMPOSER_LABEL_MIN_WIDTH};
-`;
-
-const StyledTrailing = styled.div`
- align-items: center;
- display: flex;
-`;
-
type ComposerFieldRowProps = {
label: string;
children: ReactNode;
trailing?: ReactNode;
+ hasDivider?: boolean;
onClick?: MouseEventHandler<HTMLDivElement>;
};
-// The label is a plain span, so the row is named as a group to give assistive technology the field name.
export const ComposerFieldRow = ({
label,
children,
trailing,
+ hasDivider,
onClick,
}: ComposerFieldRowProps) => {
const handleClick = (event: MouseEvent<HTMLDivElement>) => {
@@ -98,19 +41,15 @@ export const ComposerFieldRow = ({
};
return (
- <StyledRow
- role="group"
- aria-label={label}
- $clickable={isDefined(onClick)}
+ <FormFieldRow
+ label={label}
+ hasDivider={hasDivider}
+ isHoverable={isDefined(onClick)}
onClick={isDefined(onClick) ? handleClick : undefined}
+ trailing={trailing}
+ trailingProps={{ onClick: (event) => event.stopPropagation() }}
>
- <StyledLabel aria-hidden="true">{label}</StyledLabel>
- <StyledContent>{children}</StyledContent>
- {isDefined(trailing) && (
- <StyledTrailing onClick={(event) => event.stopPropagation()}>
- {trailing}
- </StyledTrailing>
- )}
- </StyledRow>
+ {children}
+ </FormFieldRow>
);
};
diff --git a/packages/twenty-front/src/modules/activities/constants/ComposerLabelMinWidth.ts b/packages/twenty-front/src/modules/activities/constants/ComposerLabelMinWidth.ts
deleted file mode 100644
index 93bb10aa7b9..00000000000
--- a/packages/twenty-front/src/modules/activities/constants/ComposerLabelMinWidth.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const COMPOSER_LABEL_MIN_WIDTH = '80px';
diff --git a/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx b/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx
index f79e24e2155..5d0d7c33ebf 100644
--- a/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx
@@ -176,7 +176,7 @@ export const CampaignDetailsFields = ({
/>
</ComposerFieldRow>
)}
- <ComposerFieldRow label={t`Subject`}>
+ <ComposerFieldRow label={t`Subject`} hasDivider={false}>
<FormTextFieldInput
key={`subject-${detailsState.draftResyncKey}`}
ariaLabel={t`Subject`}
diff --git a/packages/twenty-front/src/modules/activities/emails/components/CampaignSentEnvelope.tsx b/packages/twenty-front/src/modules/activities/emails/components/CampaignSentEnvelope.tsx
index f54804910d3..ebece2b3452 100644
--- a/packages/twenty-front/src/modules/activities/emails/components/CampaignSentEnvelope.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/components/CampaignSentEnvelope.tsx
@@ -120,7 +120,10 @@ export const CampaignSentEnvelope = ({
)}
</ComposerFieldRow>
)}
- <ComposerFieldRow label={t`Subject`}>
+ <ComposerFieldRow
+ label={t`Subject`}
+ hasDivider={isNonEmptyString(scheduledSendTime)}
+ >
{isNonEmptyString(subject) ? (
<StyledValue>{subject}</StyledValue>
) : (
@@ -128,7 +131,7 @@ export const CampaignSentEnvelope = ({
)}
</ComposerFieldRow>
{isNonEmptyString(scheduledSendTime) && (
- <ComposerFieldRow label={t`Send at`}>
+ <ComposerFieldRow label={t`Send at`} hasDivider={false}>
<StyledValue>{scheduledSendTime}</StyledValue>
</ComposerFieldRow>
)}
diff --git a/packages/twenty-front/src/modules/activities/emails/components/EmailComposerFields.tsx b/packages/twenty-front/src/modules/activities/emails/components/EmailComposerFields.tsx
index 2791e955b9c..ffa074fa34b 100644
--- a/packages/twenty-front/src/modules/activities/emails/components/EmailComposerFields.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/components/EmailComposerFields.tsx
@@ -248,7 +248,7 @@ export const EmailComposerFields = ({
</ComposerFieldRow>
</>
)}
- <ComposerFieldRow label={t`Subject`}>
+ <ComposerFieldRow label={t`Subject`} hasDivider={false}>
<Input
variant="plain"
type="text"
diff --git a/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx b/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx
index 08f9e41ef2c..991f97acb97 100644
--- a/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx
@@ -94,6 +94,11 @@ const StyledInput = styled.input`
outline: none;
padding: 0;
+ &:focus-visible {
+ outline: 2px solid ${themeCssVariables.color.blue};
+ outline-offset: 1px;
+ }
+
&::placeholder {
${FORM_FIELD_PLACEHOLDER_STYLES}
}
diff --git a/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx b/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx
index 8a68b570d00..253b48845da 100644
--- a/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx
@@ -208,7 +208,12 @@ export const PastesAndSelectsChipsWithTheKeyboard: Story = {
const input = await canvas.findByRole('combobox', { name: 'To' });
const ccInput = canvas.getByRole('combobox', { name: 'Cc' });
- await userEvent.click(input);
+ await userEvent.tab();
+ expect(input).toHaveFocus();
+ expect(getComputedStyle(input).outlineStyle).not.toBe('none');
+ expect(
+ Number.parseFloat(getComputedStyle(input).outlineWidth),
+ ).toBeGreaterThan(0);
await userEvent.paste('Ada <[email protected]>; Grace <[email protected]>');
expect(canvas.getByText('Ada')).toBeVisible();
diff --git a/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/StatefulEmailRecipientsFieldInput.tsx b/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/StatefulEmailRecipientsFieldInput.tsx
index c55ce5e3120..5dde9350179 100644
--- a/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/StatefulEmailRecipientsFieldInput.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/StatefulEmailRecipientsFieldInput.tsx
@@ -48,7 +48,10 @@ export const StatefulEmailRecipientsFieldInput = ({
>
{(['to', 'cc'] as const).map((fieldId) => (
<div key={fieldId} role="group" aria-label={`${fieldId} recipients`}>
- <ComposerFieldRow label={fieldId === 'to' ? 'To' : 'Cc'}>
+ <ComposerFieldRow
+ label={fieldId === 'to' ? 'To' : 'Cc'}
+ hasDivider={false}
+ >
<EmailRecipientsFieldInput
fieldId={fieldId}
label={fieldId === 'to' ? 'To' : 'Cc'}
diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.ts
index 7aa18613b6c..97d247f46d4 100644
--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts
+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts
@@ -154,6 +154,7 @@ export const DOCUMENTATION_PATHS = {
UI_COMPONENTS_FEEDBACK_TOAST: '/ui/components/feedback/toast',
UI_COMPONENTS_INPUT_COUNTRY_SELECT: '/ui/components/input/country-select',
UI_COMPONENTS_INPUT_CURRENCY_PICKER: '/ui/components/input/currency-picker',
+ UI_COMPONENTS_INPUT_FORM_FIELD_ROW: '/ui/components/input/form-field-row',
UI_COMPONENTS_INPUT_ICON_BUTTON: '/ui/components/input/icon-button',
UI_COMPONENTS_INPUT_IMAGE_INPUT: '/ui/components/input/image-input',
UI_COMPONENTS_INPUT_LIGHT_BUTTON: '/ui/components/input/light-button',
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index bf0b5cc64c0..226ecd774d8 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -3,6 +3,7 @@ import { CHECKBOX_PROP_DESCRIPTIONS } from './checkboxPropDescriptions';
import { SWITCH_PROP_DESCRIPTIONS } from './switchPropDescriptions';
import { TEXTAREA_PROP_DESCRIPTIONS } from './textareaPropDescriptions';
import { INPUT_GROUP_PROP_DESCRIPTIONS } from './inputGroupPropDescriptions';
+import { FORM_FIELD_ROW_PROP_DESCRIPTIONS } from './formFieldRowPropDescriptions';
import { INPUT_PROP_DESCRIPTIONS } from './inputPropDescriptions';
import { COUNTRY_SELECT_PROP_DESCRIPTIONS } from './countrySelectPropDescriptions';
import { COUNTRY_SELECT_PART_PROP_DESCRIPTIONS } from './countrySelectPartPropDescriptions';
@@ -1019,6 +1020,18 @@ export const DOCUMENTED_COMPONENTS = [
slug: 'components/feedback/toaster',
propDescriptions: TOASTER_PROP_DESCRIPTIONS,
},
+ {
+ name: 'FormFieldRow',
+ source: 'components/input/FormFieldRow/FormFieldRow.tsx',
+ entryPoint: 'twenty-ui/components/input',
+ slug: 'components/input/form-field-row',
+ propDescriptions: FORM_FIELD_ROW_PROP_DESCRIPTIONS,
+ propDefaults: {
+ labelWidth: '80',
+ isHoverable: 'false',
+ hasDivider: 'true',
+ },
+ },
{
name: 'ImageInput',
source: 'components/input/ImageInput/ImageInput.tsx',
diff --git a/packages/twenty-ui/docs/formFieldRowPropDescriptions.ts b/packages/twenty-ui/docs/formFieldRowPropDescriptions.ts
new file mode 100644
index 00000000000..4375cf37111
--- /dev/null
+++ b/packages/twenty-ui/docs/formFieldRowPropDescriptions.ts
@@ -0,0 +1,28 @@
+import { type ComponentProps } from 'react';
+
+import { type FormFieldRow } from '../src/components/input/FormFieldRow/FormFieldRow';
+
+export const FORM_FIELD_ROW_PROP_DESCRIPTIONS = {
+ label:
+ 'Optional visible field label and default group name. Supply aria-label or aria-labelledby when the label is omitted. Label each nested input separately.',
+ startIcon:
+ 'Optional decorative icon before the label. The caller controls icon dimensions.',
+ trailing:
+ 'Optional trailing content. Nested controls retain their own keyboard focus and event behavior.',
+ trailingProps:
+ 'Native props, event handlers and ref applied to the trailing content wrapper. The wrapper is rendered only when trailing content is present; className is merged with the shared layout class.',
+ children:
+ 'Field content, such as plain inputs, recipient chips, selectors or toggles. The caller owns input labels, state and click-to-focus behavior.',
+ onClick:
+ 'Native group click handler. Providing a handler shows a pointer cursor; the caller guards nested-control and portaled events as needed.',
+ labelWidth:
+ 'Preferred label column width, capped at 40% of the row. Numbers use pixels; use the same width for aligned sibling rows.',
+ isHoverable:
+ 'Enables a neutral hover background independently of click handlers. Keyboard focus remains on nested controls without changing the row background.',
+ hasDivider:
+ 'Shows a decorative bottom divider. Set false on the final row when the surrounding surface supplies its own border.',
+ className: 'CSS class applied to the group root.',
+ style: 'Inline styles applied to the group root.',
+ ref: 'Ref forwarded to the group root div.',
+ render: 'Customizes the group root. Forward its props and ref.',
+} satisfies Partial<Record<keyof ComponentProps<typeof FormFieldRow>, string>>;
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index 7b43d17629c..d08b3dbd2eb 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -56,6 +56,7 @@
"CurrencyPicker",
"DetailsRow",
"Dropdown",
+ "FormFieldRow",
"IconButton",
"ImageInput",
"InlineBanner",
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 66f4deafbfb..9cb0ab562d8 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -92,6 +92,7 @@
"values": {
"CountrySelect": "components/input/CountrySelect/CountrySelect",
"CurrencyPicker": "components/input/CurrencyPicker/CurrencyPicker",
+ "FormFieldRow": "components/input/FormFieldRow/FormFieldRow",
"IconButton": "components/input/IconButton/IconButton",
"ImageInput": "components/input/ImageInput/ImageInput",
"LightButton": "components/input/LightButton/LightButton",
@@ -117,6 +118,7 @@
"CurrencyPickerRootProps": "components/input/CurrencyPicker/types/CurrencyPickerRootProps",
"CurrencyPickerState": "components/input/CurrencyPicker/types/CurrencyPickerState",
"CurrencyPickerTriggerProps": "components/input/CurrencyPicker/types/CurrencyPickerTriggerProps",
+ "FormFieldRowProps": "components/input/FormFieldRow/types/FormFieldRowProps",
"IconButtonProps": "components/input/IconButton/types/IconButtonProps",
"IconButtonSize": "components/input/IconButton/types/IconButtonSize",
"ImageInputProps": "components/input/ImageInput/types/ImageInputProps",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 679dec31135..fa750a2d0e1 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -14615,6 +14615,104 @@
}
]
},
+ {
+ "name": "FormFieldRow",
+ "entryPoint": "twenty-ui/components/input",
+ "slug": "components/input/form-field-row",
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": true,
+ "defaultValue": null,
+ "description": "Field content, such as plain inputs, recipient chips, selectors or toggles. The caller owns input labels, state and click-to-focus behavior."
+ },
+ {
+ "name": "className",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the group root."
+ },
+ {
+ "name": "hasDivider",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Shows a decorative bottom divider. Set false on the final row when the surrounding surface supplies its own border."
+ },
+ {
+ "name": "isHoverable",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Enables a neutral hover background independently of click handlers. Keyboard focus remains on nested controls without changing the row background."
+ },
+ {
+ "name": "label",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional visible field label and default group name. Supply aria-label or aria-labelledby when the label is omitted. Label each nested input separately."
+ },
+ {
+ "name": "labelWidth",
+ "type": "Width<string | number>",
+ "required": false,
+ "defaultValue": "80",
+ "description": "Preferred label column width, capped at 40% of the row. Numbers use pixels; use the same width for aligned sibling rows."
+ },
+ {
+ "name": "onClick",
+ "type": "MouseEventHandler<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Native group click handler. Providing a handler shows a pointer cursor; the caller guards nested-control and portaled events as needed."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref forwarded to the group root div."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Customizes the group root. Forward its props and ref."
+ },
+ {
+ "name": "startIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional decorative icon before the label. The caller controls icon dimensions."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties",
+ "required": false,
+ "defaultValue": null,
+ "description": "Inline styles applied to the group root."
+ },
+ {
+ "name": "trailing",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional trailing content. Nested controls retain their own keyboard focus and event behavior."
+ },
+ {
+ "name": "trailingProps",
+ "type": "Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, \"children\">",
+ "required": false,
+ "defaultValue": null,
+ "description": "Native props, event handlers and ref applied to the trailing content wrapper. The wrapper is rendered only when trailing content is present; className is merged with the shared layout class."
+ }
+ ]
+ },
{
"name": "ImageInput",
"entryPoint": "twenty-ui/components/input",
diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.module.scss b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.module.scss
new file mode 100644
index 00000000000..faf3b1707ea
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.module.scss
@@ -0,0 +1,64 @@
+.root {
+ display: flex;
+ flex-direction: column;
+ inline-size: 100%;
+ min-block-size: 40px;
+ min-inline-size: 0;
+
+ &[data-clickable] {
+ cursor: pointer;
+ }
+
+ @include hover-capable {
+ &[data-hoverable]:hover {
+ background-color: var(--t-background-transparent-lighter);
+ }
+ }
+}
+
+.surface {
+ align-items: center;
+ box-sizing: border-box;
+ display: flex;
+ flex: 1;
+ gap: var(--t-spacing-3);
+ min-inline-size: 0;
+ padding-block: var(--t-spacing-1);
+ padding-inline: var(--t-spacing-3) var(--t-spacing-1);
+}
+
+.icon {
+ align-items: center;
+ color: var(--t-font-color-tertiary);
+ display: flex;
+ flex-shrink: 0;
+}
+
+.label {
+ flex-shrink: 0;
+ inline-size: var(--form-field-row-label-width);
+ max-inline-size: 40%;
+ overflow-wrap: anywhere;
+}
+
+.content {
+ align-items: center;
+ display: flex;
+ flex: 1;
+ flex-wrap: wrap;
+ gap: var(--t-spacing-1);
+ min-inline-size: 0;
+ overflow-wrap: anywhere;
+ padding-inline: var(--t-spacing-2);
+}
+
+.trailing {
+ align-items: center;
+ display: flex;
+ flex-shrink: 0;
+ gap: var(--t-spacing-1);
+}
+
+.divider {
+ background-color: var(--t-border-color-light);
+}
diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.tsx b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.tsx
new file mode 100644
index 00000000000..daf6722f189
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.tsx
@@ -0,0 +1,87 @@
+import { useRender } from '@base-ui/react/use-render';
+import { isNumber } from '@sniptt/guards';
+import { clsx } from 'clsx';
+import { type CSSProperties } from 'react';
+
+import { Separator } from '@ui/primitives/layout/Separator/Separator';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import styles from './FormFieldRow.module.scss';
+import { type FormFieldRowProps } from './types/FormFieldRowProps';
+
+export const FormFieldRow = ({
+ label,
+ startIcon,
+ trailing,
+ trailingProps,
+ children,
+ labelWidth = 80,
+ isHoverable = false,
+ hasDivider = true,
+ render,
+ ref,
+ className,
+ style,
+ ...props
+}: FormFieldRowProps) => {
+ const rowStyle: CSSProperties & {
+ '--form-field-row-label-width': string;
+ } = {
+ '--form-field-row-label-width': isNumber(labelWidth)
+ ? `${labelWidth}px`
+ : labelWidth,
+ ...style,
+ };
+
+ return useRender({
+ render,
+ ref,
+ props: {
+ role: 'group',
+ 'aria-label': label,
+ ...props,
+ 'data-clickable': isDefined(props.onClick) || undefined,
+ 'data-hoverable': isHoverable || undefined,
+ className: clsx(styles.root, className),
+ style: rowStyle,
+ children: (
+ <>
+ <div className={styles.surface}>
+ {isRenderableSlot(startIcon) && (
+ <span className={styles.icon} aria-hidden="true">
+ {startIcon}
+ </span>
+ )}
+ {isRenderableSlot(label) && (
+ <Text
+ render={<span />}
+ className={styles.label}
+ size="md"
+ weight="regular"
+ color="tertiary"
+ aria-hidden="true"
+ >
+ {label}
+ </Text>
+ )}
+ <div className={styles.content}>{children}</div>
+ {isRenderableSlot(trailing) && (
+ <div
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...trailingProps}
+ className={clsx(styles.trailing, trailingProps?.className)}
+ >
+ {trailing}
+ </div>
+ )}
+ </div>
+ {hasDivider && (
+ <Separator className={styles.divider} aria-hidden="true" />
+ )}
+ </>
+ ),
+ },
+ });
+};
diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/__stories__/FormFieldRow.stories.tsx b/packages/twenty-ui/src/components/input/FormFieldRow/__stories__/FormFieldRow.stories.tsx
new file mode 100644
index 00000000000..8ac028cde3c
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/FormFieldRow/__stories__/FormFieldRow.stories.tsx
@@ -0,0 +1,290 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+
+import { LightButton } from '@ui/components/input/LightButton/LightButton';
+import { IconCalendarEvent, IconMail } from '@ui/icon';
+import { Chip } from '@ui/primitives/data-display/Chip/Chip';
+import { Input } from '@ui/primitives/input/Input/Input';
+import { Select } from '@ui/primitives/input/Select/Select';
+import { Switch } from '@ui/primitives/input/Switch/Switch';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+
+import { FormFieldRow } from '../FormFieldRow';
+
+const handleShowCcBcc = fn();
+const handleFullDayChange = fn();
+const handleClearSubject = fn();
+
+const meta: Meta<typeof FormFieldRow> = {
+ id: 'ui-input-formfieldrow',
+ title: 'UI/Components/Input/FormFieldRow',
+ component: FormFieldRow,
+ decorators: [ComponentDecorator],
+ parameters: {
+ container: { width: 520 },
+ a11y: A11Y_DEFER_COLOR_CONTRAST,
+ },
+ args: {
+ label: 'Subject',
+ children: (
+ <Input
+ variant="plain"
+ aria-label="Subject"
+ defaultValue="Project update"
+ />
+ ),
+ },
+ argTypes: {
+ startIcon: { control: false },
+ trailing: { control: false },
+ children: { control: false },
+ },
+};
+
+export default meta;
+
+type Story = StoryObj<typeof FormFieldRow>;
+
+export const Display: Story = {};
+
+export const Clickable: Story = {
+ args: {
+ onClick: fn(),
+ trailing: <LightButton onClick={handleClearSubject}>Clear</LightButton>,
+ trailingProps: {
+ className: 'subject-field-actions',
+ onClick: (event) => event.stopPropagation(),
+ },
+ },
+ play: async ({ args, canvasElement }) => {
+ const canvas = within(canvasElement);
+ const group = canvas.getByRole('group', { name: 'Subject' });
+ const action = canvas.getByRole('button', { name: 'Clear' });
+
+ await expect(getComputedStyle(group).cursor).toBe('pointer');
+ await expect(action.closest('.subject-field-actions')).toBeInTheDocument();
+ await userEvent.click(action);
+ await expect(handleClearSubject).toHaveBeenCalledOnce();
+ await expect(args.onClick).not.toHaveBeenCalled();
+ await userEvent.click(canvas.getByRole('textbox', { name: 'Subject' }));
+ await expect(args.onClick).toHaveBeenCalledOnce();
+ },
+};
+
+export const EmailFields: Story = {
+ render: (args) => (
+ <>
+ <FormFieldRow
+ label="To"
+ dir={args.dir}
+ startIcon={<IconMail size={16} />}
+ trailing={
+ <LightButton size="sm" onClick={handleShowCcBcc}>
+ Cc/Bcc
+ </LightButton>
+ }
+ >
+ <Chip>Jordan Lee</Chip>
+ <Input
+ aria-label="Recipient address"
+ variant="plain"
+ placeholder="Add recipient"
+ style={{ flex: '1 1 100px' }}
+ />
+ </FormFieldRow>
+ <FormFieldRow
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ hasDivider={false}
+ />
+ </>
+ ),
+};
+
+export const CalendarFields: Story = {
+ render: () => (
+ <>
+ <FormFieldRow
+ label="Calendar"
+ startIcon={<IconCalendarEvent size={16} />}
+ >
+ <Select.Root
+ defaultValue="work"
+ items={[
+ { value: 'work', label: 'Work' },
+ { value: 'personal', label: 'Personal' },
+ ]}
+ >
+ <Select.Trigger aria-label="Calendar">
+ <Select.Value />
+ <Select.Icon />
+ </Select.Trigger>
+ <Select.Portal>
+ <Select.Positioner>
+ <Select.Popup>
+ <Select.Item value="work">
+ <Select.ItemText>Work</Select.ItemText>
+ <Select.ItemIndicator />
+ </Select.Item>
+ <Select.Item value="personal">
+ <Select.ItemText>Personal</Select.ItemText>
+ <Select.ItemIndicator />
+ </Select.Item>
+ </Select.Popup>
+ </Select.Positioner>
+ </Select.Portal>
+ </Select.Root>
+ </FormFieldRow>
+ <FormFieldRow
+ label="All day"
+ hasDivider={false}
+ trailing={
+ <Switch aria-label="All day" onCheckedChange={handleFullDayChange} />
+ }
+ >
+ <Text size="md" color="secondary">
+ Use dates without a time
+ </Text>
+ </FormFieldRow>
+ </>
+ ),
+};
+
+export const KeyboardFocus: Story = {
+ ...EmailFields,
+ tags: ['!autodocs'],
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const recipient = canvas.getByRole('textbox', {
+ name: 'Recipient address',
+ });
+ const action = canvas.getByRole('button', { name: 'Cc/Bcc' });
+ const subject = canvas.getByRole('textbox', { name: 'Subject' });
+ const group = canvas.getByRole('group', { name: 'To' });
+ const neutralBackground = getComputedStyle(group).backgroundColor;
+
+ for (const control of [recipient, action, subject]) {
+ await userEvent.tab();
+ await expect(control).toHaveFocus();
+ await expect(getComputedStyle(control).outlineStyle).not.toBe('none');
+ await expect(
+ Number.parseFloat(getComputedStyle(control).outlineWidth),
+ ).toBeGreaterThan(0);
+ await expect(getComputedStyle(group).backgroundColor).toBe(
+ neutralBackground,
+ );
+ }
+
+ await userEvent.tab({ shift: true });
+ await userEvent.keyboard('{Enter}');
+ await expect(handleShowCcBcc).toHaveBeenCalledOnce();
+ },
+};
+
+export const CalendarKeyboard: Story = {
+ ...CalendarFields,
+ tags: ['!autodocs'],
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const selector = canvas.getByRole('combobox', { name: 'Calendar' });
+ const toggle = canvas.getByRole('switch', { name: 'All day' });
+ const neutralBorder = getComputedStyle(selector).borderColor;
+
+ await userEvent.tab();
+ await expect(selector).toHaveFocus();
+ await expect(getComputedStyle(selector).borderColor).not.toBe(
+ neutralBorder,
+ );
+ await userEvent.keyboard('{Enter}');
+ const body = within(canvasElement.ownerDocument.body);
+ const workOption = await body.findByRole('option', { name: 'Work' });
+
+ await waitFor(() => expect(workOption).toBeVisible());
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(workOption).not.toBeVisible());
+ await expect(selector).toHaveFocus();
+ await userEvent.tab();
+ await expect(toggle).toHaveFocus();
+ await expect(getComputedStyle(toggle).outlineStyle).not.toBe('none');
+ await userEvent.keyboard(' ');
+ await expect(toggle).toBeChecked();
+ await expect(handleFullDayChange).toHaveBeenCalledOnce();
+ },
+};
+
+export const ExplicitHover: Story = {
+ parameters: { pseudo: { hover: ['.static-row', '.hoverable-row'] } },
+ render: () => (
+ <>
+ <FormFieldRow label="Static" className="static-row">
+ <Input variant="plain" aria-label="Static" />
+ </FormFieldRow>
+ <FormFieldRow
+ label="Hoverable"
+ className="hoverable-row"
+ isHoverable
+ hasDivider={false}
+ >
+ <Input variant="plain" aria-label="Hoverable" />
+ </FormFieldRow>
+ </>
+ ),
+};
+
+export const NarrowLayout: Story = {
+ parameters: { container: { width: 280 } },
+ render: () => (
+ <FormFieldRow
+ label="Primary recipients"
+ labelWidth={120}
+ startIcon={<IconMail size={16} />}
+ >
+ <Chip>Jordan Lee</Chip>
+ <Chip>Alex Morgan</Chip>
+ <Text>[email protected]</Text>
+ </FormFieldRow>
+ ),
+ play: async ({ canvasElement }) => {
+ const group = within(canvasElement).getByRole('group', {
+ name: 'Primary recipients',
+ });
+
+ await expect(group).toBeVisible();
+ await expect(group.scrollWidth).toBeLessThanOrEqual(group.clientWidth);
+ },
+};
+
+export const WithoutLabel: Story = {
+ args: { label: undefined, 'aria-label': 'Subject field' },
+};
+
+export const Disabled: Story = {
+ args: {
+ children: (
+ <Input
+ variant="plain"
+ aria-label="Subject"
+ defaultValue="Project update"
+ disabled
+ />
+ ),
+ trailing: <LightButton disabled>Clear</LightButton>,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(
+ canvas.getByRole('textbox', { name: 'Subject' }),
+ ).toBeDisabled();
+ await expect(canvas.getByRole('button', { name: 'Clear' })).toBeDisabled();
+ },
+};
+
+export const RightToLeft: Story = { ...EmailFields, args: { dir: 'rtl' } };
+
+export const Dark: Story = {
+ ...EmailFields,
+ globals: { colorScheme: 'dark' },
+ tags: ['!autodocs'],
+};
diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/__tests__/FormFieldRow.test.tsx b/packages/twenty-ui/src/components/input/FormFieldRow/__tests__/FormFieldRow.test.tsx
new file mode 100644
index 00000000000..e9a52dc7984
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/FormFieldRow/__tests__/FormFieldRow.test.tsx
@@ -0,0 +1,50 @@
+import { render, screen, within } from '@testing-library/react';
+import { expect, it } from 'vitest';
+
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { Input } from '@ui/primitives/input/Input/Input';
+
+import { FormFieldRow } from '../FormFieldRow';
+
+runComponentConformance({
+ name: 'FormFieldRow',
+ element: <FormFieldRow label="Subject">Project update</FormFieldRow>,
+ refInstanceOf: HTMLDivElement,
+ renderPropTagName: 'div',
+});
+
+it('names the group without relabelling its nested controls or announcing decoration', () => {
+ render(
+ <FormFieldRow
+ label="To"
+ startIcon={<svg role="img" aria-label="Internal artwork" />}
+ trailing={<Button>Cc/Bcc</Button>}
+ >
+ <Input aria-label="Recipient address" variant="plain" />
+ </FormFieldRow>,
+ );
+
+ const group = screen.getByRole('group', { name: 'To' });
+
+ expect(
+ within(group).getByRole('textbox', { name: 'Recipient address' }),
+ ).toBeInTheDocument();
+ expect(
+ within(group).getByRole('button', { name: 'Cc/Bcc' }),
+ ).toBeInTheDocument();
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
+ expect(screen.queryByRole('separator')).not.toBeInTheDocument();
+});
+
+it('accepts an external group name without a visible label', () => {
+ render(
+ <FormFieldRow aria-labelledby="event-options-label" hasDivider={false}>
+ <span id="event-options-label">Event options</span>
+ </FormFieldRow>,
+ );
+
+ expect(
+ screen.getByRole('group', { name: 'Event options' }),
+ ).toBeInTheDocument();
+});
diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/types/FormFieldRowProps.ts b/packages/twenty-ui/src/components/input/FormFieldRow/types/FormFieldRowProps.ts
new file mode 100644
index 00000000000..0a141b2603e
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/FormFieldRow/types/FormFieldRowProps.ts
@@ -0,0 +1,16 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ComponentProps, type CSSProperties, type ReactNode } from 'react';
+
+export type FormFieldRowProps = Omit<
+ useRender.ComponentProps<'div'>,
+ 'children'
+> & {
+ label?: string;
+ startIcon?: ReactNode;
+ trailing?: ReactNode;
+ trailingProps?: Omit<ComponentProps<'div'>, 'children'>;
+ children: ReactNode;
+ labelWidth?: CSSProperties['width'];
+ isHoverable?: boolean;
+ hasDivider?: boolean;
+};
diff --git a/packages/twenty-ui/src/components/input/index.ts b/packages/twenty-ui/src/components/input/index.ts
index 32657fa137c..dded60d27ce 100644
--- a/packages/twenty-ui/src/components/input/index.ts
+++ b/packages/twenty-ui/src/components/input/index.ts
@@ -22,6 +22,8 @@ export type { CurrencyPickerProps } from './CurrencyPicker/types/CurrencyPickerP
export type { CurrencyPickerRootProps } from './CurrencyPicker/types/CurrencyPickerRootProps';
export type { CurrencyPickerState } from './CurrencyPicker/types/CurrencyPickerState';
export type { CurrencyPickerTriggerProps } from './CurrencyPicker/types/CurrencyPickerTriggerProps';
+export { FormFieldRow } from './FormFieldRow/FormFieldRow';
+export type { FormFieldRowProps } from './FormFieldRow/types/FormFieldRowProps';
export { IconButton } from './IconButton/IconButton';
export type { IconButtonProps } from './IconButton/types/IconButtonProps';
export type { IconButtonSize } from './IconButton/types/IconButtonSize';