Skip to content

The open alternative to Salesforce, designed for AI.

Complete Button and IconButton contracts (#27609)

Raphaël Bosi897bfa115aab
diff --git a/packages/twenty-docs/snippets/ui/generated/components/feedback/callout.mdx b/packages/twenty-docs/snippets/ui/generated/components/feedback/callout.mdx
index dcefc32736d..599c7134fb2 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/feedback/callout.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/feedback/callout.mdx
@@ -95,7 +95,7 @@
</ParamField>
<ParamField body="Action.href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="Action.loading" type="boolean">
@@ -106,8 +106,16 @@
Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
</ParamField>
+<ParamField body="Action.nativeButton" type="boolean" default="true">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="Action.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="Action.role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="Action.shortcut" type="ShortcutDefinition">
diff --git a/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx b/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx
index fd5eee6208a..4dfc5f48765 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx
@@ -83,7 +83,7 @@
</ParamField>
<ParamField body="Action.href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="Action.loading" type="boolean">
@@ -94,8 +94,16 @@
Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
</ParamField>
+<ParamField body="Action.nativeButton" type="boolean" default="true">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="Action.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="Action.role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="Action.shortcut" type="ShortcutDefinition">
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx
index 265102a1995..9a9a15bcc8b 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx
@@ -11,8 +11,12 @@
* npx nx generate:ui twenty-docs
*/}
-<ParamField body="aria-label" type="string" required>
- Required accessible name describing the action.
+<ParamField body="aria-label" type="string">
+ Accessible name describing the action. Required unless `aria-labelledby` supplies the name.
+</ParamField>
+
+<ParamField body="aria-labelledby" type="string">
+ ID of the element supplying the accessible name. Can be used instead of `aria-label`.
</ParamField>
<ParamField body="children" type="ReactNode" required>
@@ -24,7 +28,7 @@
returns a class based on the component's state.
</ParamField>
-<ParamField body="color" type="&quot;accent&quot; | &quot;danger&quot; | &quot;neutral&quot; | &quot;success&quot;">
+<ParamField body="color" type="&quot;accent&quot; | &quot;danger&quot; | &quot;neutral&quot; | &quot;success&quot;" default="neutral">
Semantic color of the button.
</ParamField>
@@ -37,15 +41,23 @@
</ParamField>
<ParamField body="href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="loading" type="boolean">
Shows a loading indicator and disables activation.
</ParamField>
+<ParamField body="nativeButton" type="boolean" default="true (false for the built-in href anchor)">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="shape" type="&quot;round&quot; | &quot;square&quot;" default="square">
@@ -77,6 +89,6 @@
Preferred placement of the tooltip relative to the button.
</ParamField>
-<ParamField body="variant" type="&quot;ghost&quot; | &quot;link&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;">
- Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics.
+<ParamField body="variant" type="&quot;ghost&quot; | &quot;link&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;" default="outline">
+ Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/light-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/light-button.mdx
index efa29aee81f..0b54fb00fec 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/input/light-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/light-button.mdx
@@ -41,7 +41,7 @@
</ParamField>
<ParamField body="href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="loading" type="boolean">
@@ -52,8 +52,16 @@
Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
</ParamField>
+<ParamField body="nativeButton" type="boolean" default="true">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="shortcut" type="ShortcutDefinition">
@@ -78,5 +86,5 @@
</ParamField>
<ParamField body="variant" type="&quot;ghost&quot; | &quot;link&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;" default="ghost">
- Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics.
+ Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx
index 11ea0e92949..65a89399a84 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx
@@ -11,8 +11,12 @@
* npx nx generate:ui twenty-docs
*/}
-<ParamField body="aria-label" type="string" required>
- Required accessible name describing the action.
+<ParamField body="aria-label" type="string">
+ Accessible name describing the action. Required unless `aria-labelledby` supplies the name.
+</ParamField>
+
+<ParamField body="aria-labelledby" type="string">
+ ID of the element supplying the accessible name. Can be used instead of `aria-label`.
</ParamField>
<ParamField body="children" type="ReactNode" required>
@@ -41,15 +45,23 @@
</ParamField>
<ParamField body="href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="loading" type="boolean">
Shows a loading indicator and disables activation.
</ParamField>
+<ParamField body="nativeButton" type="boolean" default="true">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="shape" type="&quot;round&quot; | &quot;square&quot;">
@@ -82,5 +94,5 @@
</ParamField>
<ParamField body="variant" type="&quot;ghost&quot; | &quot;link&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;" default="ghost">
- Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics.
+ Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/main-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/main-button.mdx
index efe6f692110..ef58b0e4c96 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/input/main-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/main-button.mdx
@@ -37,7 +37,7 @@
</ParamField>
<ParamField body="href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="loading" type="boolean">
@@ -48,8 +48,16 @@
Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
</ParamField>
+<ParamField body="nativeButton" type="boolean" default="true">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="shortcut" type="ShortcutDefinition">
@@ -74,5 +82,5 @@
</ParamField>
<ParamField body="variant" type="&quot;ghost&quot; | &quot;link&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;" default="solid">
- Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics.
+ Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdx
index 67085afb77b..7cebc263ab4 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdx
@@ -33,11 +33,19 @@
</ParamField>
<ParamField body="href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
+</ParamField>
+
+<ParamField body="nativeButton" type="boolean" default="true">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
</ParamField>
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="size" type="&quot;md&quot; | &quot;sm&quot;" default="sm">
diff --git a/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx b/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx
index 28102be5607..4bb44c4488b 100644
--- a/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx
@@ -75,7 +75,7 @@
</ParamField>
<ParamField body="Action.href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="Action.loading" type="boolean">
@@ -86,8 +86,16 @@
Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
</ParamField>
+<ParamField body="Action.nativeButton" type="boolean" default="true">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="Action.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="Action.role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="Action.shortcut" type="ShortcutDefinition">
diff --git a/packages/twenty-docs/snippets/ui/generated/input/button-group.mdx b/packages/twenty-docs/snippets/ui/generated/input/button-group.mdx
index cb27e4010c4..86b853d33a4 100644
--- a/packages/twenty-docs/snippets/ui/generated/input/button-group.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/input/button-group.mdx
@@ -16,7 +16,7 @@
</ParamField>
<ParamField body="color" type="&quot;accent&quot; | &quot;danger&quot; | &quot;neutral&quot; | &quot;success&quot;">
- Shared semantic color that overrides the color of buttons in the group.
+ Default semantic color for children without an explicit color.
</ParamField>
<ParamField body="framed" type="boolean" default="false">
@@ -31,9 +31,9 @@
</ParamField>
<ParamField body="size" type="&quot;md&quot; | &quot;sm&quot;">
- Shared button height that overrides the size of buttons in the group.
+ Default button height for children without an explicit size.
</ParamField>
<ParamField body="variant" type="&quot;ghost&quot; | &quot;link&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;">
- Shared surface treatment that overrides the variant of buttons in the group.
+ Default surface treatment for children without an explicit variant.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/input/button.mdx b/packages/twenty-docs/snippets/ui/generated/input/button.mdx
index 0360a2670c9..931d6887a03 100644
--- a/packages/twenty-docs/snippets/ui/generated/input/button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/input/button.mdx
@@ -37,7 +37,7 @@
</ParamField>
<ParamField body="href" type="string">
- Destination URL. Enables native link semantics instead of button semantics.
+ Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.
</ParamField>
<ParamField body="loading" type="boolean" default="false">
@@ -48,8 +48,16 @@
Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
</ParamField>
+<ParamField body="nativeButton" type="boolean" default="true (false for the built-in href anchor)">
+ Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.
+</ParamField>
+
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
- Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+ Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="role" type="AriaRole">
+ Role of the root element. Use `link` for custom navigation renderers.
</ParamField>
<ParamField body="shortcut" type="ShortcutDefinition">
@@ -74,5 +82,5 @@
</ParamField>
<ParamField body="variant" type="&quot;ghost&quot; | &quot;link&quot; | &quot;outline&quot; | &quot;soft&quot; | &quot;solid&quot;" default="outline">
- Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics.
+ Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics.
</ParamField>
diff --git a/packages/twenty-docs/ui/components/input/icon-button.mdx b/packages/twenty-docs/ui/components/input/icon-button.mdx
index 633883227d1..7f863d45b5d 100644
--- a/packages/twenty-docs/ui/components/input/icon-button.mdx
+++ b/packages/twenty-docs/ui/components/input/icon-button.mdx
@@ -7,7 +7,7 @@ import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import IconButtonReference from '/snippets/ui/generated/components/input/icon-button.mdx';
-`IconButton` composes [Button](/ui/primitives/input/button) with a square or round surface. Pass the icon as children and provide an `aria-label` describing the action. Icon content is decorative and hidden from assistive technology.
+`IconButton` composes [Button](/ui/primitives/input/button) with a square or round surface. Pass the icon as children and provide an accessible name with `aria-label` or `aria-labelledby`. Icon content is decorative and hidden from assistive technology.
## Usage
@@ -35,9 +35,36 @@ Sizes are `xs` (20px), `sm` (24px), and `md` (32px). The defaults are `md`, `out
height={620}
/>
+## Accessible names
+
+Use `aria-label` for a name supplied directly on the control. When visible text already names the action, use `aria-labelledby` to reference it instead. At least one naming prop is required.
+
+```tsx
+import { IconButton } from 'twenty-ui/components/input';
+import { IconSearch } from 'twenty-ui/icon';
+import { Text } from 'twenty-ui/primitives/typography';
+
+export const LabelledSearchButton = () => (
+ <>
+ <Text render={<span />} id="records-search-label">
+ Search records
+ </Text>
+ <IconButton aria-labelledby="records-search-label" tooltip="Find a record">
+ <IconSearch />
+ </IconButton>
+ </>
+);
+```
+
+<StoryEmbed
+ title="Icon button named by visible text"
+ storyId="ui-components-iconbutton--labelled-by"
+ height={180}
+/>
+
## Tooltip
-Add `tooltip` to show text on hover and keyboard focus. Keep `aria-label` as the accessible name of the action. Disabled and loading buttons retain hover tooltips.
+Add `tooltip` to show text on hover and keyboard focus. Keep `aria-label` or `aria-labelledby` as the accessible name of the action. Disabled and loading buttons retain hover tooltips.
```tsx
import { IconButton } from 'twenty-ui/components/input';
@@ -116,13 +143,19 @@ export const RecordActions = () => (
);
```
-[ButtonGroup](/ui/primitives/input/button-group) supplies size, variant, color, and adjoining corners. Individual buttons do not need a position prop.
+[ButtonGroup](/ui/primitives/input/button-group) supplies defaults for size, variant, and color, plus adjoining corners. Explicit child props take precedence independently, including `size="xs"`. Individual buttons do not need a position prop.
+
+<StoryEmbed
+ storyId="ui-components-iconbutton--grouped-overrides"
+ title="Individual icon button appearance in a group"
+ height={180}
+/>
## Links and forms
-Use `href` to render an anchor. The caller can provide a custom `render` element, including its own router link. Supply `href` to select link semantics; the renderer must preserve an anchor. Without `href`, preserve a native button. Neither `nativeButton` nor `role` is part of the public button interface. Disabled links cannot activate. Routing stays in the application.
+Without a custom `render`, `href` renders an anchor unless `nativeButton` is explicitly true. For a custom navigation anchor or router link, set `nativeButton={false}` and `role="link"`. The renderer can own its destination without an IconButton `href`. Keep `nativeButton` true for a custom native button, and use false for a non-native action element. Explicit nativeButton and role props are preserved. Disabled and loading links cannot activate. Routing stays in the application.
-Native attributes, event handlers, refs, and render composition pass through to Button. The default is `type="button"`; set `type="submit"` explicitly for form submission.
+Native button and anchor attributes, event handlers, event details, refs, and render composition pass through to Button. The ref receives the actual root element. Tooltip composition preserves that root and its accessible name. The default is `type="button"`; set `type="submit"` explicitly for form submission.
## Props
diff --git a/packages/twenty-docs/ui/components/input/light-button.mdx b/packages/twenty-docs/ui/components/input/light-button.mdx
index 12f0259f09f..5b284225138 100644
--- a/packages/twenty-docs/ui/components/input/light-button.mdx
+++ b/packages/twenty-docs/ui/components/input/light-button.mdx
@@ -40,7 +40,8 @@ surfaces. Semantic colors and solid surfaces retain their contrast treatment.
Override `variant`, `color`, `size`, or `elevated` when needed.
[ButtonGroup](/ui/primitives/input/button-group) can set a shared size, surface,
-and color; subtle emphasis does not replace the group's semantic color.
+and color. Explicit child appearance takes precedence over the group, followed by
+the component defaults. Subtle emphasis does not replace the semantic color.
## Interaction
@@ -48,8 +49,8 @@ and color; subtle emphasis does not replace the group's semantic color.
slots, loading and disabled states, and render composition. Its native default
is `type="button"`. Set `type="submit"` for submission or use `href` for a link.
Supply `render` to choose a custom root, including an application-owned router
-link. The root must preserve a native button, or an anchor when `href` is set.
-Button derives the interaction behavior from `href`.
+link. Set `nativeButton={false}` and `role="link"` for a navigation renderer.
+Custom native buttons keep `nativeButton` true.
## Props
diff --git a/packages/twenty-docs/ui/components/input/light-icon-button.mdx b/packages/twenty-docs/ui/components/input/light-icon-button.mdx
index 60aa7a80a33..fb0dbcaa787 100644
--- a/packages/twenty-docs/ui/components/input/light-icon-button.mdx
+++ b/packages/twenty-docs/ui/components/input/light-icon-button.mdx
@@ -27,13 +27,13 @@ export const AddAction = () => (
);
```
-Standard emphasis uses secondary neutral text; subtle emphasis uses tertiary text. Explicit semantic colors and group colors take precedence. Small controls are 24px with a 14px icon; medium controls are 32px with a 16px icon. Compact controls use `size="xs"` and are 20px.
+Standard emphasis uses secondary neutral text; subtle emphasis uses tertiary text. Explicit child appearance takes precedence over ButtonGroup values, followed by the component defaults. Semantic colors retain their own contrast treatment. Small controls are 24px with a 14px icon; medium controls are 32px with a 16px icon. Compact controls use `size="xs"` and are 20px.
## State and interaction
Button owns keyboard activation, disabled and loading behavior, refs, native attributes, and render composition. The native default is `type="button"`. Use `aria-pressed` for toggles and `aria-expanded` for disclosures. The application owns these states and can set `color="accent"` to highlight a selected action. Keyboard focus uses the shared focus ring.
-Tooltip text is optional and does not replace `aria-label`. Set `href` for a link and supply `render` when the application owns routing.
+Tooltip text is optional and does not replace an accessible name from `aria-label` or `aria-labelledby`. Set `href` for a link. For application-owned routing, supply `render`, `nativeButton={false}`, and `role="link"`.
## Updating existing controls
diff --git a/packages/twenty-docs/ui/components/input/main-button.mdx b/packages/twenty-docs/ui/components/input/main-button.mdx
index fe6e717d732..60d338b9392 100644
--- a/packages/twenty-docs/ui/components/input/main-button.mdx
+++ b/packages/twenty-docs/ui/components/input/main-button.mdx
@@ -45,11 +45,13 @@ Keep page layout in your application's styling.
set `type="submit"` explicitly for form submission.
Use `href` for a link. Supply `render` to choose a custom root, including an
-application-owned router link. The root must preserve a native button, or an
-anchor when `href` is set. Button derives the interaction behavior from `href`.
+application-owned router link. Set `nativeButton={false}` and `role="link"` for
+a navigation renderer. Custom native buttons keep `nativeButton` true.
[ButtonGroup](/ui/primitives/input/button-group) can set a shared size, surface,
-and color. Consumer classes, including state functions, pass through to the root.
+and color. Explicit child appearance takes precedence over the group, followed by
+the component defaults. Consumer classes, including state functions, pass through
+to the root.
## Props
diff --git a/packages/twenty-docs/ui/components/navigation/tab-button.mdx b/packages/twenty-docs/ui/components/navigation/tab-button.mdx
index d75640d329a..46f6bdf6863 100644
--- a/packages/twenty-docs/ui/components/navigation/tab-button.mdx
+++ b/packages/twenty-docs/ui/components/navigation/tab-button.mdx
@@ -38,7 +38,7 @@ export const BillingLink = () => (
);
```
-For client-side routing, pass the resolved destination as `href` and your router link through `render`. Keep route state and history options on the router link. Custom wrappers must forward props and the ref to the anchor. Disabled links retain their link role and block activation.
+For client-side routing, set `nativeButton={false}` and `role="link"`, pass the resolved destination as `href`, and supply your router link through `render`. Keep route state and history options on the router link. Custom wrappers must forward props and the ref to the anchor. Disabled links retain their link role and block activation.
## Actions
diff --git a/packages/twenty-docs/ui/primitives/input/button-group.mdx b/packages/twenty-docs/ui/primitives/input/button-group.mdx
index 20d72a6d18e..447fff1f339 100644
--- a/packages/twenty-docs/ui/primitives/input/button-group.mdx
+++ b/packages/twenty-docs/ui/primitives/input/button-group.mdx
@@ -13,7 +13,7 @@ import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import ButtonGroupReference from '/snippets/ui/generated/input/button-group.mdx';
-Give a group an accessible name and place related buttons inside it. The group joins adjacent borders and can apply a shared size, variant, and color. Buttons retain their own tab stops.
+Give a group an accessible name and place related buttons inside it. The group joins adjacent borders and can apply defaults for size, variant, and color. Buttons retain their own tab stops.
## State ownership
@@ -34,37 +34,66 @@ export const RecordActions = () => (
);
```
+## Appearance precedence
+
+Each appearance prop resolves independently: the child's explicit prop, then the group default, then the component default. This applies to both Button and IconButton, including an explicit `IconButton size="xs"`. Defaults reach children through fragments, wrappers, and tooltip anchors.
+
+```tsx
+import { Button, ButtonGroup } from 'twenty-ui/primitives/input';
+
+export const ActivityActions = () => (
+ <ButtonGroup
+ aria-label="Activity actions"
+ variant="solid"
+ color="accent"
+ size="sm"
+ >
+ <Button>New activity</Button>
+ <Button variant="ghost" color="danger" size="md">
+ Delete activity
+ </Button>
+ <Button color="neutral">Duplicate activity</Button>
+ </ButtonGroup>
+);
+```
+
+<StoryEmbed
+ storyId="ui-input-button-buttongroup--appearance-overrides"
+ title="Individual appearance in a button group"
+ height={180}
+/>
+
## Props
<ButtonGroupReference />
## Detached controls
-Set `attached={false}` to keep each control's rounded corners and a 2px gap. Shared size, surface, and color still apply through wrappers and tooltip anchors.
+Set `attached={false}` to keep each control's rounded corners and a 2px gap. Group defaults still apply through wrappers and tooltip anchors; explicit child props take precedence.
## Framed controls
-Set `framed` to add a translucent background, border, 2px padding, and concentric corners. The frame works with attached or detached controls and preserves each button's size and appearance unless you set them on the group. Use `size="xs"` on [LightIconButton](/ui/components/input/light-icon-button) for compact 20px actions.
+Set `framed` to add a translucent background, border, 2px padding, and concentric corners. The frame works with attached or detached controls and preserves explicit child appearance. Use `size="xs"` on [IconButton](/ui/components/input/icon-button) for compact 20px actions.
<StoryEmbed
- storyId="ui-components-input-lighticonbutton-groups--framed-documentation"
+ storyId="ui-components-iconbutton--framed-group-documentation"
title="Framed button group"
height={180}
/>
```tsx
-import { LightIconButton } from 'twenty-ui/components/input';
+import { IconButton } from 'twenty-ui/components/input';
import { IconPlus, IconTrash } from 'twenty-ui/icon';
import { ButtonGroup } from 'twenty-ui/primitives/input';
export const CompactRecordActions = () => (
<ButtonGroup framed attached={false} aria-label="Record actions">
- <LightIconButton size="xs" aria-label="Add" emphasis="subtle">
+ <IconButton size="xs" aria-label="Add" variant="ghost">
<IconPlus />
- </LightIconButton>
- <LightIconButton size="xs" aria-label="Delete" emphasis="subtle" disabled>
+ </IconButton>
+ <IconButton size="xs" aria-label="Delete" variant="ghost" disabled>
<IconTrash />
- </LightIconButton>
+ </IconButton>
</ButtonGroup>
);
```
diff --git a/packages/twenty-docs/ui/primitives/input/button.mdx b/packages/twenty-docs/ui/primitives/input/button.mdx
index ddd28e15eae..57c3c36a18b 100644
--- a/packages/twenty-docs/ui/primitives/input/button.mdx
+++ b/packages/twenty-docs/ui/primitives/input/button.mdx
@@ -8,7 +8,7 @@ import StoryEmbed from '/snippets/ui/StoryEmbed.mdx';
<StoryEmbed storyId="ui-input-button-button--default" height={220} />
import ButtonReference from '/snippets/ui/generated/input/button.mdx';
-Use `Button` for an action. Supply its visible label as children, and give icon-only buttons an `aria-label`.
+Use `Button` for an action and supply its visible label as children. Use [IconButton](/ui/components/input/icon-button) for icon-only controls, with an accessible name from `aria-label` or `aria-labelledby`.
For recurring design defaults, use [MainButton](/ui/components/input/main-button)
or [LightButton](/ui/components/input/light-button) from `twenty-ui/components`.
@@ -158,15 +158,35 @@ export const DocumentationLink = () => (
href="https://twenty.com"
target="_blank"
rel="noreferrer"
+ hrefLang="en"
+ referrerPolicy="no-referrer"
>
Read documentation
</Button>
);
```
-`href` renders an anchor with link semantics. The caller can supply its own `render` element or router link. Set `href` and preserve an anchor for navigation; without `href`, preserve a native button. Button derives its semantics without public `nativeButton` or `role` flags. Disabled links cannot activate.
+Without a custom `render`, `href` renders an anchor with link semantics, unless you explicitly set `nativeButton` to `true`. Native anchor attributes such as `download`, `hrefLang`, `ping`, and `referrerPolicy` reach the anchor. Props shared with native buttons retain their Base UI types. To supply an anchor MIME type, put it on the renderer, for example `render={<a href="/records.csv" type="text/csv">Download records</a>}` with `nativeButton={false}` and `role="link"`. Disabled and loading links cannot activate.
-Buttons default to `type="button"`. Set `type="submit"` or `type="reset"` explicitly for forms. Native props, event handlers, refs, and Base UI's `render` prop pass through to the root.
+Use `render` to compose another element or a router link. `nativeButton` describes the rendered element and defaults to `true` for custom renderers. Set `nativeButton={false}` and `role="link"` for a navigation anchor. The anchor or router component can own its destination without a `Button` `href`.
+
+```tsx
+import { Button } from 'twenty-ui/primitives/input';
+
+export const RecordsLink = () => (
+ <Button nativeButton={false} role="link" render={<a href="/records" />}>
+ Open records
+ </Button>
+);
+```
+
+For a custom native `<button>`, keep `nativeButton` true. For a non-native action element such as a `<div>`, use `nativeButton={false}`; Base UI supplies button keyboard behavior. An explicit `nativeButton` or `role` is preserved even when `href` is also supplied.
+
+Buttons default to `type="button"`. Set `type="submit"` or `type="reset"` explicitly for forms. Native attributes, event handlers, event details, and refs reach the rendered root. A ref receives the actual button, anchor, or custom root element. Keyboard handlers retain Base UI event methods, including `preventBaseUIHandler()` to cancel its built-in keyboard action. Base UI's render callback receives both root props and the current disabled state; spread the props onto your root to retain composition behavior.
+
+## Group defaults
+
+[ButtonGroup](/ui/primitives/input/button-group) supplies a shared variant, color, and size. An explicit prop on a child takes precedence over the group default. When neither sets a prop, the component default applies.
## Migration from ClickToActionLink
diff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
index e32516a99a3..4e6daee82cc 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -22,6 +22,7 @@ import { listItemTest } from '@/__stories__/twenty-ui-gallery/utils/listItemTest
import { resizeHandlePanelTest } from '@/__stories__/twenty-ui-gallery/utils/resizeHandlePanelTest';
import { pickerListItemsTest } from '@/__stories__/twenty-ui-gallery/utils/pickerListItemsTest';
import { iconButtonElevatedTest } from '@/__stories__/twenty-ui-gallery/utils/iconButtonElevatedTest';
+import { buttonContractsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonContractsTest';
import { buttonControlsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonControlsTest';
import { responsiveHooksTest } from '@/__stories__/twenty-ui-gallery/utils/responsiveHooksTest';
import { RESPONSIVE_HOOKS_WIDGET_SIZING } from '@/__stories__/twenty-ui-gallery/constants/RESPONSIVE_HOOKS_WIDGET_SIZING';
@@ -548,6 +549,18 @@ export const TagControlsPreact: Story = createGalleryStory({
play: tagControlsTest,
});
+export const ButtonContractsReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-button-contracts',
+ runtime: 'react',
+ play: buttonContractsTest,
+});
+
+export const ButtonContractsPreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-button-contracts',
+ runtime: 'preact',
+ play: buttonContractsTest,
+});
+
export const ButtonControlsReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-button-controls',
runtime: 'react',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/button-contracts-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/button-contracts-example.tsx
new file mode 100644
index 00000000000..21dd42acb7e
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/button-contracts-example.tsx
@@ -0,0 +1,139 @@
+import { createElement, useState } from 'react';
+import { IconButton } from 'twenty-ui/components/input';
+import { IconPlus, IconX } from 'twenty-ui/icon';
+import { Button, ButtonGroup } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+
+export const ButtonContractsExample = () => {
+ const [nativeClicks, setNativeClicks] = useState(0);
+ const [clickDetails, setClickDetails] = useState('none');
+ const [callbackLinkClicks, setCallbackLinkClicks] = useState(0);
+ const [labelledIconClicks, setLabelledIconClicks] = useState(0);
+ const [centerLoading, setCenterLoading] = useState(false);
+
+ return (
+ <>
+ <Button
+ nativeButton
+ data-contract-target="native-button"
+ href="#native-button-contract"
+ render={<button />}
+ ref={(element) => {
+ element?.setAttribute('data-ref-target', 'native-button');
+ }}
+ onClick={(event) => {
+ setNativeClicks((count) => count + 1);
+ setClickDetails(
+ `${event.currentTarget.getAttribute('data-contract-target')}:${event.type}:${event.button}:${typeof event.preventBaseUIHandler}`,
+ );
+ }}
+ >
+ Custom native button
+ </Button>
+ <Text aria-label="Native button activations">{nativeClicks}</Text>
+ <Text aria-label="Button click details">{clickDetails}</Text>
+ <Button
+ nativeButton={false}
+ role="link"
+ href="#composed-button-link"
+ hrefLang="fr"
+ media="screen"
+ ping="https://twenty.com/ping"
+ referrerPolicy="no-referrer"
+ download="button-contract.txt"
+ render={
+ <a
+ type="text/plain"
+ ref={(element) => {
+ element?.setAttribute('data-render-ref-target', 'element-link');
+ }}
+ />
+ }
+ ref={(element) => {
+ element?.setAttribute('data-ref-target', 'element-link');
+ }}
+ >
+ Composed download link
+ </Button>
+ <Button href="#boolean-download" download>
+ Download without filename
+ </Button>
+ <Button
+ nativeButton={false}
+ role="link"
+ href="#callback-button-link"
+ target="_self"
+ data-contract-target="callback-link"
+ render={(props, state) =>
+ createElement('a', {
+ ...props,
+ 'data-render-disabled': String(state.disabled),
+ })
+ }
+ ref={(element) => {
+ element?.setAttribute('data-ref-target', 'callback-link');
+ }}
+ onClick={(event) => {
+ event.preventDefault();
+ setCallbackLinkClicks((count) => count + 1);
+ setClickDetails(
+ `${event.currentTarget.getAttribute('data-contract-target')}:${event.type}:${event.button}:${typeof event.preventBaseUIHandler}`,
+ );
+ }}
+ >
+ Callback rendered link
+ </Button>
+ <Text aria-label="Callback link activations">{callbackLinkClicks}</Text>
+ <Text id="labelled-icon-button-name">Labelled icon action</Text>
+ <IconButton
+ aria-labelledby="labelled-icon-button-name"
+ onClick={() => setLabelledIconClicks((count) => count + 1)}
+ >
+ <IconPlus />
+ </IconButton>
+ <Text aria-label="Labelled icon activations">{labelledIconClicks}</Text>
+ <ButtonGroup
+ aria-label="Appearance defaults"
+ variant="solid"
+ color="danger"
+ size="sm"
+ >
+ <Button>Inherited appearance</Button>
+ <Button variant="ghost" color="success" size="md">
+ Explicit appearance
+ </Button>
+ <IconButton aria-label="Inherited icon appearance">
+ <IconPlus />
+ </IconButton>
+ <IconButton
+ aria-label="Explicit icon appearance"
+ variant="outline"
+ color="accent"
+ size="xs"
+ >
+ <IconPlus />
+ </IconButton>
+ </ButtonGroup>
+ <Button loading={centerLoading}>Preserve center content width</Button>
+ <Button onClick={() => setCenterLoading(!centerLoading)}>
+ Toggle center loading
+ </Button>
+ <Button
+ loading
+ loadingPosition="start"
+ startIcon={<IconPlus data-testid="start-loading-original-icon" />}
+ endIcon={<IconX data-testid="start-loading-retained-icon" />}
+ >
+ Loading at start
+ </Button>
+ <Button
+ loading
+ loadingPosition="end"
+ startIcon={<IconPlus data-testid="end-loading-retained-icon" />}
+ endIcon={<IconX data-testid="end-loading-original-icon" />}
+ >
+ Loading at end
+ </Button>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-contracts.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-contracts.front-component.tsx
new file mode 100644
index 00000000000..72a74f4abbc
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-contracts.front-component.tsx
@@ -0,0 +1,18 @@
+import { ButtonContractsExample } from '@/__stories__/twenty-ui-gallery/button-contracts-example';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import 'twenty-ui/style.css';
+import { ThemeProvider } from 'twenty-ui/theme';
+
+const ButtonContracts = () => (
+ <ThemeProvider colorScheme="light">
+ <ButtonContractsExample />
+ </ThemeProvider>
+);
+
+export default defineFrontComponent({
+ universalIdentifier: '1c8d8d4a-a5d5-49f9-806b-69d5ad573ba7',
+ name: 'twenty-ui-button-contracts',
+ description:
+ 'Button native rendering and appearance contracts in the sandbox',
+ component: ButtonContracts,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx
index f5998ad4745..d0844b13d0e 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx
@@ -46,6 +46,8 @@ const InlineBannerExample = () => {
layout="compact"
action={
<InlineBanner.Action
+ nativeButton={false}
+ role="link"
href={'https://twenty.com'}
target={'_blank'}
rel={'noopener noreferrer'}
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonContractsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonContractsTest.ts
new file mode 100644
index 00000000000..b8fbb93da9d
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonContractsTest.ts
@@ -0,0 +1,150 @@
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+export const buttonContractsTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const nativeButton = await canvas.findByRole(
+ 'button',
+ { name: 'Custom native button' },
+ { timeout: 10000 },
+ );
+
+ await waitFor(() =>
+ expect(nativeButton.getBoundingClientRect().height).toBe(32),
+ );
+
+ await expect(nativeButton.tagName).toBe('BUTTON');
+ await expect(nativeButton).toHaveAttribute('type', 'button');
+ await userEvent.click(nativeButton);
+ nativeButton.focus();
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() => {
+ expect(
+ canvas.getByLabelText('Native button activations'),
+ ).toHaveTextContent('2');
+ expect(canvas.getByLabelText('Button click details')).toHaveTextContent(
+ 'native-button:click:0:function',
+ );
+ });
+
+ const elementLink = canvas.getByRole('link', {
+ name: 'Composed download link',
+ });
+
+ await expect(elementLink.tagName).toBe('A');
+ await expect(elementLink).toHaveAttribute('href', '#composed-button-link');
+ await expect(elementLink).toHaveAttribute('hreflang', 'fr');
+ await expect(elementLink).toHaveAttribute('media', 'screen');
+ await expect(elementLink).toHaveAttribute('type', 'text/plain');
+ await expect(elementLink).toHaveAttribute('ping', 'https://twenty.com/ping');
+ await expect(elementLink).toHaveAttribute('referrerpolicy', 'no-referrer');
+ await expect(elementLink).toHaveAttribute('download', 'button-contract.txt');
+
+ await expect(
+ canvas.getByRole('link', { name: 'Download without filename' }),
+ ).toHaveAttribute('download', '');
+
+ const callbackLink = canvas.getByRole('link', {
+ name: 'Callback rendered link',
+ });
+
+ await expect(callbackLink.tagName).toBe('A');
+ await expect(callbackLink).toHaveAttribute('href', '#callback-button-link');
+ await expect(callbackLink).toHaveAttribute('data-render-disabled', 'false');
+ await userEvent.click(callbackLink);
+ await waitFor(() => {
+ expect(
+ canvas.getByLabelText('Callback link activations'),
+ ).toHaveTextContent('1');
+ expect(canvas.getByLabelText('Button click details')).toHaveTextContent(
+ 'callback-link:click:0:function',
+ );
+ });
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Labelled icon action' }),
+ );
+ await waitFor(() =>
+ expect(
+ canvas.getByLabelText('Labelled icon activations'),
+ ).toHaveTextContent('1'),
+ );
+
+ for (const name of ['Inherited appearance', 'Inherited icon appearance']) {
+ const inherited = canvas.getByRole('button', { name });
+
+ await expect(inherited).toHaveAttribute('data-variant', 'solid');
+ await expect(inherited).toHaveAttribute('data-color', 'danger');
+ await expect(inherited.getBoundingClientRect().height).toBe(24);
+ }
+
+ const explicitButton = canvas.getByRole('button', {
+ name: 'Explicit appearance',
+ });
+ const explicitIcon = canvas.getByRole('button', {
+ name: 'Explicit icon appearance',
+ });
+
+ await expect(explicitButton).toHaveAttribute('data-variant', 'ghost');
+ await expect(explicitButton).toHaveAttribute('data-color', 'success');
+ await expect(explicitButton.getBoundingClientRect().height).toBe(32);
+ await expect(explicitIcon).toHaveAttribute('data-variant', 'outline');
+ await expect(explicitIcon).toHaveAttribute('data-color', 'accent');
+ await expect(explicitIcon.getBoundingClientRect().height).toBe(20);
+ await expect(explicitIcon.getBoundingClientRect().width).toBe(20);
+
+ const centerLoadingButton = canvas.getByRole('button', {
+ name: 'Preserve center content width',
+ });
+ const initialWidth = centerLoadingButton.getBoundingClientRect().width;
+ const toggleCenterLoading = canvas.getByRole('button', {
+ name: 'Toggle center loading',
+ });
+
+ await userEvent.click(toggleCenterLoading);
+ await waitFor(() => {
+ expect(centerLoadingButton).toBeDisabled();
+ expect(centerLoadingButton).toHaveAttribute('aria-busy', 'true');
+ expect(centerLoadingButton.getBoundingClientRect().width).toBe(
+ initialWidth,
+ );
+ });
+ await userEvent.click(toggleCenterLoading);
+ await waitFor(() => expect(centerLoadingButton).toBeEnabled());
+
+ for (const name of ['Loading at start', 'Loading at end']) {
+ const loadingButton = canvas.getByRole('button', { name });
+
+ await expect(loadingButton).toBeDisabled();
+ await expect(loadingButton).toHaveAttribute('aria-busy', 'true');
+ }
+
+ await expect(
+ canvas.queryByTestId('start-loading-original-icon'),
+ ).not.toBeInTheDocument();
+ await expect(
+ canvas.queryByTestId('end-loading-original-icon'),
+ ).not.toBeInTheDocument();
+ await expect(
+ canvas.getByTestId('start-loading-retained-icon'),
+ ).toBeInTheDocument();
+ await expect(
+ canvas.getByTestId('end-loading-retained-icon'),
+ ).toBeInTheDocument();
+
+ await expect(nativeButton).toHaveAttribute(
+ 'data-ref-target',
+ 'native-button',
+ );
+ await expect(elementLink).toHaveAttribute('data-ref-target', 'element-link');
+ await expect(elementLink).toHaveAttribute(
+ 'data-render-ref-target',
+ 'element-link',
+ );
+ await expect(callbackLink).toHaveAttribute(
+ 'data-ref-target',
+ 'callback-link',
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.ts b/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.ts
index 60d2dbaa569..8b5ab4f45ec 100644
--- a/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.ts
+++ b/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.ts
@@ -37,10 +37,13 @@ export const ALLOWED_HTML_ELEMENTS: AllowedHtmlElement[] = [
name: 'HtmlA',
properties: {
href: { type: 'string', optional: true },
+ hrefLang: { type: 'string', optional: true },
+ media: { type: 'string', optional: true },
+ type: { type: 'string', optional: true },
target: { type: 'string', optional: true },
rel: { type: 'string', optional: true },
download: { type: 'string', optional: true },
- hrefLang: { type: 'string', optional: true },
+ ping: { type: 'string', optional: true },
referrerPolicy: { type: 'string', optional: true },
},
},
diff --git a/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.ts b/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.ts
index 1e1079885f4..1a197077aca 100644
--- a/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.ts
+++ b/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.ts
@@ -391,10 +391,13 @@ export const HtmlBlockquoteElement = createRemoteElement<
export type HtmlAProperties = HtmlCommonProperties & {
href?: string;
+ hrefLang?: string;
+ media?: string;
+ type?: string;
target?: string;
rel?: string;
download?: string;
- hrefLang?: string;
+ ping?: string;
referrerPolicy?: string;
};
@@ -407,10 +410,13 @@ export const HtmlAElement = createRemoteElement<
properties: {
...HTML_COMMON_PROPERTIES_CONFIG,
href: { type: String },
+ hrefLang: { type: String },
+ media: { type: String },
+ type: { type: String },
target: { type: String },
rel: { type: String },
download: { type: String },
- hrefLang: { type: String },
+ ping: { type: String },
referrerPolicy: { type: String },
},
events: {
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuButton.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuButton.tsx
index 57fe8da37c5..fd8a842dbf3 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuButton.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuButton.tsx
@@ -85,6 +85,8 @@ export const CommandMenuButton = ({
size="sm"
variant={buttonAccent === 'blue' ? 'solid' : 'outline'}
color={buttonAccent === 'blue' ? 'accent' : 'neutral'}
+ nativeButton={!isDefined(to)}
+ role={isDefined(to) ? 'link' : undefined}
render={isDefined(to) ? <Link to={to} /> : undefined}
href={to}
onClick={onClick}
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationActionButton.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationActionButton.tsx
index cb17f4e4253..b2c3e684906 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationActionButton.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationActionButton.tsx
@@ -28,6 +28,8 @@ export const SettingsApplicationActionButton = ({
variant="solid"
color="accent"
size="sm"
+ nativeButton={false}
+ role="link"
render={
<Link
to={getSettingsPath(SettingsPath.ApplicationDetail, {
diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsx
index 0b51c4062bb..bde82d53419 100644
--- a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsx
+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsx
@@ -59,6 +59,8 @@ export const SettingsBillingTabBar = () => {
aria-current={isTabActive(path) ? 'page' : undefined}
href={href}
render={render}
+ nativeButton={false}
+ role="link"
>
{title}
</TabButton>
diff --git a/packages/twenty-front/src/modules/ui/input/components/NavigationButton.tsx b/packages/twenty-front/src/modules/ui/input/components/NavigationButton.tsx
index 05310a8e98e..19b7fc04500 100644
--- a/packages/twenty-front/src/modules/ui/input/components/NavigationButton.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/NavigationButton.tsx
@@ -19,7 +19,13 @@ export const NavigationButton = ({
return (
<NavigationLink to={to}>
{({ href, render }) => (
- <ButtonComponent {...props} href={href} render={render} />
+ <ButtonComponent
+ nativeButton={false}
+ role="link"
+ {...props}
+ href={href}
+ render={render}
+ />
)}
</NavigationLink>
);
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListItem.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListItem.tsx
index ff8e1e305dd..c478ecd5c5c 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListItem.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListItem.tsx
@@ -71,6 +71,8 @@ export const TabListItem = ({
ref={ref}
href={href}
render={render}
+ nativeButton={false}
+ role="link"
active={active}
aria-current={active ? 'page' : undefined}
disabled={disabled}
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsx
index 217bb674e6c..288e51827b6 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsx
@@ -224,8 +224,16 @@ export const RouteLinks: Story = {
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);
const activity = await canvas.findByRole('link', { name: 'activity' });
+ const overview = canvas.getByRole('link', { name: 'overview' });
const disabled = canvas.getByRole('link', { name: 'disabled' });
+ expect(disabled).toHaveAttribute('aria-disabled', 'true');
+ expect(disabled).toHaveAttribute('tabindex', '-1');
+ expect(activity).not.toHaveAttribute('type');
+ overview.focus();
+ await userEvent.tab();
+ expect(activity).toHaveFocus();
+
expect(canvas.queryByRole('tablist')).not.toBeInTheDocument();
expect(canvas.queryByRole('tabpanel')).not.toBeInTheDocument();
expect(activity).toHaveAttribute('href', '/?filter=open#activity');
diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
index 9c4a0ee74c0..7d8be734fe6 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
@@ -349,6 +349,8 @@ export const SettingsAdminNewAiModel = () => {
action={
<InlineBanner.Action
href={getSettingsPath(SettingsPath.AdminPanelOrganization)}
+ nativeButton={false}
+ role="link"
render={
<Link
to={getSettingsPath(SettingsPath.AdminPanelOrganization)}
diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
index da26eae970a..0033e493e90 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
@@ -274,6 +274,8 @@ export const SettingsAdminNewAiProvider = () => {
action={
<InlineBanner.Action
href={getSettingsPath(SettingsPath.AdminPanelOrganization)}
+ nativeButton={false}
+ role="link"
render={
<Link
to={getSettingsPath(SettingsPath.AdminPanelOrganization)}
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx
index fa8937ebaac..2209fde7632 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx
@@ -28,6 +28,8 @@ export const SettingsApplicationRegistrationGeneralTab = ({
action={
<InlineBanner.Action
href={`${location.pathname}${location.search}#config`}
+ nativeButton={false}
+ role="link"
render={
<Link
to={{ search: location.search, hash: '#config' }}
diff --git a/packages/twenty-ui/docs/buttonGroupPropDescriptions.ts b/packages/twenty-ui/docs/buttonGroupPropDescriptions.ts
index d0d2a4747f0..0e921dcec72 100644
--- a/packages/twenty-ui/docs/buttonGroupPropDescriptions.ts
+++ b/packages/twenty-ui/docs/buttonGroupPropDescriptions.ts
@@ -6,8 +6,7 @@ export const BUTTON_GROUP_PROP_DESCRIPTIONS = {
framed:
'Add a translucent frame with padding and concentric corners. Button sizes and appearance remain independent unless set on the group.',
variant:
- 'Shared surface treatment that overrides the variant of buttons in the group.',
- color:
- 'Shared semantic color that overrides the color of buttons in the group.',
- size: 'Shared button height that overrides the size of buttons in the group.',
+ 'Default surface treatment for children without an explicit variant.',
+ color: 'Default semantic color for children without an explicit color.',
+ size: 'Default button height for children without an explicit size.',
} satisfies Partial<Record<keyof ButtonGroupProps, string>>;
diff --git a/packages/twenty-ui/docs/buttonPropDescriptions.ts b/packages/twenty-ui/docs/buttonPropDescriptions.ts
index 30c45282cdc..6c8a82de436 100644
--- a/packages/twenty-ui/docs/buttonPropDescriptions.ts
+++ b/packages/twenty-ui/docs/buttonPropDescriptions.ts
@@ -2,7 +2,7 @@ import { type ButtonProps } from '../src/primitives/input/Button/types/ButtonPro
export const BUTTON_PROP_DESCRIPTIONS = {
variant:
- 'Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics.',
+ 'Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics.',
color: 'Semantic color of the button.',
size: 'Button height: `sm` (24px) or `md` (32px). The `link` variant uses its content height at either size.',
fullWidth: 'Expands the button to fill its container width.',
@@ -16,7 +16,10 @@ export const BUTTON_PROP_DESCRIPTIONS = {
shortcutJoinLabel: 'Localized text between sequence steps. Defaults to then.',
shortcut:
'Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Displayed on non-mobile screens.',
- href: 'Destination URL. Enables native link semantics instead of button semantics.',
+ href: 'Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract.',
render:
- 'Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.',
+ 'Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role="link"` for a custom navigation anchor. Router integration belongs to the caller.',
+ nativeButton:
+ 'Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence.',
+ role: 'Role of the root element. Use `link` for custom navigation renderers.',
} satisfies Partial<Record<keyof ButtonProps, string>>;
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index a3476694dbb..52c7e171556 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -240,6 +240,7 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/components/input',
slug: 'components/input/light-icon-button',
propDescriptions: LIGHT_ICON_BUTTON_PROP_DESCRIPTIONS,
+ propDefaults: { variant: 'ghost', size: 'sm' },
},
{
name: 'IconButton',
@@ -247,6 +248,12 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/components/input',
slug: 'components/input/icon-button',
propDescriptions: ICON_BUTTON_PROP_DESCRIPTIONS,
+ propDefaults: {
+ variant: 'outline',
+ color: 'neutral',
+ size: 'md',
+ nativeButton: 'true (false for the built-in href anchor)',
+ },
},
{
name: 'MainButton',
@@ -254,6 +261,7 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/components/input',
slug: 'components/input/main-button',
propDescriptions: BUTTON_PROP_DESCRIPTIONS,
+ propDefaults: { variant: 'solid' },
},
{
name: 'LightButton',
@@ -261,6 +269,7 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/components/input',
slug: 'components/input/light-button',
propDescriptions: LIGHT_BUTTON_PROP_DESCRIPTIONS,
+ propDefaults: { variant: 'ghost', size: 'sm' },
},
{
name: 'Button',
@@ -268,6 +277,12 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/primitives/input',
slug: 'input/button',
propDescriptions: BUTTON_PROP_DESCRIPTIONS,
+ propDefaults: {
+ variant: 'outline',
+ color: 'neutral',
+ size: 'md',
+ nativeButton: 'true (false for the built-in href anchor)',
+ },
},
{
name: 'ButtonGroup',
diff --git a/packages/twenty-ui/docs/iconButtonPropDescriptions.ts b/packages/twenty-ui/docs/iconButtonPropDescriptions.ts
index 0a7bcfa00ed..21398f5de08 100644
--- a/packages/twenty-ui/docs/iconButtonPropDescriptions.ts
+++ b/packages/twenty-ui/docs/iconButtonPropDescriptions.ts
@@ -10,5 +10,8 @@ export const ICON_BUTTON_PROP_DESCRIPTIONS = {
tooltipPlace: 'Preferred placement of the tooltip relative to the button.',
tooltipDelay: 'Delay before showing the tooltip.',
tooltipOffset: 'Distance in pixels between the button and the tooltip.',
- 'aria-label': 'Required accessible name describing the action.',
+ 'aria-label':
+ 'Accessible name describing the action. Required unless `aria-labelledby` supplies the name.',
+ 'aria-labelledby':
+ 'ID of the element supplying the accessible name. Can be used instead of `aria-label`.',
} satisfies Partial<Record<keyof IconButtonProps, string>>;
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 9a777a1a343..19224047f25 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -690,7 +690,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -706,12 +706,26 @@
"defaultValue": null,
"description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shortcut",
@@ -1546,9 +1560,16 @@
{
"name": "aria-label",
"type": "string",
- "required": true,
+ "required": false,
+ "defaultValue": null,
+ "description": "Accessible name describing the action. Required unless `aria-labelledby` supplies the name."
+ },
+ {
+ "name": "aria-labelledby",
+ "type": "string",
+ "required": false,
"defaultValue": null,
- "description": "Required accessible name describing the action."
+ "description": "ID of the element supplying the accessible name. Can be used instead of `aria-label`."
},
{
"name": "children",
@@ -1597,7 +1618,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -1606,12 +1627,26 @@
"defaultValue": null,
"description": "Shows a loading indicator and disables activation."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shape",
@@ -1667,7 +1702,7 @@
"type": "\"ghost\" | \"link\" | \"outline\" | \"soft\" | \"solid\"",
"required": false,
"defaultValue": "ghost",
- "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics."
+ "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics."
}
]
},
@@ -1679,9 +1714,16 @@
{
"name": "aria-label",
"type": "string",
- "required": true,
+ "required": false,
+ "defaultValue": null,
+ "description": "Accessible name describing the action. Required unless `aria-labelledby` supplies the name."
+ },
+ {
+ "name": "aria-labelledby",
+ "type": "string",
+ "required": false,
"defaultValue": null,
- "description": "Required accessible name describing the action."
+ "description": "ID of the element supplying the accessible name. Can be used instead of `aria-label`."
},
{
"name": "children",
@@ -1701,7 +1743,7 @@
"name": "color",
"type": "\"accent\" | \"danger\" | \"neutral\" | \"success\"",
"required": false,
- "defaultValue": null,
+ "defaultValue": "neutral",
"description": "Semantic color of the button."
},
{
@@ -1723,7 +1765,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -1732,12 +1774,26 @@
"defaultValue": null,
"description": "Shows a loading indicator and disables activation."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true (false for the built-in href anchor)",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shape",
@@ -1792,8 +1848,8 @@
"name": "variant",
"type": "\"ghost\" | \"link\" | \"outline\" | \"soft\" | \"solid\"",
"required": false,
- "defaultValue": null,
- "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics."
+ "defaultValue": "outline",
+ "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics."
}
]
},
@@ -1849,7 +1905,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -1865,12 +1921,26 @@
"defaultValue": null,
"description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shortcut",
@@ -1912,7 +1982,7 @@
"type": "\"ghost\" | \"link\" | \"outline\" | \"soft\" | \"solid\"",
"required": false,
"defaultValue": "solid",
- "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics."
+ "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics."
}
]
},
@@ -1975,7 +2045,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -1991,12 +2061,26 @@
"defaultValue": null,
"description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shortcut",
@@ -2038,7 +2122,7 @@
"type": "\"ghost\" | \"link\" | \"outline\" | \"soft\" | \"solid\"",
"required": false,
"defaultValue": "ghost",
- "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics."
+ "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics."
}
]
},
@@ -2094,7 +2178,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -2110,12 +2194,26 @@
"defaultValue": "center",
"description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true (false for the built-in href anchor)",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shortcut",
@@ -2157,7 +2255,7 @@
"type": "\"ghost\" | \"link\" | \"outline\" | \"soft\" | \"solid\"",
"required": false,
"defaultValue": "outline",
- "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; `href` still determines link semantics."
+ "description": "Visual treatment of the button surface. `link` uses compact text styling without a filled surface or border; render composition determines native semantics."
}
]
},
@@ -2178,7 +2276,7 @@
"type": "\"accent\" | \"danger\" | \"neutral\" | \"success\"",
"required": false,
"defaultValue": null,
- "description": "Shared semantic color that overrides the color of buttons in the group."
+ "description": "Default semantic color for children without an explicit color."
},
{
"name": "framed",
@@ -2199,14 +2297,14 @@
"type": "\"md\" | \"sm\"",
"required": false,
"defaultValue": null,
- "description": "Shared button height that overrides the size of buttons in the group."
+ "description": "Default button height for children without an explicit size."
},
{
"name": "variant",
"type": "\"ghost\" | \"link\" | \"outline\" | \"soft\" | \"solid\"",
"required": false,
"defaultValue": null,
- "description": "Shared surface treatment that overrides the variant of buttons in the group."
+ "description": "Default surface treatment for children without an explicit variant."
}
]
},
@@ -10556,14 +10654,28 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
+ },
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
},
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "size",
@@ -10981,7 +11093,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -10997,12 +11109,26 @@
"defaultValue": null,
"description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shortcut",
@@ -11170,7 +11296,7 @@
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Destination URL. Enables native link semantics instead of button semantics."
+ "description": "Destination URL. Renders a native anchor when `render` is omitted unless `nativeButton` is explicitly true. Custom renderers retain their own element contract."
},
{
"name": "loading",
@@ -11186,12 +11312,26 @@
"defaultValue": null,
"description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
},
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the rendered root is a native button. Defaults to true for custom renderers. The built-in `href` anchor defaults to false; an explicit value takes precedence."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
"required": false,
"defaultValue": null,
- "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ "description": "Caller-supplied root element or renderer. Native attributes, handlers, event details, and refs reach the rendered root. Use `nativeButton={false}` and `role=\"link\"` for a custom navigation anchor. Router integration belongs to the caller."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": null,
+ "description": "Role of the root element. Use `link` for custom navigation renderers."
},
{
"name": "shortcut",
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx b/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx
index ac8f00e8ecf..02df75e3674 100644
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx
@@ -259,6 +259,8 @@ export const CustomLink: Story = {
...CompactLink.args,
action: (
<InlineBanner.Action
+ nativeButton={false}
+ role="link"
href={'https://twenty.com'}
target={'_blank'}
rel={'noopener noreferrer'}
@@ -275,6 +277,7 @@ export const CustomLink: Story = {
const canvas = within(canvasElement);
const link = canvas.getByRole('link', { name: 'Open connection settings' });
+ await expect(link).not.toHaveAttribute('type');
await expect(link).toHaveAttribute('href', 'https://twenty.com');
await expect(link).toHaveAttribute('target', '_blank');
await expect(link).toHaveAttribute('rel', 'noopener noreferrer');
diff --git a/packages/twenty-ui/src/components/input/IconButton/IconButton.tsx b/packages/twenty-ui/src/components/input/IconButton/IconButton.tsx
index 16f644ccb4f..76f824f36ca 100644
--- a/packages/twenty-ui/src/components/input/IconButton/IconButton.tsx
+++ b/packages/twenty-ui/src/components/input/IconButton/IconButton.tsx
@@ -12,7 +12,7 @@ import { type IconButtonProps } from './types/IconButtonProps';
export const IconButton = ({
children,
- size = 'md',
+ size,
shape = 'square',
className,
tooltip,
@@ -24,13 +24,13 @@ export const IconButton = ({
...props
}: IconButtonProps) => {
const buttonGroup = useContext(ButtonGroupContext);
- const resolvedSize = buttonGroup?.size ?? size;
+ const resolvedSize = size ?? buttonGroup?.size ?? 'md';
const hasTooltip = isNonEmptyString(tooltip);
const isDisabled = disabled || loading;
const button = (
<Button
{...props}
- size={size === 'xs' ? 'sm' : size}
+ size={resolvedSize === 'xs' ? 'sm' : resolvedSize}
data-icon-size={resolvedSize}
data-shape={shape}
disabled={disabled}
diff --git a/packages/twenty-ui/src/components/input/IconButton/__stories__/IconButton.stories.tsx b/packages/twenty-ui/src/components/input/IconButton/__stories__/IconButton.stories.tsx
index 864d35947bd..ce10d049bc1 100644
--- a/packages/twenty-ui/src/components/input/IconButton/__stories__/IconButton.stories.tsx
+++ b/packages/twenty-ui/src/components/input/IconButton/__stories__/IconButton.stories.tsx
@@ -1,7 +1,8 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { expect, fn, userEvent, within } from 'storybook/test';
-import { IconPlus, IconSearch } from '@ui/icon';
+import { IconPlus, IconSearch, IconTrash } from '@ui/icon';
+import { Text } from '@ui/primitives/typography';
import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';
import { type ButtonColor } from '@ui/primitives/input/Button/types/ButtonColor';
import { type ButtonVariant } from '@ui/primitives/input/Button/types/ButtonVariant';
@@ -239,6 +240,8 @@ export const TooltipLink: Story = {
args: {
...Tooltip.args,
href: '#search',
+ nativeButton: false,
+ role: 'link',
render: (props) => (
<a {...props} data-custom-render>
{props.children}
@@ -385,3 +388,97 @@ export const Round: Story = {
await expect(getComputedStyle(disabled).opacity).toBe('1');
},
};
+
+export const LabelledBy: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <>
+ <Text render={<span />} id="search-records-label">
+ Search records
+ </Text>
+ <IconButton
+ aria-labelledby="search-records-label"
+ tooltip="Find a record"
+ tooltipDelay={0}
+ >
+ <IconSearch />
+ </IconButton>
+ </>
+ ),
+};
+
+export const LabelledByInteraction: Story = {
+ ...LabelledBy,
+ play: async ({ canvasElement }) => {
+ const button = within(canvasElement).getByRole('button', {
+ name: 'Search records',
+ });
+
+ await expect(button).not.toHaveAttribute('aria-label');
+ button.focus();
+ await expect(button).toHaveFocus();
+ await expect(
+ await within(canvasElement.ownerDocument.body).findByRole('tooltip'),
+ ).toHaveTextContent('Find a record');
+ await expect(button).toHaveAccessibleName('Search records');
+ },
+};
+
+export const GroupedOverrides: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <ButtonGroup
+ aria-label="Record appearance"
+ variant="solid"
+ color="accent"
+ size="sm"
+ >
+ <IconButton
+ variant="outline"
+ color="neutral"
+ size="xs"
+ aria-label="Search records"
+ tooltip="Search records"
+ >
+ <IconSearch />
+ </IconButton>
+ <IconButton aria-label="Create record" tooltip="Create record">
+ <IconPlus />
+ </IconButton>
+ </ButtonGroup>
+ ),
+};
+
+export const GroupedOverridesInteraction: Story = {
+ ...GroupedOverrides,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const searchButton = canvas.getByRole('button', { name: 'Search records' });
+ const createButton = canvas.getByRole('button', { name: 'Create record' });
+
+ await expect(searchButton).toHaveAttribute('data-variant', 'outline');
+ await expect(searchButton).toHaveAttribute('data-color', 'neutral');
+ await expect(searchButton).toHaveAttribute('data-icon-size', 'xs');
+ await expect(searchButton.getBoundingClientRect().width).toBe(20);
+ await expect(searchButton.getBoundingClientRect().height).toBe(20);
+ await expect(createButton).toHaveAttribute('data-variant', 'solid');
+ await expect(createButton).toHaveAttribute('data-color', 'accent');
+ await expect(createButton).toHaveAttribute('data-icon-size', 'sm');
+ await expect(createButton.getBoundingClientRect().width).toBe(24);
+ await expect(createButton.getBoundingClientRect().height).toBe(24);
+ },
+};
+
+export const FramedGroupDocumentation: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <ButtonGroup framed attached={false} aria-label="Record actions">
+ <IconButton size="xs" aria-label="Add" variant="ghost">
+ <IconPlus />
+ </IconButton>
+ <IconButton size="xs" aria-label="Delete" variant="ghost" disabled>
+ <IconTrash />
+ </IconButton>
+ </ButtonGroup>
+ ),
+};
diff --git a/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts b/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts
index e70baa493f1..a93de2edfc7 100644
--- a/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts
+++ b/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts
@@ -9,6 +9,7 @@ export type IconButtonProps = Omit<
ButtonProps,
| 'size'
| 'aria-label'
+ | 'aria-labelledby'
| 'children'
| 'startIcon'
| 'endIcon'
@@ -20,9 +21,11 @@ export type IconButtonProps = Omit<
size?: IconButtonSize;
shape?: 'square' | 'round';
children: ReactNode;
- 'aria-label': string;
tooltip?: string;
tooltipPlace?: TooltipSide;
tooltipDelay?: number;
tooltipOffset?: number;
-};
+} & (
+ | { 'aria-label': string; 'aria-labelledby'?: string }
+ | { 'aria-label'?: string; 'aria-labelledby': string }
+ );
diff --git a/packages/twenty-ui/src/components/input/LightButton/LightButton.tsx b/packages/twenty-ui/src/components/input/LightButton/LightButton.tsx
index ef5edd9db60..6828549d919 100644
--- a/packages/twenty-ui/src/components/input/LightButton/LightButton.tsx
+++ b/packages/twenty-ui/src/components/input/LightButton/LightButton.tsx
@@ -1,4 +1,7 @@
+import { useContext } from 'react';
+
import { Button } from '@ui/primitives/input/Button/Button';
+import { ButtonGroupContext } from '@ui/primitives/input/ButtonGroup/internal/ButtonGroupContext';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
import styles from './LightButton.module.scss';
@@ -7,15 +10,21 @@ import { type LightButtonProps } from './types/LightButtonProps';
export const LightButton = ({
className,
emphasis = 'standard',
- size = 'sm',
- variant = 'ghost',
+ size,
+ variant,
...props
-}: LightButtonProps) => (
- <Button
- {...props}
- size={size}
- variant={variant}
- data-emphasis={emphasis}
- className={mergeClassNames(styles.button, className)}
- />
-);
+}: LightButtonProps) => {
+ const buttonGroup = useContext(ButtonGroupContext);
+ const resolvedSize = size ?? buttonGroup?.size ?? 'sm';
+ const resolvedVariant = variant ?? buttonGroup?.variant ?? 'ghost';
+
+ return (
+ <Button
+ {...props}
+ size={resolvedSize}
+ variant={resolvedVariant}
+ data-emphasis={emphasis}
+ className={mergeClassNames(styles.button, className)}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/LightButton/__stories__/LightButton.stories.tsx b/packages/twenty-ui/src/components/input/LightButton/__stories__/LightButton.stories.tsx
index eca45156cc0..f51e3e37bf5 100644
--- a/packages/twenty-ui/src/components/input/LightButton/__stories__/LightButton.stories.tsx
+++ b/packages/twenty-ui/src/components/input/LightButton/__stories__/LightButton.stories.tsx
@@ -79,7 +79,13 @@ export const SemanticAndGroupAppearance: Story = {
<LightButton emphasis="subtle" color="danger">
Group action
</LightButton>
- <Button>Group reference</Button>
+ <Button color="danger">Group reference</Button>
+ <LightButton emphasis="subtle" color="danger" variant="ghost" size="sm">
+ Explicit group action
+ </LightButton>
+ <Button color="danger" variant="ghost" size="sm">
+ Explicit group reference
+ </Button>
</ButtonGroup>
</>
),
@@ -89,6 +95,7 @@ export const SemanticAndGroupAppearance: Story = {
['Delete record', 'Danger reference'],
['Solid action', 'Solid reference'],
['Group action', 'Group reference'],
+ ['Explicit group action', 'Explicit group reference'],
]) {
const action = canvas.getByRole('button', { name: actionName });
const reference = canvas.getByRole('button', { name: referenceName });
@@ -99,11 +106,17 @@ export const SemanticAndGroupAppearance: Story = {
getComputedStyle(reference).backgroundColor,
);
}
- await expect(
- canvas
- .getByRole('button', { name: 'Group action' })
- .getBoundingClientRect().height,
- ).toBe(32);
+ const grouped = canvas.getByRole('button', { name: 'Group action' });
+ const explicit = canvas.getByRole('button', {
+ name: 'Explicit group action',
+ });
+
+ await expect(grouped).toHaveAttribute('data-color', 'danger');
+ await expect(grouped).toHaveAttribute('data-variant', 'outline');
+ await expect(grouped.getBoundingClientRect().height).toBe(32);
+ await expect(explicit).toHaveAttribute('data-color', 'danger');
+ await expect(explicit).toHaveAttribute('data-variant', 'ghost');
+ await expect(explicit.getBoundingClientRect().height).toBe(24);
},
};
diff --git a/packages/twenty-ui/src/components/input/LightButton/__tests__/LightButton.test.tsx b/packages/twenty-ui/src/components/input/LightButton/__tests__/LightButton.test.tsx
index cefdcf75e4f..5d70ff64fa2 100644
--- a/packages/twenty-ui/src/components/input/LightButton/__tests__/LightButton.test.tsx
+++ b/packages/twenty-ui/src/components/input/LightButton/__tests__/LightButton.test.tsx
@@ -1,3 +1,6 @@
+import { render, screen } from '@testing-library/react';
+import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';
+
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
import { LightButton } from '../LightButton';
@@ -9,3 +12,42 @@ runComponentConformance({
refInstanceOf: HTMLButtonElement,
ownClassName: styles.button,
});
+
+describe('LightButton appearance', () => {
+ it('retains its standalone defaults', () => {
+ render(<LightButton>Save changes</LightButton>);
+
+ const button = screen.getByRole('button', { name: 'Save changes' });
+
+ expect(button).toHaveAttribute('data-variant', 'ghost');
+ expect(button).toHaveAttribute('data-size', 'sm');
+ });
+
+ it('inherits omitted appearance from ButtonGroup', () => {
+ render(
+ <ButtonGroup variant="solid" size="md">
+ <LightButton>Save changes</LightButton>
+ </ButtonGroup>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Save changes' });
+
+ expect(button).toHaveAttribute('data-variant', 'solid');
+ expect(button).toHaveAttribute('data-size', 'md');
+ });
+
+ it('uses explicit appearance before ButtonGroup defaults', () => {
+ render(
+ <ButtonGroup variant="solid" size="md">
+ <LightButton variant="outline" size="sm">
+ Save changes
+ </LightButton>
+ </ButtonGroup>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Save changes' });
+
+ expect(button).toHaveAttribute('data-variant', 'outline');
+ expect(button).toHaveAttribute('data-size', 'sm');
+ });
+});
diff --git a/packages/twenty-ui/src/components/input/LightIconButton/LightIconButton.tsx b/packages/twenty-ui/src/components/input/LightIconButton/LightIconButton.tsx
index 42554c1a809..9f77bffe0df 100644
--- a/packages/twenty-ui/src/components/input/LightIconButton/LightIconButton.tsx
+++ b/packages/twenty-ui/src/components/input/LightIconButton/LightIconButton.tsx
@@ -1,4 +1,7 @@
+import { useContext } from 'react';
+
import { IconButton } from '@ui/components/input/IconButton/IconButton';
+import { ButtonGroupContext } from '@ui/primitives/input/ButtonGroup/internal/ButtonGroupContext';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
import styles from './LightIconButton.module.scss';
@@ -7,15 +10,21 @@ import { type LightIconButtonProps } from './types/LightIconButtonProps';
export const LightIconButton = ({
className,
emphasis = 'standard',
- size = 'sm',
- variant = 'ghost',
+ size,
+ variant,
...props
-}: LightIconButtonProps) => (
- <IconButton
- {...props}
- size={size}
- variant={variant}
- data-emphasis={emphasis}
- className={mergeClassNames(styles.button, className)}
- />
-);
+}: LightIconButtonProps) => {
+ const buttonGroup = useContext(ButtonGroupContext);
+ const resolvedSize = size ?? buttonGroup?.size ?? 'sm';
+ const resolvedVariant = variant ?? buttonGroup?.variant ?? 'ghost';
+
+ return (
+ <IconButton
+ {...props}
+ size={resolvedSize}
+ variant={resolvedVariant}
+ data-emphasis={emphasis}
+ className={mergeClassNames(styles.button, className)}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/LightIconButton/__stories__/LightIconButton.stories.tsx b/packages/twenty-ui/src/components/input/LightIconButton/__stories__/LightIconButton.stories.tsx
index 8431ce10b63..3f8dcd71cc1 100644
--- a/packages/twenty-ui/src/components/input/LightIconButton/__stories__/LightIconButton.stories.tsx
+++ b/packages/twenty-ui/src/components/input/LightIconButton/__stories__/LightIconButton.stories.tsx
@@ -58,13 +58,35 @@ export const Appearance: Story = {
<LightIconButton aria-label="Disabled" disabled>
<IconSearch />
</LightIconButton>
- <ButtonGroup color="danger" size="md" variant="solid">
+ <ButtonGroup
+ aria-label="Shared appearance"
+ color="danger"
+ size="md"
+ variant="solid"
+ >
<LightIconButton aria-label="Group action" emphasis="subtle">
<IconSearch />
</LightIconButton>
<IconButton aria-label="Reference">
<IconSearch />
</IconButton>
+ <LightIconButton
+ aria-label="Explicit group action"
+ emphasis="subtle"
+ color="accent"
+ variant="ghost"
+ size="xs"
+ >
+ <IconSearch />
+ </LightIconButton>
+ <IconButton
+ aria-label="Explicit reference"
+ color="accent"
+ variant="ghost"
+ size="xs"
+ >
+ <IconSearch />
+ </IconButton>
</ButtonGroup>
</>
),
@@ -93,7 +115,26 @@ export const Appearance: Story = {
await expect(getComputedStyle(grouped).color).toBe(
getComputedStyle(reference).color,
);
+ await expect(grouped).toHaveAttribute('data-variant', 'solid');
await expect(grouped.getBoundingClientRect().width).toBe(32);
+ await expect(grouped.getBoundingClientRect().height).toBe(32);
+ const explicit = canvas.getByRole('button', {
+ name: 'Explicit group action',
+ });
+ const explicitReference = canvas.getByRole('button', {
+ name: 'Explicit reference',
+ });
+
+ await expect(getComputedStyle(explicit).color).toBe(
+ getComputedStyle(explicitReference).color,
+ );
+ await expect(getComputedStyle(explicit).backgroundColor).toBe(
+ getComputedStyle(explicitReference).backgroundColor,
+ );
+ await expect(explicit).toHaveAttribute('data-color', 'accent');
+ await expect(explicit).toHaveAttribute('data-variant', 'ghost');
+ await expect(explicit.getBoundingClientRect().width).toBe(20);
+ await expect(explicit.getBoundingClientRect().height).toBe(20);
await expect(
canvas.getByRole('button', { name: 'Disabled' }),
).toBeDisabled();
diff --git a/packages/twenty-ui/src/components/input/LightIconButton/__tests__/LightIconButton.test.tsx b/packages/twenty-ui/src/components/input/LightIconButton/__tests__/LightIconButton.test.tsx
index 2cf9e0f09f2..4a1cf081b48 100644
--- a/packages/twenty-ui/src/components/input/LightIconButton/__tests__/LightIconButton.test.tsx
+++ b/packages/twenty-ui/src/components/input/LightIconButton/__tests__/LightIconButton.test.tsx
@@ -1,3 +1,6 @@
+import { render, screen } from '@testing-library/react';
+import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';
+
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
import { IconSearch } from '@ui/icon';
@@ -14,3 +17,48 @@ runComponentConformance({
refInstanceOf: HTMLButtonElement,
ownClassName: styles.button,
});
+
+describe('LightIconButton appearance', () => {
+ it('retains its standalone defaults', () => {
+ render(
+ <LightIconButton aria-label="Search">
+ <IconSearch />
+ </LightIconButton>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Search' });
+
+ expect(button).toHaveAttribute('data-variant', 'ghost');
+ expect(button).toHaveAttribute('data-size', 'sm');
+ });
+
+ it('inherits omitted appearance from ButtonGroup', () => {
+ render(
+ <ButtonGroup variant="solid" size="md">
+ <LightIconButton aria-label="Search">
+ <IconSearch />
+ </LightIconButton>
+ </ButtonGroup>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Search' });
+
+ expect(button).toHaveAttribute('data-variant', 'solid');
+ expect(button).toHaveAttribute('data-size', 'md');
+ });
+
+ it('uses explicit appearance before ButtonGroup defaults', () => {
+ render(
+ <ButtonGroup variant="solid" size="md">
+ <LightIconButton aria-label="Search" variant="outline" size="sm">
+ <IconSearch />
+ </LightIconButton>
+ </ButtonGroup>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Search' });
+
+ expect(button).toHaveAttribute('data-variant', 'outline');
+ expect(button).toHaveAttribute('data-size', 'sm');
+ });
+});
diff --git a/packages/twenty-ui/src/components/input/MainButton/MainButton.tsx b/packages/twenty-ui/src/components/input/MainButton/MainButton.tsx
index 5bedb474f96..1d50e77807c 100644
--- a/packages/twenty-ui/src/components/input/MainButton/MainButton.tsx
+++ b/packages/twenty-ui/src/components/input/MainButton/MainButton.tsx
@@ -1,5 +1,8 @@
+import { useContext } from 'react';
+
import { Button } from '@ui/primitives/input/Button/Button';
import { type ButtonProps } from '@ui/primitives/input/Button/types/ButtonProps';
+import { ButtonGroupContext } from '@ui/primitives/input/ButtonGroup/internal/ButtonGroupContext';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
import styles from './MainButton.module.scss';
@@ -7,13 +10,18 @@ import styles from './MainButton.module.scss';
export const MainButton = ({
className,
elevated = true,
- variant = 'solid',
+ variant,
...props
-}: ButtonProps) => (
- <Button
- {...props}
- elevated={elevated}
- variant={variant}
- className={mergeClassNames(styles.button, className)}
- />
-);
+}: ButtonProps) => {
+ const buttonGroup = useContext(ButtonGroupContext);
+ const resolvedVariant = variant ?? buttonGroup?.variant ?? 'solid';
+
+ return (
+ <Button
+ {...props}
+ elevated={elevated}
+ variant={resolvedVariant}
+ className={mergeClassNames(styles.button, className)}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/MainButton/__tests__/MainButton.test.tsx b/packages/twenty-ui/src/components/input/MainButton/__tests__/MainButton.test.tsx
index 6bce5efc7ff..a6f04eb12e9 100644
--- a/packages/twenty-ui/src/components/input/MainButton/__tests__/MainButton.test.tsx
+++ b/packages/twenty-ui/src/components/input/MainButton/__tests__/MainButton.test.tsx
@@ -1,3 +1,6 @@
+import { render, screen } from '@testing-library/react';
+import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';
+
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
import { MainButton } from '../MainButton';
@@ -9,3 +12,37 @@ runComponentConformance({
refInstanceOf: HTMLButtonElement,
ownClassName: styles.button,
});
+
+describe('MainButton appearance', () => {
+ it('retains its standalone defaults', () => {
+ render(<MainButton>Save changes</MainButton>);
+
+ const button = screen.getByRole('button', { name: 'Save changes' });
+
+ expect(button).toHaveAttribute('data-variant', 'solid');
+ });
+
+ it('inherits omitted appearance from ButtonGroup', () => {
+ render(
+ <ButtonGroup variant="ghost">
+ <MainButton>Save changes</MainButton>
+ </ButtonGroup>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Save changes' });
+
+ expect(button).toHaveAttribute('data-variant', 'ghost');
+ });
+
+ it('uses explicit appearance before ButtonGroup defaults', () => {
+ render(
+ <ButtonGroup variant="ghost">
+ <MainButton variant="outline">Save changes</MainButton>
+ </ButtonGroup>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Save changes' });
+
+ expect(button).toHaveAttribute('data-variant', 'outline');
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/input/Button/Button.tsx b/packages/twenty-ui/src/primitives/input/Button/Button.tsx
index aa88d054c59..81da53a57ac 100644
--- a/packages/twenty-ui/src/primitives/input/Button/Button.tsx
+++ b/packages/twenty-ui/src/primitives/input/Button/Button.tsx
@@ -12,9 +12,9 @@ import styles from './Button.module.scss';
import { type ButtonProps } from './types/ButtonProps';
export const Button = ({
- variant = 'outline',
- color = 'neutral',
- size = 'md',
+ variant,
+ color,
+ size,
fullWidth = false,
loading = false,
loadingPosition = 'center',
@@ -26,16 +26,23 @@ export const Button = ({
disabled = false,
href,
render,
+ nativeButton,
+ role,
className,
children,
...props
}: ButtonProps) => {
const buttonGroup = useContext(ButtonGroupContext);
- const resolvedVariant = buttonGroup?.variant ?? variant;
- const resolvedColor = buttonGroup?.color ?? color;
- const resolvedSize = buttonGroup?.size ?? size;
- const isLink = isDefined(href);
- const linkProps = isLink ? { href } : undefined;
+ const resolvedVariant = variant ?? buttonGroup?.variant ?? 'outline';
+ const resolvedColor = color ?? buttonGroup?.color ?? 'neutral';
+ const resolvedSize = size ?? buttonGroup?.size ?? 'md';
+ const isAutomaticLink =
+ isDefined(href) && !isDefined(render) && nativeButton !== true;
+ const linkProps = isDefined(href) ? { href } : undefined;
+ const resolvedRole = role ?? (isAutomaticLink ? 'link' : undefined);
+ const roleProps = isDefined(resolvedRole)
+ ? { role: resolvedRole }
+ : undefined;
const isCenterLoading = loading && loadingPosition === 'center';
const resolvedStartIcon =
loading && loadingPosition === 'start' ? <Loader /> : startIcon;
@@ -55,9 +62,11 @@ export const Button = ({
data-elevated={elevated || undefined}
aria-busy={loading ? 'true' : props['aria-busy']}
disabled={disabled || loading}
- role={isLink ? 'link' : undefined}
- nativeButton={!isLink}
- render={render ?? (isLink ? <a href={href}>{children}</a> : undefined)}
+ {...roleProps}
+ nativeButton={nativeButton ?? !isAutomaticLink}
+ render={
+ render ?? (isAutomaticLink ? <a href={href}>{children}</a> : undefined)
+ }
>
<span className={clsx(styles.content, isCenterLoading && styles.hidden)}>
{isDefined(resolvedStartIcon) && (
diff --git a/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx b/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
index de282819d22..28d7b2e7914 100644
--- a/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
+++ b/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
@@ -105,11 +105,36 @@ export const Loading: Story = {
await expect(button).toBeEnabled();
},
};
+export const LoadingAtStart: Story = {
+ ...Default,
+ args: {
+ children: 'Creating record',
+ startIcon: <IconPlus />,
+ endIcon: <IconArrowRight />,
+ loading: true,
+ loadingPosition: 'start',
+ },
+};
+export const LoadingAtStartInteraction: Story = {
+ ...LoadingAtStart,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const button = canvas.getByRole('button', { name: 'Creating record' });
+ await expect(canvas.getByText('Creating record')).toBeVisible();
+ await expect(button).toHaveAttribute('aria-busy', 'true');
+ await expect(button).toBeDisabled();
+ await expect(button.querySelector('.tabler-icon-plus')).toBeNull();
+ await expect(
+ button.querySelector('.tabler-icon-arrow-right'),
+ ).toBeVisible();
+ },
+};
export const LoadingAtEnd: Story = {
...Default,
args: {
children: 'Installing (42%)',
startIcon: <IconDownload />,
+ endIcon: <IconArrowRight />,
loading: true,
loadingPosition: 'end',
},
@@ -122,6 +147,8 @@ export const LoadingAtEndInteraction: Story = {
await expect(canvas.getByText('Installing (42%)')).toBeVisible();
await expect(button).toHaveAttribute('aria-busy', 'true');
await expect(button).toBeDisabled();
+ await expect(button.querySelector('.tabler-icon-download')).toBeVisible();
+ await expect(button.querySelector('.tabler-icon-arrow-right')).toBeNull();
},
};
export const NativeForm: Story = {
@@ -258,3 +285,180 @@ export const CatalogDark: CatalogStory<Story, typeof Button> = {
tags: ['!autodocs'],
globals: { colorScheme: 'dark' },
};
+
+export const NativeButtonWithHref: Story = {
+ ...Default,
+ args: {
+ children: 'Open records',
+ nativeButton: true,
+ href: '#native-button-destination',
+ render: <button data-custom-button />,
+ ref: fn(),
+ onClick: fn(),
+ onPointerDown: fn(),
+ },
+ play: async ({ canvasElement, args }) => {
+ const button = within(canvasElement).getByRole('button', {
+ name: 'Open records',
+ });
+
+ await expect(button.tagName).toBe('BUTTON');
+ await expect(button).toHaveAttribute('type', 'button');
+ await expect(button).toHaveAttribute('data-custom-button');
+ await expect(args.ref).toHaveBeenCalledWith(button);
+ await userEvent.click(button);
+ await expect(args.onClick).toHaveBeenCalledWith(
+ expect.objectContaining({ type: 'click', button: 0, detail: 1 }),
+ );
+ await expect(args.onPointerDown).toHaveBeenCalledWith(
+ expect.objectContaining({ type: 'pointerdown', pointerType: 'mouse' }),
+ );
+ await userEvent.keyboard('{Enter} ');
+ await expect(args.onClick).toHaveBeenCalledTimes(3);
+ },
+};
+
+export const CustomButton: Story = {
+ ...Default,
+ args: {
+ children: 'Open records',
+ nativeButton: false,
+ render: <div data-custom-control />,
+ ref: fn(),
+ onClick: fn(),
+ },
+ play: async ({ canvasElement, args }) => {
+ const button = within(canvasElement).getByRole('button', {
+ name: 'Open records',
+ });
+
+ await expect(button.tagName).toBe('DIV');
+ await expect(button).not.toHaveAttribute('type');
+ await expect(args.ref).toHaveBeenCalledWith(button);
+ button.focus();
+ await userEvent.keyboard('{Enter} ');
+ await expect(args.onClick).toHaveBeenCalledTimes(2);
+ },
+};
+
+export const NativeAnchorAttributes: Story = {
+ ...Default,
+ args: {
+ children: 'Open records',
+ href: '#records-download',
+ download: 'records.csv',
+ hrefLang: 'en',
+ media: 'screen',
+ ping: '/download-audit',
+ referrerPolicy: 'no-referrer',
+ target: '_blank',
+ rel: 'noreferrer',
+ ref: fn(),
+ onClick: fn((event) => event.preventDefault()),
+ },
+ play: async ({ canvasElement, args }) => {
+ const link = within(canvasElement).getByRole('link', {
+ name: 'Open records',
+ });
+
+ await expect(link.tagName).toBe('A');
+ await expect(link).toHaveAttribute('href', '#records-download');
+ await expect(link).toHaveAttribute('download', 'records.csv');
+ await expect(link).toHaveAttribute('hreflang', 'en');
+ await expect(link).toHaveAttribute('media', 'screen');
+ await expect(link).toHaveAttribute('ping', '/download-audit');
+ await expect(link).toHaveAttribute('referrerpolicy', 'no-referrer');
+ await expect(link).toHaveAttribute('target', '_blank');
+ await expect(link).toHaveAttribute('rel', 'noreferrer');
+ await expect(link).not.toHaveAttribute('type');
+ await expect(args.ref).toHaveBeenCalledWith(link);
+ await userEvent.click(link);
+ await expect(args.onClick).toHaveBeenCalledWith(
+ expect.objectContaining({ type: 'click', defaultPrevented: true }),
+ );
+ },
+};
+
+const renderedLinkClick = fn();
+
+export const ComposedNavigation: Story = {
+ ...Default,
+ args: {
+ children: 'Open records',
+ nativeButton: false,
+ role: 'link',
+ render: (
+ <a href="#composed-records" type="text/csv" onClick={renderedLinkClick}>
+ Open records
+ </a>
+ ),
+ ref: fn(),
+ onClick: fn((event) => event.preventDefault()),
+ },
+ play: async ({ canvasElement, args }) => {
+ const link = within(canvasElement).getByRole('link', {
+ name: 'Open records',
+ });
+
+ await expect(link.tagName).toBe('A');
+ await expect(link).toHaveAttribute('href', '#composed-records');
+ await expect(link).toHaveAttribute('type', 'text/csv');
+ await expect(args.ref).toHaveBeenCalledWith(link);
+ link.focus();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onClick).toHaveBeenCalledOnce();
+ await expect(renderedLinkClick).toHaveBeenCalledOnce();
+ },
+};
+
+export const RenderCallback: Story = {
+ ...Default,
+ args: {
+ children: 'Open records',
+ nativeButton: false,
+ role: 'link',
+ href: '#callback-records',
+ disabled: true,
+ ref: fn(),
+ onClick: fn(),
+ render: (props, state) => (
+ <a {...props} data-render-disabled={state.disabled}>
+ {props.children}
+ </a>
+ ),
+ },
+ play: async ({ canvasElement, args }) => {
+ const link = within(canvasElement).getByRole('link', {
+ name: 'Open records',
+ });
+
+ await expect(link).toHaveAttribute('href', '#callback-records');
+ await expect(link).toHaveAttribute('data-render-disabled', 'true');
+ await expect(link).toHaveAttribute('aria-disabled', 'true');
+ await expect(args.ref).toHaveBeenCalledWith(link);
+ await userEvent.click(link);
+ await expect(args.onClick).not.toHaveBeenCalled();
+ },
+};
+
+export const CustomButtonKeyboardCancellation: Story = {
+ ...CustomButton,
+ args: {
+ ...CustomButton.args,
+ onKeyDown: fn((event) => event.preventBaseUIHandler()),
+ },
+ play: async ({ canvasElement, args }) => {
+ const button = within(canvasElement).getByRole('button', {
+ name: 'Open records',
+ });
+
+ button.focus();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onKeyDown).toHaveBeenCalledWith(
+ expect.objectContaining({ key: 'Enter' }),
+ );
+ await expect(args.onClick).not.toHaveBeenCalled();
+ await userEvent.click(button);
+ await expect(args.onClick).toHaveBeenCalledOnce();
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/input/Button/__tests__/Button.test.tsx b/packages/twenty-ui/src/primitives/input/Button/__tests__/Button.test.tsx
index 2c5a7ae8f5b..67ce1534e34 100644
--- a/packages/twenty-ui/src/primitives/input/Button/__tests__/Button.test.tsx
+++ b/packages/twenty-ui/src/primitives/input/Button/__tests__/Button.test.tsx
@@ -15,6 +15,29 @@ runComponentConformance({
ownClassName: styles.button,
});
+runComponentConformance({
+ name: 'Button link',
+ element: (
+ <Button href="#destination" nativeButton={false}>
+ Open record
+ </Button>
+ ),
+ refInstanceOf: HTMLAnchorElement,
+ ownClassName: styles.button,
+ renderPropTagName: 'a',
+});
+
+runComponentConformance({
+ name: 'Button custom element',
+ element: (
+ <Button nativeButton={false} render={<div />}>
+ Open record
+ </Button>
+ ),
+ refInstanceOf: HTMLDivElement,
+ ownClassName: styles.button,
+});
+
describe('Button loading', () => {
it('keeps content in its layout space behind the default centered spinner', () => {
render(
@@ -162,12 +185,14 @@ describe('Button loading', () => {
it('preserves custom link rendering and blocks activation while loading', async () => {
const user = userEvent.setup();
const onClick = vi.fn();
- const ref = createRef<HTMLButtonElement>();
+ const ref = createRef<HTMLAnchorElement>();
render(
<Button
ref={ref}
href="#destination"
+ nativeButton={false}
+ role="link"
render={
<a href="#destination" data-custom-render>
Installing
diff --git a/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts b/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts
index ce9fdc416ad..c0291515b36 100644
--- a/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts
+++ b/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts
@@ -8,10 +8,13 @@ import { type ButtonSize } from './ButtonSize';
import { type ButtonVariant } from './ButtonVariant';
export type ButtonProps = Omit<
- ButtonPrimitive.Props,
- 'color' | 'nativeButton' | 'role'
+ ComponentPropsWithRef<typeof ButtonPrimitive>,
+ 'color'
> &
- Pick<ComponentPropsWithRef<'a'>, 'href' | 'target' | 'rel' | 'download'> & {
+ Omit<
+ ComponentPropsWithRef<'a'>,
+ keyof ComponentPropsWithRef<typeof ButtonPrimitive>
+ > & {
variant?: ButtonVariant;
color?: ButtonColor;
size?: ButtonSize;
diff --git a/packages/twenty-ui/src/primitives/input/ButtonGroup/__stories__/ButtonGroup.stories.tsx b/packages/twenty-ui/src/primitives/input/ButtonGroup/__stories__/ButtonGroup.stories.tsx
index f48a4029da1..796a4265584 100644
--- a/packages/twenty-ui/src/primitives/input/ButtonGroup/__stories__/ButtonGroup.stories.tsx
+++ b/packages/twenty-ui/src/primitives/input/ButtonGroup/__stories__/ButtonGroup.stories.tsx
@@ -62,9 +62,7 @@ export const InheritedAppearance: Story = {
},
render: (args) => (
<ButtonGroup {...args}>
- <Button variant="ghost" color="danger" size="md">
- Direct action
- </Button>
+ <Button>Direct action</Button>
<>
<Button>Fragment action</Button>
</>
@@ -167,3 +165,45 @@ export const FramedAttached: Story = {
);
},
};
+
+export const AppearanceOverrides: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <ButtonGroup
+ aria-label="Activity appearance"
+ variant="solid"
+ color="accent"
+ size="sm"
+ >
+ <Button variant="ghost" color="danger" size="md">
+ Delete activity
+ </Button>
+ <Button color="neutral">Duplicate activity</Button>
+ <Button>New activity</Button>
+ </ButtonGroup>
+ ),
+};
+
+export const AppearanceOverridesInteraction: Story = {
+ ...AppearanceOverrides,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const deleteButton = canvas.getByRole('button', {
+ name: 'Delete activity',
+ });
+ const duplicateButton = canvas.getByRole('button', {
+ name: 'Duplicate activity',
+ });
+ const newButton = canvas.getByRole('button', { name: 'New activity' });
+
+ await expect(deleteButton).toHaveAttribute('data-variant', 'ghost');
+ await expect(deleteButton).toHaveAttribute('data-color', 'danger');
+ await expect(deleteButton).toHaveAttribute('data-size', 'md');
+ await expect(duplicateButton).toHaveAttribute('data-variant', 'solid');
+ await expect(duplicateButton).toHaveAttribute('data-color', 'neutral');
+ await expect(duplicateButton).toHaveAttribute('data-size', 'sm');
+ await expect(newButton).toHaveAttribute('data-variant', 'solid');
+ await expect(newButton).toHaveAttribute('data-color', 'accent');
+ await expect(newButton).toHaveAttribute('data-size', 'sm');
+ },
+};