Search documentation of Plushie

# Plushie.Widget.Tooltip (Plushie v0.7.2)

Copy Markdown View Source

Tooltip, shows a popup tip over child content on hover.

## Props

Name | Type | Default | Description
--- | --- | --- | ---
`tip` | `String.t() | atom()` | `nil` | Tooltip text.
`position` | `:top | :bottom | :left | :right | :follow_cursor` | `nil` | Position: `:top`, `:bottom`, `:left`, `:right`, `:follow_cursor`.
`gap` | `number()` | `nil` | Gap between tooltip and content in pixels.
`padding` | `number()` | `nil` | Tooltip padding in pixels (uniform).
`snap_within_viewport` | `boolean()` | `nil` | Keep tooltip within viewport. Default: true.
`delay` | `integer()` | `nil` | Delay in milliseconds before showing.

| `style` | `:default \| :primary \| :secondary \| :success \| :danger \| :warning \| :dark \| :weak \| :rounded_box \| term()` | `nil` | Named style preset or custom `StyleMap`. | | `event_rate` | `integer()` | `nil` | Max events per second for coalescable events. | | `a11y` | `%Plushie.Type.A11y{} \| map() \| keyword()` | `%{role: :tooltip}` | Accessibility annotations. |

## Summary

### Types

option()
t()

### Functions

a11y(widget, descriptor)

Accessibility annotations.

build(widget)

Converts this widget struct to a `ui_node()` map.

delay(widget, descriptor)

Delay in milliseconds before showing.

event_rate(widget, descriptor)

Max events per second for coalescable events.

extend(widget, children)

Appends multiple children to the widget.

gap(widget, descriptor)

Gap between tooltip and content in pixels.

new(id, opts \\ [])

Creates a new tooltip.

new(id, tip, opts)
padding(widget, descriptor)

Tooltip padding in pixels (uniform).

position(widget, descriptor)

Position: `:top`, `:bottom`, `:left`, `:right`, `:follow_cursor`.

push(widget, child)

Appends a child to the widget.

snap_within_viewport(widget, descriptor)

Keep tooltip within viewport. Default: true.

style(widget, descriptor)

Named style preset or custom `StyleMap`.

tip(widget, descriptor)

Tooltip text.

tooltip(id, opts \\ [])

Creates a `:tooltip` widget.

with_options(widget, opts)

Applies keyword options to an existing widget struct.

## Types

# option()

    @type option() ::
      (((((({:position, :top | :bottom | :left | :right | :follow_cursor}
            | {:gap, number()})
           | {:padding, number()})
          | {:snap_within_viewport, boolean()})
         | {:delay, integer()})
        | {:style,
           :default
           | :primary
           | :secondary
           | :success
           | :danger
           | :warning
           | :dark
           | :weak
           | :rounded_box
           | term()})
       | {:event_rate, integer()})
      | {:a11y,
         %Plushie.Type.A11y{
           active_descendant: term(),
           busy: term(),
           described_by: term(),
           description: term(),
           disabled: term(),
           error_message: term(),
           expanded: term(),
           has_popup: term(),
           hidden: term(),
           invalid: term(),
           label: term(),
           label_from: term(),
           labelled_by: term(),
           level: term(),
           live: term(),
           mnemonic: term(),
           modal: term(),
           orientation: term(),
           position_in_set: term(),
           radio_group: term(),
           read_only: term(),
           required: term(),
           role: term(),
           selected: term(),
           size_of_set: term(),
           toggled: term(),
           value: term()
         }
         | map()
         | keyword()}

# t()

    @type t() :: %Plushie.Widget.Tooltip{
      a11y:
        (%Plushie.Type.A11y{
           active_descendant: term(),
           busy: term(),
           described_by: term(),
           description: term(),
           disabled: term(),
           error_message: term(),
           expanded: term(),
           has_popup: term(),
           hidden: term(),
           invalid: term(),
           label: term(),
           label_from: term(),
           labelled_by: term(),
           level: term(),
           live: term(),
           mnemonic: term(),
           modal: term(),
           orientation: term(),
           position_in_set: term(),
           radio_group: term(),
           read_only: term(),
           required: term(),
           role: term(),
           selected: term(),
           size_of_set: term(),
           toggled: term(),
           value: term()
         }
         | map()
         | keyword())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      children: [Plushie.Widget.ui_node()],
      delay:
        integer()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      event_rate:
        integer()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      gap:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      id: String.t(),
      padding:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      position:
        (:top | :bottom | :left | :right | :follow_cursor)
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      snap_within_viewport:
        boolean()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      style:
        (:default
         | :primary
         | :secondary
         | :success
         | :danger
         | :warning
         | :dark
         | :weak
         | :rounded_box
         | term())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      tip:
        (String.t() | atom())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil
    }

## Functions

# a11y(widget, descriptor)

    @spec a11y(
      widget :: t(),
      value ::
        (%Plushie.Type.A11y{
           active_descendant: term(),
           busy: term(),
           described_by: term(),
           description: term(),
           disabled: term(),
           error_message: term(),
           expanded: term(),
           has_popup: term(),
           hidden: term(),
           invalid: term(),
           label: term(),
           label_from: term(),
           labelled_by: term(),
           level: term(),
           live: term(),
           mnemonic: term(),
           modal: term(),
           orientation: term(),
           position_in_set: term(),
           radio_group: term(),
           read_only: term(),
           required: term(),
           role: term(),
           selected: term(),
           size_of_set: term(),
           toggled: term(),
           value: term()
         }
         | map()
         | keyword())
        | nil
    ) :: t()

Accessibility annotations.

Accepts `%Plushie.Type.A11y{} | map() | keyword()`.

# build(widget)

    @spec build(widget :: t()) :: Plushie.Widget.ui_node()

Converts this widget struct to a `ui_node()` map.

# delay(widget, descriptor)

    @spec delay(widget :: t(), value :: integer() | nil) :: t()

Delay in milliseconds before showing.

Accepts `integer()`.

# event_rate(widget, descriptor)

    @spec event_rate(widget :: t(), value :: integer() | nil) :: t()

Max events per second for coalescable events.

Accepts `integer()`.

# extend(widget, children)

    @spec extend(widget :: t(), children :: [Plushie.Widget.child()]) :: t()

Appends multiple children to the widget.

# gap(widget, descriptor)

    @spec gap(widget :: t(), value :: number() | nil) :: t()

Gap between tooltip and content in pixels.

Accepts `number()`.

# new(id, opts \\ [])

    @spec new(id :: String.t(), opts :: [option()]) :: t()

Creates a new tooltip.

Accepts either keyword opts (with `:tip` key) or a positional tip string:

    Tooltip.new("tt", tip: "Help", position: :top)
    Tooltip.new("tt", "Help", position: :top)

# new(id, tip, opts)

    @spec new(id :: String.t(), tip :: String.t(), opts :: keyword()) :: t()

# padding(widget, descriptor)

    @spec padding(widget :: t(), value :: number() | nil) :: t()

Tooltip padding in pixels (uniform).

Accepts `number()`.

# position(widget, descriptor)

    @spec position(
      widget :: t(),
      value :: (:top | :bottom | :left | :right | :follow_cursor) | nil
    ) :: t()

Position: `:top`, `:bottom`, `:left`, `:right`, `:follow_cursor`.

Accepts `:top | :bottom | :left | :right | :follow_cursor`.

# push(widget, child)

    @spec push(widget :: t(), child :: Plushie.Widget.child()) :: t()

Appends a child to the widget.

# snap_within_viewport(widget, descriptor)

    @spec snap_within_viewport(widget :: t(), value :: boolean() | nil) :: t()

Keep tooltip within viewport. Default: true.

Accepts `boolean()`.

# style(widget, descriptor)

    @spec style(
      widget :: t(),
      value ::
        (:default
         | :primary
         | :secondary
         | :success
         | :danger
         | :warning
         | :dark
         | :weak
         | :rounded_box
         | term())
        | nil
    ) :: t()

Named style preset or custom `StyleMap`.

Accepts `:default | :primary | :secondary | :success | :danger | :warning | :dark | :weak | :rounded_box | term()`.

# tip(widget, descriptor)

    @spec tip(widget :: t(), value :: (String.t() | atom()) | nil) :: t()

Tooltip text.

Accepts `String.t() | atom()`.

# tooltip(id, opts \\ [])

(macro)

Creates a `:tooltip` widget.

Shorthand for `new/2`. Import this macro to use the widget name directly in view functions:

    import Plushie.Widget.Tooltip, only: [tooltip: 2]

    tooltip("my-id", prop: value)

# with_options(widget, opts)

    @spec with_options(widget :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing widget struct.