Swiftpack.co - Package - whitesmith/WSTagsField


Carthage Compatible SwiftPM Compatible CocoaPods Compatible Swift 4.1 Platforms iOS Build Status License MIT

An iOS text field that represents different Tags.



let tagsField = WSTagsField()
tagsField.layoutMargins = UIEdgeInsets(top: 2, left: 6, bottom: 2, right: 6)
tagsField.contentInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
tagsField.spaceBetweenLines = 5.0
tagsField.spaceBetweenTags = 10.0
tagsField.font = .systemFont(ofSize: 12.0)
tagsField.backgroundColor = .white
tagsField.tintColor = .green
tagsField.textColor = .black
tagsField.fieldTextColor = .blue
tagsField.selectedColor = .black
tagsField.selectedTextColor = .red
tagsField.delimiter = ","
tagsField.isDelimiterVisible = true
tagsField.placeholderColor = .green
tagsField.placeholderAlwaysVisible = true
tagsField.returnKeyType = .next
tagsField.acceptTagOption = .space

// Events
tagsField.onDidAddTag = { (_,_) in

tagsField.onDidRemoveTag = { (_,_) in

tagsField.onDidChangeText = { _, text in

tagsField.onDidChangeHeightTo = { sender, height in
    print("HeightTo \(height)")

tagsField.onValidateTag = { tag, tags in
    // custom validations, called before tag is added to tags list
    return tag.text != "#" && !tags.contains(where: { $0.text.uppercased() == tag.text.uppercased() })



To install it, simply add the following line to your Cartfile:

github "whitesmith/WSTagsField"

Then run carthage update.

Follow the current instructions in Carthage's README for up to date installation instructions.


To install it, simply add the following line to your Podfile:

pod "WSTagsField"

You will also need to make sure you're opting into using frameworks:


Then run pod install with CocoaPods 1.1.0 or newer.


If your version of Swift supports the SPM, you just need to add WSTagsField as a dependency in your Package.swift:

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .Package(url: "https://github.com/whitesmith/WSTagsField.git", , versions: "2.0.0" ..< Version.max),

(Note that the Swift Package Manager is still in early design and development, for more information checkout its repository)


Download all the source files and drop them into your project.


  • iOS 8.0+
  • Xcode 9 (Swift 4.0)


The best way to contribute is by submitting a pull request. We'll do our best to respond to your patch as soon as possible. You can also submit a new GitHub issue if you find bugs or have questions. :octocat:



This project was inspired by CLTokenInputView.


Stars: 746
Help us keep the lights on


Used By

Total: 0


3.1.0 - Apr 9, 2018


  • By default, the return key is used to create a tag in the field. Now, you can change it and use the comma or the space key instead: tagsField.acceptTagOption = .space.
  • onDidEndEditing and onDidBeginEditing events were removed in favor of UITextFieldDelegate methods (textFieldDidBeginEditing(textField:) and textFieldDidEndEditing(textField:)). The delegate should be assigned to the textDelegate property and it's related with the input text field. It's also a nice way to have access to textFieldShouldReturn(textField:) where it's possible to change the first responder when the return key is free (i.e.: tagsField.acceptTagOption = .comma is set).

3.0.0 - Apr 9, 2018

Breaking changes

  • padding property is now using the standard contentInset property of UIView. So, padding has been deprecated.
  • displayDelimiter has been renamed to isDelimiterVisible.
  • tagCornerRadius has been renamed to cornerRadius.
  • placeholderAlwayVisible has been renamed to placeholderAlwaysVisible.


  • You can now define the size of the TagView by defining a margin of type UIEdgeInsets to layoutMargins property.
  • You can now define a max number of lines by using the numberOfLines property.
  • You can now define the space between lines using the spaceBetweenLines property.


  • #65 layout issues in an UITableView.

Thanks 🎉💪🙌

@billzhou0223, @griffinmacias, @matsune, @nicol3a and @CharlesAbouYakzan for the amazing API improvements and fixes. @krezzoid for the conversion and improvements for Swift 4.0.

2.1.2 - Jul 7, 2017

  • Fix #37: use WSTagsField in a static TableViewController Cell.

1.3.0 - Apr 9, 2018

Please use the swift2.3 branch for now.


pod 'WSTagsField', :git => 'https://github.com/whitesmith/WSTagsField.git', :branch => 'swift2.3'

or just add swift_version = '2.3' to your Podfile:

target 'AmazingProject' do
  swift_version = '2.3'
  pod 'WSTagsField', '~>1.2.0'


github "whitesmith/WSTagsField" "swift2.3"

or just run carthage with Swift 2.3 toolchain:

carthage update WSTagsField --no-use-binaries --platform iOS --toolchain

2.1.1 - Apr 7, 2017

  • Fix #39: solve retain cycle
  • Fix #31: Traits and autocorrection (ty @danielrhodes)