- Welcome
- Getting started
- Latest updates
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- App Search Modal
- 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
- Image Gallery
- Infinite scroll
- Info Banner
- Inset Banner
- Link
- List
- Map
- Mobile scroll container
- Modal
- Navigation bar
- Navigation Tab Group
- Nudger
- Overlay
- Page indicator
- Pagination
- Panel
- Phone input
- Picker
- Popover
- Price
- Progress bar
- Radio button
- Rating
- Rating Bar
- Scrollable calendar
- Search Modal
- Section header
- Section list
- Select
- Skeleton
- Skip link
- Slider
- Snackbar
- Snippet
- Spinner
- Split input
- Star rating
- Swap Button
- Switch
- Table
- Text
- Text input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable native feedback
- Touchable overlay
- Search Input Summary
- Content
- Accessibility
- Contributing
- Localisation
Bottom sheet
Bottom sheets are views rendered on top of screen content, containing supplementary content that are anchored to the bottom of the screen.
Bottom Sheet
Default
Day | Night |
---|---|
BottomSheet with Light Drag Handle over Image content
Day | Night |
---|---|
Modal
Day | Night |
---|---|
Modal With TopBar
Day | Night |
---|---|
Modal with Dark Drag Handle over Image content
Day | Night |
---|---|
Modal with TopBar and Dark Drag Handle over Image content
Day | Night |
---|---|
Installation
Backpack Compose is available through Maven Central. Check the main Readme for a complete installation guide.
Usage
Example of a Bottom Sheet:
import net.skyscanner.backpack.compose.bottomsheet.BpkBottomSheet
import net.skyscanner.backpack.compose.bottomsheet.BpkBottomSheetState
import net.skyscanner.backpack.compose.bottomsheet.rememberBpkBottomSheetState
val state = rememberBpkBottomSheetState()
BpkBottomSheet(
state = state,
peekHeight = HeightOfCollapsedBottomSheet,
sheetContent = { /* content of the bottom sheet */ },
dragHandleStyle = BpkDragHandleStyle.Default,
content = { contentPadding ->
// content displayed behind bottom sheet
// you should apply content padding to avoid displaying content behind collapsed bottom sheet
// here's an example:
Box(modifier = Modifier
.fillMaxSize()
.background(myBackground)
.padding(contentPadding)
) {
// this content will respect the paddings
}
}
)
Example of a Modal Bottom Sheet:
import net.skyscanner.backpack.compose.bottomsheet.BpkModalBottomSheet
import net.skyscanner.backpack.compose.bottomsheet.BpkModalBottomSheetState
import net.skyscanner.backpack.compose.bottomsheet.rememberBpkModalBottomSheetState
var openBottomSheet by rememberSaveable { mutableStateOf(true) }
val state = rememberBpkModalBottomSheetState()
if (openBottomSheet) {
BpkModalBottomSheet(
state = state,
content = { /* content of the bottom sheet */ },
dragHandleStyle = BpkDragHandleStyle.Default,
onDismissRequest = { openBottomSheet = false },
)
}
Example of a Modal Bottom Sheet With Title and Close NavAction:
import net.skyscanner.backpack.compose.bottomsheet.BpkModalBottomSheet
import net.skyscanner.backpack.compose.bottomsheet.BpkModalBottomSheetState
import net.skyscanner.backpack.compose.bottomsheet.rememberBpkModalBottomSheetState
var openBottomSheet by rememberSaveable { mutableStateOf(true) }
val state = rememberBpkModalBottomSheetState()
if (openBottomSheet) {
BpkModalBottomSheet(
state = state,
title = stringResource(id = R.string.generic_title),
closeButton = BpkModalBottomSheetCloseAction.Default(stringResource(id = R.string.navigation_close)),
action = TextAction(text = stringResource(id = R.string.section_header_button_text), {}),
content = { /* content of the bottom sheet */ },
dragHandleStyle = BpkDragHandleStyle.Default,
onDismissRequest = { openBottomSheet = false },
)
}
By default the Bottom sheet content starts below the drag handle. In cases where you need to show an image at the top you can set the dragHandleStyle property to OnImage to remove the safe area, like this:
import net.skyscanner.backpack.compose.bottomsheet.BpkModalBottomSheet
import net.skyscanner.backpack.compose.bottomsheet.BpkModalBottomSheetState
import net.skyscanner.backpack.compose.bottomsheet.rememberBpkModalBottomSheetState
var openBottomSheet by rememberSaveable { mutableStateOf(true) }
val state = rememberBpkModalBottomSheetState()
if (openBottomSheet) {
BpkModalBottomSheet(
state = state,
content = { /* image content of the bottom sheet */ },
dragHandleStyle = BpkDragHandleStyle.OnImage(Type.Light), // use Type.Dark for Dark dragHandle on Image
onDismissRequest = { openBottomSheet = false },
)
}
Made with ❤️ by Skyscanner © 2024
© 2024 Skyscanner Backpack. Page last updated on Nov 14, 2022, 09:47