---
title: "ButtonGroupState"
description: "A state object that allows querying and controlling the state of a ButtonGroup component."
type: "interface"
lastmod: "2026-07-30T07:35:59.194343Z"
---
## API Reference

> Source set: Android

```kotlin
public sealed interface ButtonGroupState : ScrollableState
```

A state object that allows querying and controlling the state of a [ButtonGroup](/jetpack-compose/androidx.xr.glimmer/glimmer/components/ButtonGroup) component.

## Properties

### currentItemIndex

> Source set: Android

```kotlin
public val currentItemIndex: Int
```

Index of the current child.

The index updates continuously as the user scrolls. To get updates only when the index is
"settled", use the current item index when `isScrollInProgress` is `false`.

Returns -1 if the [ButtonGroup](/jetpack-compose/androidx.xr.glimmer/glimmer/components/ButtonGroup) is empty, or if the layout has not been initialized yet.

### itemCount

> Source set: Android

```kotlin
public val itemCount: Int
```

The number of items currently within the ButtonGroup.

## Functions

### scrollToItem

```kotlin
public suspend fun scrollToItem(index: Int)
```

Jump instantly to the item at `index`.

If the [ButtonGroup](/jetpack-compose/androidx.xr.glimmer/glimmer/components/ButtonGroup) has focus, focus will be requested for the child at this index.

### animateScrollToItem

```kotlin
public suspend fun animateScrollToItem(
        index: Int,
        animationSpec: FiniteAnimationSpec<Float> =
            ButtonGroupDefaults.AnimateScrollToItemAnimationSpec,
    )
```

Scroll to the item at `index` with the given [animationSpec](/jetpack-compose/androidx.compose.animation/animation-core/interfaces/AnimationSpec).

If the [ButtonGroup](/jetpack-compose/androidx.xr.glimmer/glimmer/components/ButtonGroup) has focus, focus will be requested for the child at this index.
