Vitepress Theme Akari Docsv1.0.0GitHubSettingsMore

Image preview: API ​

AkariImagePreview belongs to the theme rather than to @m3e/web, so it has no m3e- element behind it. It reads the --md-sys-color-* and --md-sys-motion-* tokens, which is why it follows the color and motion settings.

AkariImagePreview ​

PropTypeDefaultDescription
srcstringrequiredPicture shown enlarged; also the default thumbnail's source
altstring""Description, also the dialog's aria-label
labelstringthe locale's imagePreviewOpenThe trigger button's aria-label and title
SlotContent
defaultThe thumbnail. The component wraps it in a <button> and adds the zoom icon that appears on hover
OutputDescription
No eventsThe component owns both the open state and the view state
ClassWhere
.akari-image-previewThe root, laid out inline
.akari-image-preview__triggerThe button around the thumbnail
.akari-image-preview__thumbThe default thumbnail
.akari-image-preview__overlayThe overlay, teleported to .akari-frame

Exports ​

The component and its geometry are exported from the theme entry:

ts
import {
  AkariImagePreview,
  clampImageScale,
  zoomImageScale,
  wheelImageScale,
  rotateImage,
  uprightRotation,
  unwindRotation,
  isImageTransformed,
  previewChrome,
  rotationFitScale,
  scaleLabel,
} from "vitepress-akari-theme-docs";
NameDescription
IMAGE_PREVIEW_FITThe scale a preview opens at, 1
IMAGE_PREVIEW_MIN_SCALE, IMAGE_PREVIEW_MAX_SCALEZoom limits, 0.5 and 4
IMAGE_PREVIEW_ZOOM_STEPHow far one click zooms, 0.25
IMAGE_PREVIEW_WHEEL_FACTORHow much one wheel notch scales, 1.1
IMAGE_PREVIEW_ROTATION_STEPDegrees each rotate button turns, 90
clampImageScale(scale)Limits the scale and rounds it to whole percents
zoomImageScale(scale, delta)Adds a step and clamps
wheelImageScale(scale, direction)Applies a wheel notch and clamps
rotateImage(rotation, delta)Turns by the given angle
uprightRotation(rotation)The nearest whole turn, used when resetting
unwindRotation(rotation)The nearest whole turn to return to on close, reversing on a half turn
isImageTransformed(view)Whether the view was zoomed, turned or panned
previewChrome(viewportWidth)Height the overlay leaves for its bar
rotationFitScale(rotation, image, viewport, chrome)The factor that keeps a quarter-turned picture inside the viewport
scaleLabel(scale)Reads 1.05 as 105%
ImagePreviewView, ImagePreviewSizeTypes for a view and a size

Accessibility ​

  • The trigger has a name and the thumbnail has its alt; an empty alt uses the label without a description.
  • The overlay is role="dialog" with aria-modal="true", takes focus when it opens, closes on Esc, and returns focus to the trigger.
  • Page scrolling is locked while open; reduced motion turns the flying transition off.
GitHub Settings

Search the docs

Type a page title, a component name or words from the text.

Press ⌘/Ctrl + K to open it anytime

Choose a language

EnglishEnglish (United States)العربيةArabic (Saudi Arabia)FrançaisFrench (France)日本語Japanese (Japan)한국어Korean (South Korea)简体中文Chinese (China)

Settings

Color
VariantTonal SpotVibrantFidelityExpressiveMonochromeNeutralRainbowFruit Salad
ContrastDefaultMediumHigh
MotionStandardExpressive
Text directionFollow languageLeft to rightRight to left
Text size100%150%200%