MithrilUI.Animations (Mithril UI v0.1.2)

View Source

Predefined animation presets for use with Phoenix.LiveView.JS commands.

These animations work with Tailwind CSS transition utilities and are designed to be used with JS.show/2 and JS.hide/2 transition options.

Usage

import MithrilUI.Animations

JS.show(transition: modal_enter())
JS.hide(transition: modal_leave())

Animation Types

  • Modal - Scale + fade for dialog overlays
  • Dropdown - Fade + slide for menus
  • Toast - Slide from edge for notifications
  • Drawer - Full slide for side panels
  • Fade - Simple opacity transitions
  • Backdrop - Overlay fade animations
  • Accordion - Expand/collapse for sections

Accessibility

All animations respect the user's prefers-reduced-motion preference when combined with the provided CSS (see assets/css/mithril_ui/animations.css).

Summary

Functions

Accordion collapse animation.

Accordion expand animation.

Alert enter animation - slide down + fade.

Alert leave animation.

Backdrop fade in animation.

Backdrop fade out animation.

Drawer enter animation - slide from specified side.

Drawer leave animation - slide to specified side.

Dropdown enter animation - fade + slide down.

Dropdown leave animation.

Simple fade in animation.

Simple fade out animation.

Modal enter animation - fade + scale.

Modal leave animation - fade + scale.

Toast enter animation - slide in from right.

Toast leave animation.

Tooltip enter animation - fade + slight scale.

Tooltip leave animation.

Functions

accordion_collapse()

@spec accordion_collapse() :: {String.t(), String.t(), String.t()}

Accordion collapse animation.

accordion_expand()

@spec accordion_expand() :: {String.t(), String.t(), String.t()}

Accordion expand animation.

alert_enter()

@spec alert_enter() :: {String.t(), String.t(), String.t()}

Alert enter animation - slide down + fade.

alert_leave()

@spec alert_leave() :: {String.t(), String.t(), String.t()}

Alert leave animation.

backdrop_enter()

@spec backdrop_enter() :: {String.t(), String.t(), String.t()}

Backdrop fade in animation.

backdrop_leave()

@spec backdrop_leave() :: {String.t(), String.t(), String.t()}

Backdrop fade out animation.

drawer_enter(atom)

@spec drawer_enter(:left | :right) :: {String.t(), String.t(), String.t()}

Drawer enter animation - slide from specified side.

Parameters

  • side - :left or :right

Example

JS.show(transition: drawer_enter(:left))

drawer_leave(atom)

@spec drawer_leave(:left | :right) :: {String.t(), String.t(), String.t()}

Drawer leave animation - slide to specified side.

Parameters

  • side - :left or :right

fade_in()

@spec fade_in() :: {String.t(), String.t(), String.t()}

Simple fade in animation.

fade_out()

@spec fade_out() :: {String.t(), String.t(), String.t()}

Simple fade out animation.

toast_enter()

@spec toast_enter() :: {String.t(), String.t(), String.t()}

Toast enter animation - slide in from right.

toast_leave()

@spec toast_leave() :: {String.t(), String.t(), String.t()}

Toast leave animation.

tooltip_enter()

@spec tooltip_enter() :: {String.t(), String.t(), String.t()}

Tooltip enter animation - fade + slight scale.

tooltip_leave()

@spec tooltip_leave() :: {String.t(), String.t(), String.t()}

Tooltip leave animation.