# PrimaryActionButton

**Category:** Features/Actions/PrimaryActions

## Design

### Description

The `PrimaryActionButton` component displays a primary action button in the table toolbar. Use this component when you want to add a primary action button to a table.


### Basic Primary Action Button

Adds a Primary Action Button using the `` `primaryActionButton` prop.

```tsx
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { Page } from '@wix/design-system';
import {
  Table,
  PageWrapper,
  PrimaryActionButton,
  useTableCollection,
  OffsetQuery,
} from '@wix/patterns';
import { contacts } from '@wix/crm';

function Default() {
  const state = useTableCollection<contacts.Contact>({
    queryName: 'contacts-PrimaryActionButton',
    paginationMode: 'offset',
    fqdn: 'wix.patterns.dummyservice.v1.dummy_entity',
    fetchData: (query: OffsetQuery) => {
      const { limit, offset, search, filters } = query;

      let queryBuilder = contacts.queryContacts().limit(limit).skip(offset);

      if (search) {
        queryBuilder = queryBuilder.startsWith('info.name.first', search);
      }

      return queryBuilder.find().then(({ items = [], totalCount: total }) => ({
        items,
        total,
      }));
    },
    itemName: (item) => `${item.info?.name?.first} ${item.info?.name?.last}`,
    fetchErrorMessage: () => 'Error fetching contacts',
    filters: {},
  });

  return (
    <PageWrapper>
      <Page height="400px">
        <Page.Header />
        <Page.Content>
          <Table
            state={state}
            primaryActionButton={<PrimaryActionButton />}
            columns={[
              {
                id: 'name',
                title: 'Name',
                width: '250px',
                render: (contact) =>
                  `${contact.info?.name?.first} ${contact.info?.name?.last}`,
              },
            ]}
          />
        </Page.Content>
      </Page>
    </PageWrapper>
  );
}
```

---

### Customized Primary Action Button

`` is customized using its props and children.

```tsx
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { Page } from '@wix/design-system';
import {
  PrimaryActionButton,
  Table,
  PageWrapper,
  useTableCollection,
  OffsetQuery,
} from '@wix/patterns';
import { contacts } from '@wix/crm';

function OverrideButtonDefaults() {

  const state = useTableCollection<contacts.Contact>({
    queryName: 'contacts-PrimaryActionButton',
    paginationMode: 'offset',
    fqdn: 'wix.patterns.dummyservice.v1.dummy_entity',
    fetchData: (query: OffsetQuery) => {
      const { limit, offset, search, filters } = query;

      let queryBuilder = contacts.queryContacts().limit(limit).skip(offset);

      if (search) {
        queryBuilder = queryBuilder.startsWith('info.name.first', search);
      }

      return queryBuilder.find().then(({ items = [], totalCount: total }) => ({
        items,
        total,
      }));
    },
    itemName: (item) => `${item.info?.name?.first} ${item.info?.name?.last}`,
    fetchErrorMessage: () => 'Error fetching contacts',
    filters: {},
  });

  return (
    <PageWrapper>
      <Page height="400px">
        <Page.Header />
        <Page.Content>
          <Table
            state={state}
            primaryActionButton={
              <PrimaryActionButton prefixIcon={undefined}>
                Edit
              </PrimaryActionButton>
            }
            columns={[
              {
                id: 'name',
                title: 'Name',
                width: '250px',
                render: (contact) =>
                  `${contact.info?.name?.first} ${contact.info?.name?.last}`,
              },
            ]}
          />
        </Page.Content>
      </Page>
    </PageWrapper>
  );
}
```

---

### Secondary skin

Should be used in case the collection appears as a card and isn't the main content of the page.

```tsx
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { Page } from '@wix/design-system';
import {
  PrimaryActionButton,
  Table,
  PageWrapper,
  useTableCollection,
  OffsetQuery,
} from '@wix/patterns';
import { contacts } from '@wix/crm';

function OverrideButtonDefaults() {

  const state = useTableCollection<contacts.Contact>({
    queryName: 'contacts-PrimaryActionButton',
    paginationMode: 'offset',
    fqdn: 'wix.patterns.dummyservice.v1.dummy_entity',
    fetchData: (query: OffsetQuery) => {
      const { limit, offset, search, filters } = query;

      let queryBuilder = contacts.queryContacts().limit(limit).skip(offset);

      if (search) {
        queryBuilder = queryBuilder.startsWith('info.name.first', search);
      }

      return queryBuilder.find().then(({ items = [], totalCount: total }) => ({
        items,
        total,
      }));
    },
    itemName: (item) => `${item.info?.name?.first} ${item.info?.name?.last}`,
    fetchErrorMessage: () => 'Error fetching contacts',
    filters: {},
  });

  return (
    <PageWrapper>
      <Page height="400px">
        <Page.Header />
        <Page.Content>
          <Table
            state={state}
            primaryActionButton={
              <PrimaryActionButton prefixIcon={undefined}>
                Edit
              </PrimaryActionButton>
            }
            columns={[
              {
                id: 'name',
                title: 'Name',
                width: '250px',
                render: (contact) =>
                  `${contact.info?.name?.first} ${contact.info?.name?.last}`,
              },
            ]}
          />
        </Page.Content>
      </Page>
    </PageWrapper>
  );
}
```

## API

### Extends

[ButtonProps](https://www.docs.wixdesignsystem.com/?path=/story/components-actions--button)

### Props

| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `onClick` | `any` | No | - | Callback that is called each time the button is clicked. |
| `className` | `string` | No | - | Specifies a CSS class name to be appended to the component’s root element. |
| `children` | `string \| number \| boolean \| {} \| ReactElement<any, string \| JSXElementConstructor<any>> \| ReactNodeArray \| ReactPortal \| ... 39 more ...` | No | - | Accepts any item as a child element. For all common cases pass a standard text string. |
| `disabled` | `boolean` | No | - | Specifies whether user interactions are disabled. |
| `ellipsis` | `boolean` | No | - | Specifies whether component handles text overflow with ellipsis. If enabled, label that exceed available space will be displayed inside of a tooltip when user hover over a button. |
| `prefixIcon` | `IconElement` | No | - | Pass an icon or a component to display at the front of a label (e.g., svg, image, etc.) |
| `suffixIcon` | `IconElement` | No | - | Pass an icon or a component to display at the end of a label (e.g., svg, image, etc.) |
| `aria-label` | `any` | No | - | Defines a string value that labels the current element. @see aria-labelledby. |
| `internalDataHook` | `string` | No | - | Applies internal dataHook for internal testkits |
| `inputMode` | `any` | No | - | Hints at the type of data that might be entered by the user while editing the element or its contents @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute |
| `is` | `any` | No | - | Specify that a standard HTML element should behave like a defined custom built-in element @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is |
| `aria-activedescendant` | `any` | No | - | Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. |
| `aria-atomic` | `any` | No | - | Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. |
| `aria-autocomplete` | `any` | No | - | Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made. |
| `aria-busy` | `any` | No | - | Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. |
| `aria-checked` | `any` | No | - | Indicates the current "checked" state of checkboxes, radio buttons, and other widgets. @see aria-pressed @see aria-selected. |
| `aria-colcount` | `any` | No | - | Defines the total number of columns in a table, grid, or treegrid. @see aria-colindex. |
| `aria-colindex` | `any` | No | - | Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid. @see aria-colcount @see aria-colspan. |
| `aria-colspan` | `any` | No | - | Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid. @see aria-colindex @see aria-rowspan. |
| `aria-controls` | `any` | No | - | Identifies the element (or elements) whose contents or presence are controlled by the current element. @see aria-owns. |
| `aria-current` | `any` | No | - | Indicates the element that represents the current item within a container or set of related elements. |
| `aria-describedby` | `any` | No | - | Identifies the element (or elements) that describes the object. @see aria-labelledby |
| `aria-details` | `any` | No | - | Identifies the element that provides a detailed, extended description for the object. @see aria-describedby. |
| `aria-disabled` | `any` | No | - | Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. @see aria-hidden @see aria-readonly. |
| `aria-dropeffect` | `any` | No | - | Indicates what functions can be performed when a dragged object is released on the drop target. @deprecated in ARIA 1.1 |
| `aria-errormessage` | `any` | No | - | Identifies the element that provides an error message for the object. @see aria-invalid @see aria-describedby. |
| `aria-expanded` | `any` | No | - | Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. |
| `aria-flowto` | `any` | No | - | Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order. |
| `aria-grabbed` | `any` | No | - | Indicates an element's "grabbed" state in a drag-and-drop operation. @deprecated in ARIA 1.1 |
| `aria-haspopup` | `any` | No | - | Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. |
| `aria-hidden` | `any` | No | - | Indicates whether the element is exposed to an accessibility API. @see aria-disabled. |
| `aria-invalid` | `any` | No | - | Indicates the entered value does not conform to the format expected by the application. @see aria-errormessage. |
| `aria-keyshortcuts` | `any` | No | - | Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. |
| `aria-labelledby` | `any` | No | - | Identifies the element (or elements) that labels the current element. @see aria-describedby. |
| `aria-level` | `any` | No | - | Defines the hierarchical level of an element within a structure. |
| `aria-live` | `any` | No | - | Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. |
| `aria-modal` | `any` | No | - | Indicates whether an element is modal when displayed. |
| `aria-multiline` | `any` | No | - | Indicates whether a text box accepts multiple lines of input or only a single line. |
| `aria-multiselectable` | `any` | No | - | Indicates that the user may select more than one item from the current selectable descendants. |
| `aria-orientation` | `any` | No | - | Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. |
| `aria-owns` | `any` | No | - | Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship. @see aria-controls. |
| `aria-placeholder` | `any` | No | - | Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format. |
| `aria-posinset` | `any` | No | - | Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. @see aria-setsize. |
| `aria-pressed` | `any` | No | - | Indicates the current "pressed" state of toggle buttons. @see aria-checked @see aria-selected. |
| `aria-readonly` | `any` | No | - | Indicates that the element is not editable, but is otherwise operable. @see aria-disabled. |
| `aria-relevant` | `any` | No | - | Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. @see aria-atomic. |
| `aria-required` | `any` | No | - | Indicates that user input is required on the element before a form may be submitted. |
| `aria-roledescription` | `any` | No | - | Defines a human-readable, author-localized description for the role of an element. |
| `aria-rowcount` | `any` | No | - | Defines the total number of rows in a table, grid, or treegrid. @see aria-rowindex. |
| `aria-rowindex` | `any` | No | - | Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid. @see aria-rowcount @see aria-rowspan. |
| `aria-rowspan` | `any` | No | - | Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid. @see aria-rowindex @see aria-colspan. |
| `aria-selected` | `any` | No | - | Indicates the current "selected" state of various widgets. @see aria-checked @see aria-pressed. |
| `aria-setsize` | `any` | No | - | Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. @see aria-posinset. |
| `aria-sort` | `any` | No | - | Indicates if items in a table or grid are sorted in ascending or descending order. |
| `aria-valuemax` | `any` | No | - | Defines the maximum allowed value for a range widget. |
| `aria-valuemin` | `any` | No | - | Defines the minimum allowed value for a range widget. |
| `aria-valuenow` | `any` | No | - | Defines the current value for a range widget. @see aria-valuetext. |
| `aria-valuetext` | `any` | No | - | Defines the human readable text alternative of aria-valuenow for a range widget. |
| `onKeyPress` | `any` | No | - | @deprecated |
| `onKeyPressCapture` | `any` | No | - | @deprecated |
| `onPointerEnterCapture` | `any` | No | - | @deprecated This event handler was always ignored by React. It was added by mistake to the types. |
| `onPointerLeaveCapture` | `any` | No | - | @deprecated This event handler was always ignored by React. It was added by mistake to the types. |
| `priority` | `"primary" \| "secondary"` | No | - | Specifies the priority of a button. |
| `showTooltip` | `boolean` | No | - | Specifies whether the full button label is displayed in a tooltip when label overflows available space. Behaviour is enabled by default. Set property value to false to show ellipsis without a tooltip. |
| `tooltipProps` | `TooltipCommonProps` | No | - | Allows to pass all common tooltip props. Use it to customize a tooltip created from text ellipsis. @linkTypeTo components-overlays--tooltip |

## BI

### PrimaryActionButton BI Events

 Event   |   Description   |
--------- | --------------- |
[144:106](https://bo.wix.com/data-tools/bi-catalog-app/event/144:106) | Sent when the user clicks the "create new" button
[144:107](https://bo.wix.com/data-tools/bi-catalog-app/event/144:107) | Sent when the "create new" process ends (and the result is shown to the user)





### Component load events
Event   |   Description   |
--------- | --------------- |
[144:110](https://bo.wix.com/data-tools/bi-catalog-app/event/144:110) | Sent when a Wix Patterns component starts loading
[144:111](https://bo.wix.com/data-tools/bi-catalog-app/event/144:111) | Sent when a Wix Patterns component is done loading


#### 🐪 Couldn't find what you need?
* Check our [BI Catalog](https://bo.wix.com/data-tools/bi-catalog-app?viewId=all-items-view&selectedColumns=src%2Cevid%2Cname%2Cowner%2Cproduct%2CuserType+false%2CdateUpdated%2CdateCreated+false%2CcreatedBy+false%2Cstatus&source=%5B%7B%22id%22%3A%22144%22%2C%22name%22%3A%22144+-+Cairo%22%7D%5D)
* Contact us on [#cairo-bi](https://wix.slack.com/archives/C03N53KURH9)


