Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
95 lines
3.3 KiB
Plaintext
95 lines
3.3 KiB
Plaintext
---
|
|
title: IconButton
|
|
description: Trigger actions with accessible square icon buttons.
|
|
---
|
|
|
|
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
|
|
|
|
import IconButtonReference from '/snippets/ui/generated/input/icon-button.mdx';
|
|
|
|
`IconButton` composes [Button](/ui/primitives/input/button) with a square surface. Pass the icon as children and provide an `aria-label` describing the action. Icon content is decorative and hidden from assistive technology.
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { IconButton } from 'twenty-ui/components';
|
|
import { IconPlus } from 'twenty-ui/icon';
|
|
|
|
export const CreateRecordButton = () => (
|
|
<IconButton
|
|
aria-label="Create record"
|
|
variant="solid"
|
|
color="accent"
|
|
size="sm"
|
|
>
|
|
<IconPlus />
|
|
</IconButton>
|
|
);
|
|
```
|
|
|
|
Sizes are `sm` (24px) and `md` (32px). The defaults are `md`, `outline`, and `neutral`. Variants and colors match Button.
|
|
|
|
<StoryEmbed
|
|
title="Icon button example"
|
|
storyId="ui-components-iconbutton--catalog"
|
|
height={620}
|
|
/>
|
|
|
|
## 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.
|
|
|
|
```tsx
|
|
import { IconButton } from 'twenty-ui/components';
|
|
import { IconSearch } from 'twenty-ui/icon';
|
|
|
|
export const SearchRecordsButton = () => (
|
|
<IconButton aria-label="Search" tooltip="Search records" variant="ghost">
|
|
<IconSearch />
|
|
</IconButton>
|
|
);
|
|
```
|
|
|
|
<StoryEmbed
|
|
title="Icon button with tooltip"
|
|
storyId="ui-components-iconbutton--tooltip"
|
|
height={180}
|
|
/>
|
|
|
|
The tooltip defaults to the bottom, with a 1000ms delay and a 5px offset. Use `tooltipPlace`, `tooltipDelay`, and `tooltipOffset` to adjust it. Omitting `tooltip` renders the button directly.
|
|
|
|
## State ownership
|
|
|
|
Your application supplies `loading` and `disabled`. Both prevent activation. Loading preserves the square dimensions and accessible label. The button does not track a selected value or set loading automatically after a click. Native keyboard focus follows the browser; use `aria-pressed` when your application owns a toggle state.
|
|
|
|
## Grouped actions
|
|
|
|
```tsx
|
|
import { ButtonGroup } from 'twenty-ui/primitives/input';
|
|
import { IconButton } from 'twenty-ui/components';
|
|
import { IconPlus, IconSearch } from 'twenty-ui/icon';
|
|
|
|
export const RecordActions = () => (
|
|
<ButtonGroup aria-label="Record actions" size="sm" variant="outline">
|
|
<IconButton aria-label="Search records">
|
|
<IconSearch />
|
|
</IconButton>
|
|
<IconButton aria-label="Create record">
|
|
<IconPlus />
|
|
</IconButton>
|
|
</ButtonGroup>
|
|
);
|
|
```
|
|
|
|
[ButtonGroup](/ui/primitives/input/button-group) supplies size, variant, color, and adjoining corners. Individual buttons do not need a position prop.
|
|
|
|
## 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.
|
|
|
|
Native attributes, event handlers, refs, and render composition pass through to Button. The default is `type="button"`; set `type="submit"` explicitly for form submission.
|
|
|
|
## Props
|
|
|
|
<IconButtonReference />
|