Monday Hero
Website
V2
V2
  • Overview
  • Workflow Basics
  • Getting Started
    • Installing the Desktop App
    • Log In & Create a Project
    • Prepare Design to Get the Best Code Results
    • Import Design Files into Monday Hero
      • Import Figma Design Files into Monday Hero
        • Import Your Figma Text Style and Color Library
      • Import Adobe XD Design Files into Monday Hero
      • Import Sketch Design Files Into Monday Hero
    • Share Your Project & Manage Roles
  • DESIGN TO FLUTTER
    • Convert Design to Flutter
    • Create Flutter Components
      • System Components
        • Material & Cupertino Components
        • Flutter Supported Components
      • Custom Components
    • Create Responsive Code
    • Colors
    • Text Styles
    • Assets
    • Sync Code
    • Flutter Project Base
      • Fast Start with Monday Hero Starter Project
      • Integrate Monday Hero to your Existing Project
    • Shadows, Gradients, and Other Design Elements
    • Troubleshooting Guide
      • Checklist for Design Element Review and Code Generation
      • Github Monday Hero Starter Project Troubleshooting
  • DESIGN TO SWIFT
    • Convert Design to Swift
    • Create Swift Components
      • System Components
        • Views
        • Texts
        • Images
        • Button
        • TextField/EditText
        • Text Area
        • Status Bar
        • Search Bar
        • List
        • Grid
        • Swift Supported Components
      • Custom Components
      • Video Player Code Component
    • Colors
    • Text Styles
    • Assets
    • Shadows, Gradients, and Other Design Elements
    • Firebase
      • How to get Video URL from Firebase
    • Export Code
      • Integrating Exported Files into an Existing Xcode Project
  • Hero AI Assistant
    • Hero AI Assistant
  • Design to React
    • Convert Design to React
  • Step-By-Step Tutorials
    • 🏖️Travel App
  • Support
    • Roadmap
    • Suggest a New Feature
    • Report a Bug
    • Product Announcements
    • Mail to Support
    • Frequently Asked Questions
  • Join & Follow Us
    • YouTube
    • Discord Community
    • GitHub
    • Twitter
    • LinkedIn
    • Blog
    • Instagram
    • Facebook
Powered by GitBook
On this page

Was this helpful?

  1. DESIGN TO SWIFT
  2. Create Swift Components
  3. System Components

Button

Convert Button component to Android/iOS code.

PreviousImagesNextTextField/EditText

Last updated 3 years ago

Was this helpful?

Buttons are the most used components in apps and they have app-specific actions. Buttons can have a title, background, or image as property/class. They may include more than one property. A button can have both properties at the same time. For example, background and title, or title and image, etc.

You can convert rectangles, images and texts in your design into buttons on Monday Hero. All you need to do tagging the elements with the properties. They are already automatically selected by Monday Hero, incase it tags properties wrong you can reselect them anytime. Here are some button examples with the properties:

Buttons have 3 properties in Monday Hero:

Title: The text displayed over the button.

Background: It's the background of the button. It can be either an image or it can be a view like a rectangle.

Image: Icons are good examples of image buttons. They designed for having app-specific actions.

Here is another button example below. In this case, Monday Hero automatically understands the blue rectangle as View and gets background color from the rectangle. So, tagging the "Follow" text as the Title and the rectangle as Background will be enough. How to create a button and add a property/class can be seen in the GIF below.

When the button is created, the generated code will be like below.

Generated iOS/Android Code

The button code created is added to the page with the styles. Constraints are defined in the Storyboard file.

//ProfilePageViewController.swift
import UIKit

class ProfilePageViewController: UIViewController {
	
	// MARK: - Properties
  //Connection from an Interface Builder to a UI component
  
  // The button with an image and text
	@IBOutlet private weak var followButton: UIButton!
	@IBOutlet private weak var buttonImageView: UIImageView!
	
	//Button with an only image
	@IBOutlet private weak var profileButton: UIButton!

 	//Button with a text and background image
  @IBOutlet private weak var loginButton: UIButton!
  
	override func viewDidLoad() {
		super.viewDidLoad()
		setupViews()
		setupLayout()
	}
}

extension ProfilePageViewController {
	private func setupViews() {
		
		// The button with an image and text
		followButton.layer.cornerRadius = 6
		followButton.layer.masksToBounds =  true 
		followButton.backgroundColor = UIColor.cerulean
		followButton.setTitle(NSLocalizedString("follow", comment: ""),for: .normal)
		followButton.setTitleColor(UIColor.daisy, for: .normal)
		followButton.titleLabel?.font = UIFont.textStyle7
		followButton.contentHorizontalAlignment = .leading 
		followButton.contentEdgeInsets = UIEdgeInsets(top: 6, left: 9 , bottom: 6, right: 9)

		//Button with an only image
		profileButton.setImage(UIImage(named: "profileIcon") , for: .normal)
		
		//Button with a text and background image
		loginButton.setTitle(NSLocalizedString("login", comment: ""),for: .normal)
		loginButton.setTitleColor(UIColor.white, for: .normal)
		loginButton.titleLabel?.font = UIFont.textStyle2
		loginButton.contentHorizontalAlignment = .center 
		loginButton.setBackgroundImage(UIImage(named: "loginBackground") , for: .normal)
	}

	private func setupLayout() { 
		//Constraints are defined in Storyboard file.
	}
}

The button code created and added to the page with the styles.

<!--activityUserProfile.xml-->
<!--The button with a background color and text-->
<Button
	android:id="@+id/followButton"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:text="@string/follow"
	android:textAllCaps="false"
	android:background="@drawable/followbutton_background_drawable"
	style="@style/textStyle11"
	android:textAlignment="textStart"
	android:textColor="?attr/daisy"
	android:paddingLeft="9dp"
	android:paddingRight="9dp"
	android:paddingTop="6dp"
	android:paddingBottom="6dp"
	android:layout_marginEnd="56dp"
	android:layout_marginTop="42dp"
	android:layout_marginBottom="37dp"
	app:layout_constraintStart_toEndOf="@+id/profilPictureImageView"
	app:layout_constraintEnd_toEndOf="parent"
	app:layout_constraintTop_toBottomOf="@+id/nolanAlexTextView"
	app:layout_constraintBottom_toTopOf="@+id/alexanderNolanTextView"/>
	
<!--Button with an only image-->	
<Button
	android:id="@+id/profileButton"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:textAllCaps="false"
	android:background="@android:color/transparent"
	android:drawableBottom="@drawable/profileicon"
	android:layout_marginEnd="23dp"
	android:layout_marginBottom="13dp"
	app:layout_constraintStart_toEndOf="@+id/buttonImageView"
	app:layout_constraintEnd_toEndOf="@+id/baseView"
	app:layout_constraintTop_toBottomOf="@+id/userPicturesBID"
	app:layout_constraintBottom_toBottomOf="@+id/baseView"/>

<!--Button with a text and background image -->
<Button
	android:id="@+id/loginButton"
	android:layout_width="0dp"
	android:layout_height="wrap_content"
	android:text="@string/login"
	android:textAllCaps="false"
	android:background="@android:color/transparent"
	style="@style/textStyle15"
	android:textAlignment="center"
	android:textColor="?attr/white"
	android:layout_marginStart="108dp"
	android:layout_marginEnd="86dp"
	android:layout_marginBottom="18dp"
	app:layout_constraintStart_toStartOf="parent"
	app:layout_constraintEnd_toEndOf="parent"
	app:layout_constraintTop_toBottomOf="@+id/rectangleView"
	app:layout_constraintBottom_toBottomOf="parent"/>
<!--Drawables/followbutton_background_drawable.xml-->
<!--The button with a background color and text-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <shape android:shape="rectangle">
      <solid android:color="?attr/cerulean"/>
      <corners android:radius="6dp"/>
    </shape>
  </item>
</selector>

That's all for creating buttons on Monday Hero.

⚠️This feature is available in only Mac App. Web App support for Android is coming soon. If you need to install the desktop app,

click here.
Button Examples
Example of button creation that has a title in Monday Hero.