Button

Buttons help our travellers make all kinds of action, from logging in to booking that dream trip.

Button

Cocoapods class reference view on Github

Primary

Day Night

PrimaryOnLight

Day Night

PrimaryOnDark

Day Night

Secondary

Day Night
Day Night

Destructive

Day Night
Day Night

Usage

Basic button with a title and action closure.

If you don't specify a .buttonStyle(<type>) it will use the .primary type


                                                
                                                BPKButton("Button title") {
                                                    print("Button tap closure")
                                                }

Styled .secondary Button.


                                                
                                                BPKButton("Button title") {
                                                    print("Button tap closure")
                                                }
                                                .buttonStyle(.secondary)

Button with a title and icon.

Set the icon to:

  • .leading(icon: <BPKIcon>)
  • .trailing(icon: <BPKICon>)

                                                
                                                BPKButton(
                                                    "Button title",
                                                    icon: .leading(icon: .longArrowRight)
                                                ) {
                                                    print("Button tap closure")
                                                }
                                                
                                                BPKButton(
                                                    "Button title",
                                                    icon: .trailing(icon: .longArrowRight)
                                                ) {
                                                    print("Button tap closure")
                                                }

Button with loading state.

Pass in a @State variable or use .constant(true)


                                                
                                                BPKButton(
                                                    "Button title",
                                                    loading: $isLoading
                                                ) {
                                                    print("Button tap closure")
                                                }

Button with disabled state.

Pass in a @State variable or use .constant(true)


                                                
                                                BPKButton(
                                                    "Button title",
                                                    enabled: $isEnabled
                                                ) {
                                                    print("Button tap closure")
                                                }

Button with icon only

Pass in accessibilityLabel when creating a button with just an icon


                                                
                                                BPKButton(
                                                    icon: .longArrowRight,
                                                    accessibilityLabel: "Button label"
                                                ) {
                                                    print("Button tap closure")
                                                }

Button with large size


                                                
                                                BPKButton(
                                                    "Button title",
                                                    size: .large
                                                ) {
                                                    print("Button tap closure")
                                                }