onEvent

fun onEvent(title: String, description: String? = null)

Records an event in the Preview Lab. When onEvent is called, Toast is displayed and the event is recorded on the Event tab in the right sidebar. This is useful for manual testing of events that may occur in components.

PreviewLab {
MyButton(
...,
onClick = { onEvent(title = "MyButton.onClick") },
)
}

Parameters

title

The title of the event. This is used for the toast display and also appears in the event list on the Events tab.

description

It will not appear on the toast, but it will appear on the event tab. If you have a lot of information, use description instead of title to make the debug UI easier to read.