Button

A component that performs an action when it is tapped by a user.

Preview

Button Preview

Code Example

let model = ButtonVM {
  $0.title = "Continue"
  $0.color = .primary
  $0.isFullWidth = true
  $0.size = .large
}

API

ButtonVM Props

A model that defines the appearance properties for a button component.

NameTypeDefaultDescription
titleString""The text displayed on the button.
animationScaleAnimationScalemediumThe scaling factor for the button's press animation, with a value between 0 and 1.
colorComponentColor?nilThe color of the button.
contentSpacingCGFloat8.0The spacing between the button's title and its image or loading indicator.
cornerRadiusComponentRadiusmediumThe corner radius of the button.
fontUniversalFont?nilThe font used for the button's title text. If not provided, the font is automatically calculated based on the button's size.
imageLocationImageLocationleadingThe position of the image relative to the button's title.
imageSrcImageSource?nilThe source of the image to be displayed.
isEnabledBooltrueA Boolean value indicating whether the button is enabled or disabled.
isFullWidthBoolfalseA Boolean value indicating whether the button should occupy the full width of its superview.
isLoadingBoolfalseA Boolean value indicating whether the button is currently in a loading state.
loadingVMLoadingVM?nilThe loading VM used for the loading indicator. If not provided, a default loading view model is used.
sizeComponentSizemediumThe predefined size of the button.
styleButtonStylefilledThe visual style of the button.

SUButton

public init(
  model: ButtonVM,
  action: @escaping () -> Void = {}
)

UKButton

Initializers

public init(
  model: ButtonVM,
  action: @escaping () -> Void = {}
)

Public Properties

NameTypeDescription
action() -> VoidA closure that is triggered when the button is tapped.
modelButtonVMA model that defines the appearance properties.

Public Subviews

NameTypeDescription
titleLabelUILabelA label that displays the title from the model.