     }
     
     // MARK: - layout
+
+    private func updateRightInsets() {
+        if enableRemoveButton {
+            titleEdgeInsets.right = paddingX  + removeButtonSize
+        }
+        else {
+            titleEdgeInsets.right = paddingX
+        }
+    }
     
     override public func intrinsicContentSize() -> CGSize {
         var size = titleLabel?.text?.sizeWithAttributes([NSFontAttributeName: textFont]) ?? CGSizeZero

    @IBInspectable var paddingX: CGFloat = 5 {
        didSet {
            titleEdgeInsets.left = paddingX

            if !enableRemoveButton {
                titleEdgeInsets.right = paddingX
            }
            else {
                titleEdgeInsets.right = paddingX + removeButtonSize
            }
        }
    }
    
    @IBInspectable public var tagBackgroundColor: UIColor = UIColor.grayColor() {
        didSet {
            backgroundColor = tagBackgroundColor

    @IBInspectable var enableRemoveButton: Bool = false {
        didSet {
            removeButton.hidden = !enableRemoveButton
            updateRightInsets()
        }
    }
    
    @IBInspectable var removeButtonSize: CGFloat = 12 {
        didSet {
            removeButton.iconSize = removeButtonSize
            updateRightInsets()
        }
    }
    
