Image Tabs

Tabs that change an image in place while the indicator travels to the chosen tab.

Examples

Tabs with text and image

The frame crossfades: the new image fades in over the previous one, so nothing slides and no background shows through.

Rolling hills under a pale sky
A valley with a sun low over the ridges
Hills at night under a large moon
Layered hills in soft evening colours

Image thumbnails as tabs

variant='thumbnails' turns the list into a strip of images. With transition='clip', the new image wipes in from the side of the thumbnail that was chosen.

Harbour at noon
Meadow road
North ridge
Low valley
Dunes at dusk
Night camp

Image first

Put the frame before the list to mirror the layout. In a vertical list, the clip wipes up or down depending on the direction of the change.

Green hills in spring light
A bright sun over the bay
Warm hills in autumn
The valley under a full moon

Installation

npx shadcn@latest add https://ui.ndekocode.dev/r/motion-image-tabs.json

Component API

ImageTabs

PropTypeDefaultDescription
childrenReactNodeThe list and the frame.
defaultValuestringThe tab selected first.
valuestringThe selected tab, when controlled.
onValueChange(value: string) => voidCalled when another tab is chosen.
orientation'vertical' | 'horizontal''vertical'Arrow keys follow it, and the clip wipes along it.
classNamestringClasses of the root, a grid with a gap by default, for the layout.

ImageTabsList

PropTypeDefaultDescription
variant'list' | 'thumbnails''list'A list of text tabs on a travelling surface, or a strip of thumbnails.
activateOnFocusbooleantrueArrow keys select the tab they reach. The images are mounted, so no wait.
aria-labelstringThe name of the tab list.
classNamestringOptional classes of the list.

ImageTabsTab

PropTypeDefaultDescription
valuestringThe value shared with its panel.
childrenReactNodeImageTabsTitle and ImageTabsDescription, or an image.
aria-labelstringRequired when the tab only holds an image.
disabledbooleanWhether the tab can be chosen.
classNamestringOptional classes of the tab.

ImageTabsFrame

PropTypeDefaultDescription
childrenReactNodeOne ImageTabsImage or ImageTabsPanel per tab.
transition'fade' | 'clip''fade'A 200ms crossfade, or a 320ms wipe. Reduced motion always fades.
classNamestringClasses of the frame, aspect-[3/2] by default.

ImageTabsImage

PropTypeDefaultDescription
valuestringThe value of its tab.
srcstringThe image source.
altstringThe description of the image.
classNamestringOptional classes of the image.

ImageTabsPanel takes value, children and className and shows any content in the frame with the same transition. useImageTabs returns the selected value, the previousValue and the orientation.