Skip to content

Composables ​

useDeck() and useSlide(), imported from 'araojs' in a component's <script setup>. How to use them in your own components and addons: Extending.

useDeck() ​

For components inside Deck (addons, or anything in a slide) to read where the deck is and move it. Throws outside a Deck.

js
import { useDeck } from 'araojs'
const deck = useDeck()
FieldTypeMeaning
indexreadonly ref, Numbercurrent slide, 0-based
stepreadonly ref, Numbercurrent step of that slide, 1-based
totalcomputed, Numbernumber of slides
stepscomputed, Numbersteps of the current slide
progresscomputed, 0..1position over every step of the deck
themereadonly ref, Stringcurrent theme name
themesreadonly ref, Array of stringsthe deck's themes: its themes prop (names that are no theme left out), or every theme there is
fullscreenreadonly ref, Booleanthe window is fullscreen (whatever element is: f then leaves it)
timerreadonly ref, Objectthe talk's timer: { state: 'idle' | 'running' | 'paused', acc, since } (ms counted before since, and when it last started running)
durationcomputed, Number or nullthe talk's length in effect, in ms: the one set in the presenter view, else Deck(duration); null when there is none
next(), prev()functionsmove one step
first(), last()functionsthe first slide at step 1; the last slide at its last step (as Home / End)
go(i, step = 1)functiongo to slide i (0-based) at step (clamped; Infinity = last step); out-of-range i is ignored
titles()functionevery slide's title, in order ('' for a slide without one): what the jump list (g) shows
slidescomputed, Array of { index, title, layout }every slide, in order: its place (0-based), its title (as titles()), its layout's name; frozen. It follows the deck: a slide added, moved or renamed is in it. Agenda lists the section slides from it
setTheme(name)functionwear another of the deck's themes (written in the URL, followed by the other windows); any other name warns and is ignored
toggleFullscreen()functionenter or leave fullscreen (as f)
openPresenter()functionopen the presenter window, or bring it forward (as p)
roleString (not a ref)which rendering this is: 'audience' (the audience window), 'presenter' (presenter view, current slide), 'preview' (presenter view, next-step preview), 'export' (?export), 'thumbnail' (the deck's cover in the list of decks at /: its actions do nothing, as the preview's)

In the 'preview' copy the refs read the preview's position and no function does anything (next, prev, go, first, last, setTheme, toggleFullscreen, openPresenter): the preview is a copy, it cannot act. The object is frozen and its refs read-only, all the way down (themes.value, timer.value): change things through the functions. Being frozen, Vue does not make it reactive: don't put it inside reactive() or data() (its refs are not unwrapped there); read its refs directly (deck.index.value).

useSlide() ​

For components inside a Slide that change within the slide (highlight, count, dim) rather than just appear. Throws outside a Slide.

FieldMeaning
stepreadonly ref: this slide's current step (1-based; the last step once passed, 1 before reached)
requireSteps(n)the slide has at least n steps (same as a v-step="n"). n may be a number, a ref or a getter; changes are followed; released on unmount. Returns a function that releases it early.