--- category: Utilities --- # useCycleList Cycle through a list of items. Learn how to use useCycleList to create an image carousel with this FREE video lesson from Vue School! ## Usage ```ts import { useCycleList } from '@vueuse/core' const { state, next, prev, go } = useCycleList([ 'Dog', 'Cat', 'Lizard', 'Shark', 'Whale', 'Dolphin', 'Octopus', 'Seal', ]) console.log(state.value) // 'Dog' prev() console.log(state.value) // 'Seal' go(3) console.log(state.value) // 'Shark' ``` ## Type Declarations ```ts export interface UseCycleListOptions { /** * The initial value of the state. * A ref can be provided to reuse. */ initialValue?: MaybeRef /** * The default index when */ fallbackIndex?: number /** * Custom function to get the index of the current value. */ getIndexOf?: (value: T, list: T[]) => number } /** * Cycle through a list of items * * @see https://vueuse.org/useCycleList */ export declare function useCycleList( list: MaybeRefOrGetter, options?: UseCycleListOptions, ): UseCycleListReturn export interface UseCycleListReturn { state: ShallowRef index: WritableComputedRef next: (n?: number) => T prev: (n?: number) => T /** * Go to a specific index */ go: (i: number) => T } ```