- Welcome
- Getting started
- Monthly update
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- Aria Live
- Autosuggest
- Badge
- Banner Alert
- Bar Chart
- Blockquote
- Bottom Navigation
- Bottom Sheet
- Breadcrumb
- Breakpoint
- Button
- Calendar
- Card
- Card Button
- Carousel
- Checkbox
- Chip
- 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 List
- Select
- Skeleton
- Skip Link
- Slider
- Snackbar
- Spinner
- Split Input
- Star Rating
- Switch
- Table
- Text
- Text Input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable Native Feedback
- Touchable Overlay
- Content
- Accessibility
Button
Buttons help our travellers make all kinds of action, from logging in to booking that dream trip.
Button
Standard
Day | Night |
---|---|
![]() |
![]() |
Large
Day | Night |
---|---|
![]() |
![]() |
Link
Day | Night |
---|---|
![]() |
![]() |
Installation
Backpack Android is available through Maven Central. Check the main Readme for a complete installation guide.
Usage
The Button component can be used in both XML and Kotlin/Java
Example of a primary button in XML
<net.skyscanner.backpack.button.BpkButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:buttonIconPosition="end"
app:buttonIcon="@drawable/bpk_long_arrow_right"
app:buttonType="primary"
app:buttonLoading="false" />
Example of a primary button in Kotlin
import net.skyscanner.backpack.button.BpkButton
BpkButton(context,BpkButton.Type.Primary).apply {
icon = AppCompatResources.getDrawable(context, R.drawable.bpk_weather)
iconPosition = BpkButton.END
text = "Button"
loading = false
}
Large
Example of a large secondary button in XML
<net.skyscanner.backpack.button.BpkButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:buttonIconPosition="end"
app:buttonIcon="@drawable/bpk_long_arrow_right"
app:buttonType="primary"
app:bpkButtonSize="large"
app:buttonLoading="false" />
Example of a large secondary button in Kotlin
import net.skyscanner.backpack.button.BpkButton
BpkButton(context, BpkButton.Type.Secondary, size = BpkButton.Size.Large).apply {
icon = AppCompatResources.getDrawable(context, R.drawable.bpk_weather)
iconPosition = BpkButton.END
text = "Button"
loading = false
}
Icon
The icon prop only supports VectorDrawables or BitmapDrawables. If you provide a different drawable make sure its size is 16dp.
Theme Props
- buttonBackground
- buttonTextColor
BpkButton accepts the above themeable attributes for the following styles
- bpkButtonPrimary
- bpkButtonSecondary
- bpkButtonDestructive
- bpkButtonPrimaryOnDark
- bpkButtonPrimaryOnLight
- bpkButtonFeatured
Example
<style name="BlueTheme" parent="AppTheme">
<item name="bpkButtonPrimary">@style/BlueButton</item>
</style>
<style name="BlueButton">
<item name="buttonBackground">@color/bpkSkyBlueShade03</item>
<item name="buttonTextColor">@color/bpkSkyGrayTint05</item>
</style>
Check theming for more information.
Made with ❤️ by Skyscanner © 2023
© 2023 Skyscanner Backpack. Page last updated on Nov 21, 2022, 15:07