Skip to main content
Give us your valuable feedback

It will help us understand how we can serve you better

Give feedback

Components

Tooltip

Shows additional context on tap or hover.

banner-Tooltip
Component Status Details

Status component contains a list of checks and completeness that has been tested and owned by each component

check-list-icon We don't use color as the only visual tool to convey information.
check-list-icon The component’s structure and properties include relevant options such as variant, style, size, orientation, optional iconography, decorations, selection, error state, etc.check-list-icon The title is the component name that uses the frame base component template.check-list-icon The base component name contains: .Base & "Component Name" if there is more than one.check-list-icon All component properties use the Legion foundation.
check-list-icon We can change all the parts that are connected to the component base.check-list-icon The inside of the base component remains connected to the master component.check-list-icon All variant options are not damaged when we change from one to another.check-list-icon Overriding changes to components will not reset other variants.
check-list-icon Component's already has component specs documentation.

Status

Resources

Usage

In general, there are two types of LGNTooltip content that you can use:

  • Text Tooltip

    Text Tooltip
  • Custom View Tooltip

    Custom View Tooltip

These tooltips can be shown in four positions:

  • Top Center

    Top Center Tooltip
  • Bottom Center

    Bottom Center Tooltip
  • Left

    Left Tooltip
  • Right

    Right Tooltip

Additionally, tooltips support nine different arrow positions:

  • None (no arrow)

    No Arrow Tooltip
  • Right

    Right Arrow Tooltip
  • Left

    Left Arrow Tooltip
  • Bottom Center

    Bottom Center Arrow Tooltip
  • Bottom Left

    Bottom Left Arrow Tooltip
  • Bottom Right

    Bottom Right Arrow Tooltip
  • Top Left

    Top Left Arrow Tooltip
  • Top Center

    Top Center Arrow Tooltip
  • Top Right

    Top Right Arrow Tooltip

Variant

LGNTooltip has 2 content variants:

TextCustom View
Simple text tooltipCustom view with any UI components

Basic text tooltip:

let tooltip = BaseLGNTooltip()
tooltip.tooltipPosition = .bottomCenter
tooltip.setContent(.text("This is a tooltip"))
tooltip.show(in: parentView, relativeTo: buttonView)

Custom view tooltip:

let tooltip = BaseLGNTooltip()
tooltip.tooltipPosition = .topCenter
let customView = UIView()
// Configure your custom view
tooltip.setContent(.custom(customView))
tooltip.show(in: parentView, relativeTo: buttonView)

Auto-dismissing tooltip:

let tooltip = BaseLGNTooltip()
tooltip.tooltipPosition = .right
tooltip.setContent(.text("Will dismiss in 5 seconds"))
tooltip.show(for: 5, in: parentView, relativeTo: buttonView)

Non-dismissible tooltip:

let tooltip = BaseLGNTooltip()
tooltip.tooltipPosition = .left
tooltip.setContent(.text("Can't dismiss this!"))
tooltip.setDismissible(false)
tooltip.show(in: parentView, relativeTo: buttonView)

Methods

The tooltip provides several methods for controlling its behavior:

// Show tooltip
tooltip.show(in: parentView, relativeTo: referenceView)
// Show tooltip with auto-dismiss
tooltip.show(for: timeInterval, in: parentView, relativeTo: referenceView)
// Set content
tooltip.setContent(.text("Your text"))
tooltip.setContent(.custom(yourView))

Example Code

class ViewController: UIViewController {
private let exclamationMarkButton: UIButton = {
let button = UIButton(type: .system)
button.setImage(UIImage(systemName: "exclamationmark.circle"), for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()

Properties

PropertyDescriptionDefault Value
containerViewThe main container view that holds the tooltip content. Has white background and shadow.UIView with white background, corner radius 8, and shadow
contentViewThe view that contains the actual content (label or custom view).Empty UIView
isDismissibleDetermines if the tooltip can be dismissed by tapping the reference view.true
labelThe label used to display text content in the tooltip.UILabel with NunitoSans font, size 12, black text
positionThe position of the arrow pointing from the tooltip. Can be .none, .right, .left, .bottomCenter, .bottomLeft, .bottomRight, .topLeft, .topCenter, or .topRight..none
referenceViewThe view that the tooltip is associated with and points to.nil
tooltipPositionThe position where the tooltip should appear relative to the reference view. Can be .right, .left, .bottomCenter, or .topCenter..bottomCenter