In this tutorial, we will show you how to add scrollbars to scrollable lists using Compose for Desktop.
In this tutorial, we will show you how to use desktop-specific components of Compose for Desktop such as scrollbars and tooltips.
## Scrollbars applying
## Scrollbars
You can apply scrollbars to scrollable components. The scrollbar and scrollable components share a common state to synchronize with each other. For example, VerticalScrollbar can be attached to Modifier.verticalScroll, and LazyColumnFor and HorizontalScrollbar can be attached to Modifier.horizontalScroll and LazyRowFor.
You can apply scrollbars to scrollable components. The scrollbar and scrollable components share a common state to synchronize with each other. For example, `VerticalScrollbar` can be attached to `Modifier.verticalScroll`, and `LazyColumnFor` and `HorizontalScrollbar` can be attached to `Modifier.horizontalScroll` and `LazyRowFor`.
```kotlin
import androidx.compose.desktop.Window
@ -93,7 +93,7 @@ fun TextBox(text: String = "Item") {
## Lazy scrollable components with Scrollbar
You can use scrollbars with lazy scrollable components, for example, LazyColumn.
You can use scrollbars with lazy scrollable components, for example, `LazyColumn`.
```kotlin
import androidx.compose.desktop.Window
@ -166,7 +166,7 @@ fun TextBox(text: String = "Item") {
## Theme applying
Scrollbars support themes to change their appearance. The example below shows how to use the DesktopTheme appearance for the scrollbar.
Scrollbars support themes to change their appearance. The example below shows how to use the `DesktopTheme` appearance for the scrollbar.
```kotlin
import androidx.compose.desktop.DesktopTheme
@ -243,3 +243,63 @@ fun TextBox(text: String = "Item") {
```
![Themed scrollbar](themed_scrollbar.gif)
## Tooltips
You can add tooltip to any components using `BoxWithTooltip`. Basically `BoxWithTooltip` is a `Box` with the ability to show a tooltip, and has the same arguments and behavior as `Box`.
The main arguments of the `BoxWithTooltip` function: