Search documentation of Plushie

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

Copy Markdown View Source

Scrollable container, wraps child content in a scrollable viewport.

## Props

Name | Type | Default | Description
--- | --- | --- | ---
`width` | `:fill | :shrink | {:fill_portion, pos_integer()} | number()` | `nil` | Width of the scrollable area. Default: shrink.
`height` | `:fill | :shrink | {:fill_portion, pos_integer()} | number()` | `nil` | Height of the scrollable area. Default: shrink.
`direction` | `:horizontal | :vertical | :both` | `nil` | Scroll direction: `:vertical` (default), `:horizontal`, or `:both`.
`spacing` | `number()` | `nil` | Spacing between scrollbar and content.
`scrollbar_width` | `number()` | `nil` | Scrollbar track width in pixels.
`scrollbar_margin` | `number()` | `nil` | Margin around the scrollbar in pixels.
`scroller_width` | `number()` | `nil` | Scroller handle width in pixels.
`anchor` | `:start | :end` | `nil` | Scroll anchor: `:start` (default) or `:end`.
`on_scroll` | `boolean()` | `nil` | When true, emits scroll viewport events.
`auto_scroll` | `boolean()` | `nil` | When true, auto-scrolls to show new content.
`scrollbar_color` | `String.t()` | `nil` | Scrollbar track color.
`scroller_color` | `String.t()` | `nil` | Scroller handle color.
`event_rate` | `integer()` | `nil` | Max events per second for coalescable events.
`a11y` | `%Plushie.Type.A11y{} | map() | keyword()` | `%{role: :scroll_view}` | Accessibility annotations.

## Summary

### Types

option()
t()

### Functions

a11y(widget, descriptor)

Accessibility annotations.

anchor(widget, descriptor)

Scroll anchor: `:start` (default) or `:end`.

auto_scroll(widget, descriptor)

When true, auto-scrolls to show new content.

build(widget)

Converts this widget struct to a `ui_node()` map. Validates at most one child.

direction(widget, descriptor)

Scroll direction: `:vertical` (default), `:horizontal`, or `:both`.

event_rate(widget, descriptor)

Max events per second for coalescable events.

extend(widget, children)

Appends multiple children to the widget.

height(widget, descriptor)

Height of the scrollable area. Default: shrink.

new(id, opts \\ [])

Creates a new widget struct with the given ID and keyword options.

on_scroll(widget, descriptor)

When true, emits scroll viewport events.

push(widget, child)

Appends a child to the widget.

scrollable(id, opts \\ [])

Creates a `:scrollable` widget.

scrollbar_color(widget, descriptor)

Scrollbar track color.

scrollbar_margin(widget, descriptor)

Margin around the scrollbar in pixels.

scrollbar_width(widget, descriptor)

Scrollbar track width in pixels.

scroller_color(widget, descriptor)

Scroller handle color.

scroller_width(widget, descriptor)

Scroller handle width in pixels.

spacing(widget, descriptor)

Spacing between scrollbar and content.

width(widget, descriptor)

Width of the scrollable area. Default: shrink.

with_options(widget, opts)

Applies keyword options to an existing widget struct.

## Types

# option()

    @type option() ::
      (((((((((((({:width,
                   :fill | :shrink | {:fill_portion, pos_integer()} | number()}
                  | {:height,
                     :fill | :shrink | {:fill_portion, pos_integer()} | number()})
                 | {:direction, :horizontal | :vertical | :both})
                | {:spacing, number()})
               | {:scrollbar_width, number()})
              | {:scrollbar_margin, number()})
             | {:scroller_width, number()})
            | {:anchor, :start | :end})
           | {:on_scroll, boolean()})
          | {:auto_scroll, boolean()})
         | {:scrollbar_color, atom() | String.t() | map()})
        | {:scroller_color, atom() | String.t() | map()})
       | {: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.Scrollable{
      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,
      anchor:
        (:start | :end)
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      auto_scroll:
        boolean()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      children: [Plushie.Widget.ui_node()],
      direction:
        (:horizontal | :vertical | :both)
        | 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,
      height:
        (:fill | :shrink | {:fill_portion, pos_integer()} | number())
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      id: String.t(),
      on_scroll:
        boolean()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      scrollbar_color:
        String.t()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      scrollbar_margin:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      scrollbar_width:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      scroller_color:
        String.t()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      scroller_width:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      spacing:
        number()
        | Plushie.Animation.Transition.t()
        | Plushie.Animation.Spring.t()
        | Plushie.Animation.Sequence.t()
        | nil,
      width:
        (:fill | :shrink | {:fill_portion, pos_integer()} | number())
        | 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()`.

# anchor(widget, descriptor)

    @spec anchor(widget :: t(), value :: (:start | :end) | nil) :: t()

Scroll anchor: `:start` (default) or `:end`.

Accepts `:start | :end`.

# auto_scroll(widget, descriptor)

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

When true, auto-scrolls to show new content.

Accepts `boolean()`.

# build(widget)

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

Converts this widget struct to a `ui_node()` map. Validates at most one child.

# direction(widget, descriptor)

    @spec direction(widget :: t(), value :: (:horizontal | :vertical | :both) | nil) ::
      t()

Scroll direction: `:vertical` (default), `:horizontal`, or `:both`.

Accepts `:horizontal | :vertical | :both`.

# 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.

# height(widget, descriptor)

    @spec height(
      widget :: t(),
      value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
    ) :: t()

Height of the scrollable area. Default: shrink.

Accepts `:fill | :shrink | {:fill_portion, pos_integer()} | number()`.

# new(id, opts \\ [])

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

Creates a new widget struct with the given ID and keyword options.

# on_scroll(widget, descriptor)

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

When true, emits scroll viewport events.

Accepts `boolean()`.

# push(widget, child)

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

Appends a child to the widget.

# scrollable(id, opts \\ [])

(macro)

Creates a `:scrollable` widget.

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

    import Plushie.Widget.Scrollable, only: [scrollable: 2]

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

# scrollbar_color(widget, descriptor)

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

Scrollbar track color.

Accepts `String.t()`.

# scrollbar_margin(widget, descriptor)

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

Margin around the scrollbar in pixels.

Accepts `number()`.

# scrollbar_width(widget, descriptor)

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

Scrollbar track width in pixels.

Accepts `number()`.

# scroller_color(widget, descriptor)

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

Scroller handle color.

Accepts `String.t()`.

# scroller_width(widget, descriptor)

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

Scroller handle width in pixels.

Accepts `number()`.

# spacing(widget, descriptor)

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

Spacing between scrollbar and content.

Accepts `number()`.

# width(widget, descriptor)

    @spec width(
      widget :: t(),
      value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
    ) ::
      t()

Width of the scrollable area. Default: shrink.

Accepts `:fill | :shrink | {:fill_portion, pos_integer()} | number()`.

# with_options(widget, opts)

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

Applies keyword options to an existing widget struct.