# button-group

## Overview

`button-group` allows for grouping of multiple [`button`](https://docs.journeyapps.com/reference/build/ui-components/all-ui-components/button) components, providing better control over layout and visibility.

{% hint style="info" %}
**Version Compatibility**

`button-group` v3 with support for floating action buttons were introduced in version **4.70.0** of the JourneyApps Runtime.
{% endhint %}

For more information on `button`, please see the linked documentation:

{% content-ref url="button" %}
[button](https://docs.journeyapps.com/reference/build/ui-components/all-ui-components/button)
{% endcontent-ref %}

### Basic Example

```xml
<button-group>
    <button label="Previous" style="outline" icon="fa-arrow-left" />
    <button label="Next" icon="fa-arrow-right" icon-position="right" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-b2225929071f994c47a8dc9df5b8da122ecf700f%2Fbutton-group-example.png?alt=media)

## Standard Attributes

None

## Advanced Attributes

### `align-content`

Specify the alignment of button content for all buttons in the `button-group`. See more info about `align-content`:

{% content-ref url="../xml-fields/align-content" %}
[align-content](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/align-content)
{% endcontent-ref %}

### `button-order`

{% hint style="info" %}
**Version compatibility**

`button-order` was introduced in version **4.86.1** of the JourneyApps Runtime.
{% endhint %}

**Optional**

**Type**: `left-to-right`|`right-to-left`

**Default**: `left-to-right`

Specify the order of buttons when the `button-group` [`mode`](#mode) is set to `row`.

<figure><img src="https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fo1LG9lhndKBFIf76W4ZA%2Fimage.png?alt=media&#x26;token=60e28e1a-c25e-4683-adb3-41b355c3a151" alt=""><figcaption></figcaption></figure>

### `color`

**Optional**

**Type**: `string` - can be a named color or #HEX value

**Default**: unset

Specify the [`color`](https://docs.journeyapps.com/reference/build/ui-components/button#color) for all buttons in the `button-group`.

### `disabled`

**Optional**

**Type**: `boolean`

**Default**: `false`

Disables all buttons in the `button-group` to prevent a user from firing their actions.

#### Example: Disabled buttons

```xml
<button-group disabled="true">
    <button label="Previous" style="outline" icon="fa-arrow-left" />
    <button label="Next" icon="fa-arrow-right" icon-position="right" />
</button-group>
```

### `id`

{% content-ref url="../xml-fields/id" %}
[id](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/id)
{% endcontent-ref %}

### `icon`

**Optional**

**Type**: `string`

**Default**: unset

{% hint style="info" %}
This attribute is only available with `type="floating".`
{% endhint %}

The icon of the main button when using a floating action button group.

### `icon-color`

**Optional**

**Type**: `string` - can be a named color or #HEX value

**Default**: unset

Specify the [`icon-color`](https://docs.journeyapps.com/reference/build/ui-components/button#icon-color) for all buttons in the `button-group`.

### `icon-position`

Specify the position of button icons for all buttons in the `button-group`. See more info about `icon-position`:

{% content-ref url="../xml-fields/icon-position" %}
[icon-position](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/icon-position)
{% endcontent-ref %}

### `label-case`

Configure the letter case of the `label` for all buttons in the `button-group`. See more info about `label-case`:

{% content-ref url="../xml-fields/label-case" %}
[label-case](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/label-case)
{% endcontent-ref %}

### `min-width-breakpoint`

**Optional**

**Type**: `integer`

**Default**: `550 px`

{% hint style="info" %}
**Version compatibility**

`min-width-breakpoint` was introduced in version **4.84.1** of the JourneyApps Runtime.
{% endhint %}

Override at what point `button-group` changes from a row (aligned horizontally) into a column (aligned vertically) layout. The value (in pixel) refers to the minimum width of the screen, at which point the `button-group` should change its layout.

**Example:** Default (550 px):

```xml
<button-group>
    <button icon="fa-times-circle" validate="false" style="outline" />
    <button icon="fa-trash" validate="false" style="outline" />
    <button icon="fa-check-circle" validate="false" />
</button-group>
```

On a large screen:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-c4a6393a0bcb95810cc1191c6ee553b21455c432%2Fbutton-group-breakpoint-large-screen.png?alt=media)

On a small screen:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-dd8cbe2d1d4c43ca8f0ae22cb138db9c92904a87%2Fbutton-group-without-breakpoint.png?alt=media)

**Example:** Where `min-width-breakpoint` is reduced 200 px:

```xml
<button-group min-width-breakpoint="200">
    <button icon="fa-times-circle" validate="false" style="outline" />
    <button icon="fa-trash" validate="false" style="outline" />
    <button icon="fa-check-circle" validate="false" />
</button-group>
```

On a large screen:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-c4a6393a0bcb95810cc1191c6ee553b21455c432%2Fbutton-group-breakpoint-large-screen.png?alt=media)

On a small screen:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-823dbd037cb97fd0928d7fbd068dbc213be0e084%2Fbutton-group-with-breakpoint.png?alt=media)

### `mode`

**Optional**

**Type**: `row` | `column` | `split` | `collapsed`

**Default**: `row`

Control the layout of buttons with a button group.

{% hint style="info" %}
A `button-group` in `mode="row"` will switch to `mode="column"` on devices with smaller screens.
{% endhint %}

#### Examples: Button group modes

**Mode: `row`**

```xml
<button-group mode="row">
    <button label="Previous" style="outline" icon="fa-arrow-left" />
    <button label="Home" style="outline" icon="fa-home" />
    <button label="Next" icon="fa-arrow-right" icon-position="right" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-4c08299f834c81ea0f178d6d34fbd6cfa79bb4d0%2Fbutton-group-mode-row.png?alt=media)

**Mode: `column`**

```xml
<button-group mode="column">
    <button label="Button 1" icon="fa-car" />
    <button label="Button 2" icon="fa-bath" />
    <button label="Button 3" icon="fa-bomb" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-75169bec7ae3dc17cd42566dc24bc898e7a6e162%2Fbutton-group-mode-column.png?alt=media)

**Mode: `split`**

When using `split` mode, the first button is kept full, the rest of the buttons are converted to an action sheet, represented by an icon-only button that matches the style of the first button.

```xml
<button-group mode="split">
    <button label="Previous" style="outline" icon="fa-arrow-left" />
    <button label="Home" style="outline" icon="fa-home" />
    <button label="Next" icon="fa-arrow-right" icon-position="right" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-e5717ebc32cc90d4507b098236b6f9cd3fd20f4e%2Fbutton-group-mode-split.png?alt=media)

**Mode: `collapsed`**

Collapsed button-groups transforms all buttons to a single button that opens an Action Sheet when selected.

```xml
<button-group mode="collapsed">
    <button label="Previous" style="outline" icon="fa-arrow-left" />
    <button label="Home" style="outline" icon="fa-home" />
    <button label="Next" icon="fa-arrow-right" icon-position="right" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-2511589bf24c6f7e5834d77e9bec0114d5606f1d%2Fbutton-group-mode-collapsed.png?alt=media)

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-66c11d6c5651f66c275a0df36164c524898f0356%2Fbutton-group-mode-collapsed-clicked.png?alt=media)

### `show-if` and `hide-if`

{% content-ref url="../xml-fields/show-if" %}
[show-if](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/show-if)
{% endcontent-ref %}

{% content-ref url="../xml-fields/hide-if" %}
[hide-if](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/hide-if)
{% endcontent-ref %}

**Note**: A `button-group` will also be hidden when it contains no visible buttons.

### `style`

**Optional**

**Type**: `solid` | `outline`

**Default**: `solid`

Set the [`style`](https://docs.journeyapps.com/reference/build/ui-components/button#style) of all buttons in the `button-group`.

### `type`

**Optional**

**Type**: `normal` | `primary` | `floating`

**Default**: `normal`

Specify the type of `button-group`, in most cases the default will suffice.

Both special case types, i.e. `primary` | `floating` have different behaviors and constraints.

#### Examples: Button group types

**Type: `primary`**

Pin a button group at the bottom of the view

{% hint style="warning" %}
Only one `button-group` with `type="primary"` is allowed per view.
{% endhint %}

```xml
<button-group type="primary">
    <button label="Previous" icon="fa-arrow-left" />
    <button label="Home" icon="fa-home" />
    <button label="Next" icon="fa-arrow-right" icon-position="right" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-ee68702e3025ff6aa7c5b8e6d02e825a41cbcf60%2Fbutton-group-primary.png?alt=media)

**Type: `floating`**

Add a floating action button (FAB) or button group to view. Different to `type="primary"`, this FABs are pinned to the bottom right corner of the screen

{% hint style="warning" %}
Only one `button-group` with `type="floating"` is allowed per view.
{% endhint %}

**Single floating button**

```xml
<button-group type="floating">
    <button label="Home" icon="fa-home" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-ff7424bd3f9e5bc8df5991ef14935768d24871a7%2Fbutton-group-floating-single.png?alt=media)

**Floating button group**

```xml
<button-group type="floating">
    <button label="Previous" icon="fa-arrow-left" />
    <button label="Home" icon="fa-home" />
    <button label="Next" icon="fa-arrow-right" />
</button-group>
```

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-4e864e43116e6d38f3e6b08f946b4f3c3b416af7%2Fbutton-group-floating-collapsed.png?alt=media)

Select the button to open the floating action button group:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-142c3d3a30e44fb7271f9b69a6dd7ee1fe558444%2Fbutton-group-floating-expanded.png?alt=media)

## Component Methods

The following component methods are available when an [`id`](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/id) is assigned to the component and `component.buttonGroup({id:'my-id'})` is called from JS/TS:

### `scrollIntoView`

Programmatically scroll until the `button-group` is visible in the view.
