- Welcome
- Getting started
- Latest updates
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- Aria live
- Autosuggest
- Badge
- Banner alert
- Bar chart
- Blockquote
- Bottom navigation
- Bottom sheet
- Breadcrumb
- Breakpoint
- Button
- Calendar
- Card
- Card List
- Card button
- Carousel
- Checkbox
- Chip
- Chip group
- Code
- Content cards
- Data Table
- Datepicker
- Description list
- Dialog
- Divider
- Drawer
- Field Set
- Flare
- Flat list
- Flight leg
- Floating action button
- Floating notification
- Form label
- Form validation
- Graphic promotion
- Horizontal navigation
- Icon
- Image
- Infinite scroll
- Link
- List
- Map
- Mobile scroll container
- Modal
- Navigation bar
- Nudger
- Overlay
- Page indicator
- Pagination
- Panel
- Phone input
- Picker
- Popover
- Price
- Progress bar
- Radio button
- Rating
- Scrollable calendar
- Section header
- Section list
- Select
- Skeleton
- Skip link
- Slider
- Snackbar
- Snippet
- Spinner
- Split input
- Star rating
- Switch
- Table
- Text
- Text input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable native feedback
- Touchable overlay
- Content
- Accessibility
Modal
Modals are used to display content or views that are separate from the rest of the app or page.
Modal
Default
Day | Night | Right to Left |
---|---|---|
![]() |
![]() |
![]() |
Modal without action
Day | Night | Right to Left |
---|---|---|
![]() |
![]() |
![]() |
Modal without action and title
Day | Night | Right to Left |
---|---|---|
![]() |
![]() |
![]() |
Modal with back icon
Day | Night | Right to Left |
---|---|---|
![]() |
![]() |
![]() |
Installation
Backpack Compose is available through Maven Central. Check the main Readme for a complete installation guide.
Usage
Example of a Modal:
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import net.skyscanner.backpack.compose.modal.BpkModal
import net.skyscanner.backpack.compose.modal.rememberBpkModalState
val showModal = rememberSaveable { mutableStateOf(true) }
if (showModal.value) {
val modalState = rememberBpkModalState()
val coroutineScope = rememberCoroutineScope()
BpkModal(
state = modalState,
title = title,
navIcon = NavIcon.Close(
contentDescription = "Navigate back",
onClick = { coroutineScope.launch { modalState.hide() } },
),
action = TextAction(
text = "Action",
onClick = {
coroutineScope.launch { modalState.hide() }
},
),
onDismiss = { showModal.value = false },
) {
// modal content
}
}
Note: to correctly show/hide the modal with animation use rememberBpkModalState and modalState.hide() as shown in the example above. The onDismiss callback will be called when the modal is fully dismissed.
Made with ❤️ by Skyscanner © 2023
© 2023 Skyscanner Backpack. Page last updated on Sep 1, 2023, 17:41