Pantrix UI

Empty State

What a place shows while it has nothing to show: a list before its first item, a search that found nothing, a pane that waits for a document. It says what the place is for and what to do there, and gives the way to do it.

import com.pantrixui.components.container.emptystate.PantrixEmptyState

Examples

A list that is still empty

A list that has nothing yet: the icon says what the list holds, the title what is not there, and the description what will come there. A long description goes on to a second line at 360dp and stays centred.

PantrixEmptyState(
    title = "Nothing opened yet",
    description = "Paste a document or open a file; it is kept here, the last one opened first.",
    icon = PantrixIcons.Folder,
    tagKey = "recent"
)

A search that found nothing

A search that found nothing: the action takes the reader back to something to find. The button is the app's: the empty state puts it under the description, and the app gives its tag and hears its press. Here clearing the filter brings the orders back, and "Search again" shows the empty state again.

var query by rememberSaveable { mutableStateOf("red") }
if (query.isEmpty()) {
    Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
        listOf("Order 4821", "Order 4822", "Order 4823").forEach { order -> PantrixText(order) }
        PantrixButton(
            text = "Search again",
            onClick = { query = "red" },
            variant = ButtonVariant.Text,
            tagKey = "search_again"
        )
    }
} else {
    PantrixEmptyState(
        title = "No orders match",
        description = "\"$query\" is in no order. Try another word, or clear the filter.",
        icon = PantrixIcons.Search,
        action = {
            PantrixButton(
                text = "Clear the filter",
                onClick = { query = "" },
                variant = ButtonVariant.Outline,
                tagKey = "clear_filter"
            )
        },
        tagKey = "orders"
    )
}

Inside a card, with its own style and colours

Inside a card, on the card's own fill: a smaller circle and less room (EmptyStateStyle), and the circle and the icon in the app's own colour (EmptyStateColors). The second card has a title alone: neither a circle nor a description is needed.

val own = ownColors()
PantrixCard(modifier = Modifier.fillMaxWidth(), variant = CardVariant.Filled) {
    PantrixEmptyState(
        title = "No notifications",
        description = "Something new shows here when it comes.",
        icon = PantrixIcons.Inbox,
        style = EmptyStateStyle(iconContainerSize = 40.dp, iconSize = 20.dp, padding = 8.dp, iconGap = 8.dp),
        colors = EmptyStateColors(iconContainer = own.container, icon = own.onContainer),
        tagKey = "notifications"
    )
}
PantrixCard(modifier = Modifier.fillMaxWidth(), variant = CardVariant.Filled) {
    PantrixEmptyState(
        title = "No messages",
        colors = EmptyStateColors(title = PantrixTheme.colors.textSecondary),
        tagKey = "messages"
    )
}

API

title

What a place shows while it has nothing to show: a list before its first item, a search that found nothing, a pane that waits for a document. It says what the place is for and what to do there, and gives the way to do it.

ParameterTypeDefaultWhat it is
titleStringwhat the place has none of, or what it waits for: Nothing opened yet.
modifierModifierModifierthe empty state's modifier. It fills the width it is given.
descriptionString?nullwhat to do there, in a line or two, or null for the title alone.
iconImageVector?nullwhat the place holds when it is not empty, drawn in a circle over the title, or null for none.
action(@Composable () -> Unit)?nullwhat is done about it, under the words: the app's own button, PantrixButton, which is tagged by the app. Null for none.
styleEmptyStateStyle?nullthis call's own style: over every enclosing one and under the density. Only the fields it sets change, on every platform.
colorsEmptyStateColors?nullthis empty state's own colours, where they are not the theme's: the ones set here, with the theme's for the rest.
tagKeyString?nullthe empty state's automation key: it is EmptyState_<tagKey>.

EmptyStateStyle

PantrixEmptyState's geometry: the circle its icon stands in, the room around what it holds and between its parts, and how wide its words run.

ParameterTypeDefaultWhat it is
iconSizeDpDp.UnspecifiedThe icon's own size: 32dp on Android and iOS, 24dp on desktop and the web.
iconContainerSizeDpDp.UnspecifiedThe circle the icon stands in the middle of: 64dp on Android and iOS, 48dp on desktop and the web.
paddingDpDp.UnspecifiedThe room between the edge of what the empty state stands in and what it holds: 24dp on Android and iOS, 16dp on desktop and the web.
iconGapDpDp.UnspecifiedThe room between the circle and the title: 16dp on Android and iOS, 12dp on desktop and the web.
textGapDpDp.UnspecifiedThe room between the title and the description: 4dp.
actionGapDpDp.UnspecifiedThe room between the words and the action under them: 16dp.
maxTextWidthDpDp.UnspecifiedHow wide the title and the description run at the most, in the middle of a wide room: a line that runs across a whole window is not read. 360dp.

EmptyStateColors

What PantrixEmptyState is painted with, where it is not the theme's: a colour that is set is used, and one that is left out stays the theme's.

ParameterTypeDefaultWhat it is
iconColorColor.UnspecifiedThe icon: the onContainer of the theme's neutral role.
iconContainerColorColor.UnspecifiedThe circle behind the icon: the container of the theme's neutral role.
titleColorColor.UnspecifiedThe title: the theme's textPrimary.
descriptionColorColor.UnspecifiedThe description: the theme's textSecondary.

Accessibility