System Components

What is a System Component?

System components are predefined elements available in Swift, and Monday Hero enables you to create instances of these components directly from your designs. You can convert any image, text, or view into system components within your design.

When an instance of a system component is created, code is automatically generated to match the styles and overrides specified in the selected design.

Here is a list of all system components, for all the supported components list, click here.

Here is a button code example with System Components:

//ProfilePageViewController.swift
import UIKit

class ProfilePageViewController: UIViewController {

  // The button with an image and text
	@IBOutlet private weak var followButton: 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)
	
	}

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

All the components are explained separately in the following pages.

How to Create A System Component

Start by highlighting the elements and converting them into components. Here is how to create a component instance:

  1. Select and highlight the layers: Select the layers you want to convert into a component.

  1. Right-click and choose the component from the menu: Select the class of your component. Available options include Buttons, TextViews, SearchBars, StatusBars, Lists, Grids, and more.

OR click the components button and select a component from the screen: Once you select the tag component instance, you'll see the available options on the screen. Choose one of them to continue.

  1. Set properties: For each layer, select the necessary properties such as title, image, or background image. These options will appear in a list.

  1. Name Your Variable: You will name your variable during this step. This name is used to reference your component in the code, choose a name that is easy to remember for you.

  2. Finish: Click 'Finish' to complete the creation process.

Once the component is created successfully, you'll be able to see its code on the screen. Additionally, the component type will appear in the left layer list, highlighted on the screen, and the corresponding code on the right will be updated.

Please note that you need click 'Mark as Ready' button to see the code.

Congrats! It's done. You can also create your own component library for reusing components.

Last updated