# Interactive > The component visitors click to act: Button ## Button A button that runs a function when clicked, or submits the form it sits in. Buttons are how visitors act on a Widget: track a parcel, confirm a choice, open a page or reply in the chat. ```jsx ``` ### Props | Prop | Type | Default | Description | | - | - | - | - | | `label` | string \| `{text, color?, weight?}` | — | Button text. | | `onClickAction` | action | — | Function to run on click. | | `submit` | boolean | `false` | Submits the [Form](/docs/developer-guides/widgets/components/form-inputs#form) the button is in. | | `variant` | `solid` \| `soft` \| `outline` \| `ghost` | `solid` | Visual style. | | `color` | `primary` \| `secondary` \| `success` \| `danger` \| `warning` \| `caution` \| `info` \| `discovery`, or any color | `primary` | Button color. | | `size` | `3xs` \| `2xs` \| `xs` \| `sm` \| `md` \| `lg` \| `xl` \| `2xl` \| `3xl` | `lg` | Button height, from 22 px (`3xs`) to 48 px (`3xl`). `lg` is 36 px. | | `iconStart` | icon | — | Icon before the label. See [Icon field format](/docs/developer-guides/widgets/components/media#icon-field-format). | | `iconEnd` | icon | — | Icon after the label. | | `iconSize` | `xs` \| `sm` \| `md` \| `lg` \| `xl` \| `2xl` \| `3xl` | follows `size` | Size of both icons. | | `pill` | boolean | `true` | Fully rounded ends. Set `pill={false}` for rounded corners. | | `block` | boolean | `false` | Stretches the button to the full width of its container. | | `width` | number \| string | — | Fixed width. | | `uniform` | boolean | `false` | Makes the button square, for an icon-only button. | | `disabled` | boolean | `false` | Greys the button out and blocks clicks. | | `lineThrough` | boolean | `false` | Strikes the label through. | | `ariaLabel` | string | the label | Name read by screen readers. Set it on icon-only buttons. | > [!TIP] > > `onClickAction` takes an object whose `functionName` names one of the Widget's [functions](/docs/developer-guides/widgets/functions). Add `additionalInputs` to send values with the click, and `loadingBehavior` to choose how the Widget shows that the function is running. While its function runs, a button shows a spinner and can't be clicked again, unless `loadingBehavior` is `"none"` or `"container"`. ### Examples #### Basic action button A button that runs one function. ```jsx ``` #### Form submit button With `submit`, the button submits its form, which runs the form's function with every field value. Use it in a `Form` or in a `Card` with `asForm`. ```jsx
``` > [!NOTE] > > A `submit` button runs the form's `onSubmitAction`, not its own `onClickAction`, so the browser checks the fields first. #### Icon buttons Add an icon before or after the label with `iconStart` and `iconEnd`. For a square icon-only button, leave out `label`, set `uniform` and give it an `ariaLabel`. ```jsx ``` ```jsx ``` #### Full-width button Set `block` to make the button fill its container. ```jsx ``` #### Button with additional inputs Send a value along with the click. This matters for buttons drawn from a list, where each must say which item was clicked. ```jsx {items.map((item) => ( ))} ``` > [!TIP] > > The function reads the value as `{{sku}}`. See [Additional Inputs](/docs/developer-guides/widgets/functions#additional-inputs). ## Next steps > [card] Functions | /docs/developer-guides/widgets/functions | Configure what each button does. > [card] Click Tracking | /docs/developer-guides/widgets/click-tracking | Count how often visitors click each button.