Lightbox

Designer doc
Similar to Dialog, Lightbox focus must be trapped, especially to prevent pressing Tab jumping out of the Lightbox. Supported keyboard interactions include Arrow Left and Right to navigate, and Escape to close.

Example

View code
Lightbox header can be added to display the title and LightboxItemsCount by passing in getTitleByIndex prop.
View code
The component by default doesn’t include the Controls, rather they are optional and composable. So, it should be flexible enough in the future to add more tools like Rotate, Fit to Screen, etc. Though it might be slightly difficult to get started with those utilities, if a set of tools turns out are very frequent to use, we can always provide a higher level and easier to use API for it based on the current one.
For tools like Download, Share won’t be handled/provided by this component and needs the consumers to add the buttons themselves to that Utilities, because it’s too specific for Coral to handle that.
View code
Auto-hide controls
To allow user to focus on the lightbox content, controls can be auto-hidden when mouse cursor remains stationary over the content for a predefined period of time, using autoHideDelay prop. In this example, controls will be hidden after 3 seconds.
View code
Controlled
In this example, you can:
  1. Control which image is active through activeIndex prop
  2. Add your own Download function
View code
Customizing contents
Adding header
You can add your own custom components inside the overlay by overriding the default overlayElement prop. Below is an example how to add a header to the currently active image.
View code
Inline overlay
By default, overlay container is portaled to the root element, just below document.body. You can pass container prop as null to the customized LightboxOverlay in order to render it without portal.
View code
Animations
You can disable the zooming animation by specifying immediate prop to true.
View code
Integration with @seaweb/file-viewer
Lightbox can typically be used with file viewer to preview files besides images, such as Excel and PDF files. For unsupported file types, it is recommended to display a placeholder.
In this example, @seaweb/file-viewer package is used, you can view more examples and documentation here on how to use.
View code
Accessibility
There is no WAI-ARIA specification for Lightbox in W3C. However, an appropriate set of roles and labels for Lightbox are:
  • The container’s role=“region”, and it has aria-live=“assertive” on the container. The result is, if the items are images with proper alt attribute, the lightbox will spell out the current image alt.
  • Elements that only show on lightbox active should have aria-hidden=“true” when lightbox is inactive.

API

Prop nameTypeDefaultDescription
activeIndexnumber
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
collapseboolean
flipKeystring
getTitleByIndex(activeIndex: number) => string
immediateboolean
initialActiveIndexnumber
onChange(activeIndex: number) => void
overlayElementReactElement<any, string | JSXElementConstructor<any>>
themeTheme<StyledTheme>{ onLightBg: { ...styledDefaultTheme, }, onDarkBg: { ...styledDefaultTheme, interactions: { bgNeutralGeneral: { hover: alp(palette.white, 0.1), press: alp(palette.white, 0.2), selected: alp(palette.white, 0.1), }, bgNeutralStrong: { hover: alp(palette.white, 0.1), press: alp(palette.white, 0.2), selected: alp(palette.white, 0.1), }, bgTintSolid: { hover: alp(palette.white, 0.15), press: alp(palette.white, 0.3), selected: alp(palette.white, 0.15), }, bgTintTransparent: { hover: 0.15, press: 0.3, selected: 0.15 }, border: { hover: alp(palette.white, 0.15), press: alp(palette.white, 0.3), selected: alp(palette.white, 0.15) }, disabled: 0.3, }, }, }
LightboxArrowButton
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
colorTypeColorTypesneuForeInverse1st
Set color based on theme. If color is specified, that prop is used instead of this.
directionArrowDirections
disabledboolean
Equivalent to button's disabled property.
gradientBorderPropsGradientBorderProps
keyboardClickKeysstring[]
leftIconReactNode
Element before the label. Equivalent to element on the label with some margin.
loadingboolean
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
radiusnumber
rightIconReactNode
Element after the label. Equivalent to element on the label with some margin.
sizeButtonSizes
variantButtonVariants
Prefers naming it as variant because type is a known button html property.
LightboxControls
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
elevationLevelnumber3
LightboxHeader
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
closeButtonPropsIconButtonProps
getTitleByIndex(activeIndex: number) => string
itemsCountPropsLightboxItemsCountProps
showItemsCountbooleantrue
titlePropsTextProps
LightboxItem
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disabledboolean
Equivalent to button's disabled property.
indexnumber
inlineSizenumber80
keyboardClickKeysstring[]
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
LightboxOverlay
Prop nameTypeDefaultDescription
arrowButtonReactElement<LightboxArrowButtonProps, string | JSXElementConstructor<any>><LightboxArrowButton />
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
autoHideDelaynumber
zoom/rotate controls, arrow buttons and header are hidden after this delay of no mouse activity defaults to 0 (no auto hide)
containerHTMLElementconfigs.getPortalContainer('Lightbox', 'container')
disableFocusLockboolean
disableScrollLockboolean
elevationLevelnumber3
headerReactElement<LightboxHeaderProps, string | JSXElementConstructor<any>>
LightboxPlaceholder
Prop nameTypeDefaultDescription
actionPropsHTMLAttributes<HTMLDivElement> & { as?: any; ref?: HTMLDivElement; }
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
containerPropsHTMLAttributes<HTMLDivElement>
descriptionReactNode
descriptionPropsHTMLAttributes<HTMLParagraphElement> & { as?: any; ref?: HTMLParagraphElement; }
heightHeight<string | number>
imageReactNode | NextImgProps
imagePropsImgHTMLAttributes<HTMLImageElement> & { as?: any; ref?: HTMLImageElement; }
imageSizeHeight<string | number>
Will not applied if image is a ReactNode
maxWidthMaxWidth<string | number>
offsetTopMarginTop<string | number>
titleReactNode
titlePropsHTMLAttributes<HTMLDivElement> & { as?: any; ref?: HTMLDivElement; }
LightboxItemsCount
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
LightboxTransform
Prop nameTypeDefaultDescription
initialRotationRotation0
initialScalenumber1
initialTranslateTranslate{ x: 0, y: 0 }
onRotationChange(rotation: Rotation) => void
onScaleChange(scale: number) => void
onTranslateChange(translate: Translate) => void
rotationRotation
scalenumber
scaleIndicatorDelaynumber1000
showScaleIndicatorboolean
translateTranslate
zoomStepsnumber[][0.1, 0.25, 0.4, 0.6, 0.8, 1, 1.2, 1.5, 2, 3, 4, 6, 8, 16]
LightboxTransformControls
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
colorTypeColorTypesneuForeInverse1st
Set color based on theme. If color is specified, that prop is used instead of this.
disabledboolean
Equivalent to button's disabled property.
gradientBorderPropsGradientBorderProps
keyboardClickKeysstring[]
loadingboolean
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
radiusstring
rotationIntervalnumber-90
sizeIconButtonSizes
tooltipReactNode
tooltipPropsOmit<TooltipProps, "title" | "children">
variantIconButtonVariants
useLightboxTransformItem
Prop nameTypeDefaultDescription
onDragHandler<"drag">
onDragEndHandler<"drag"> & DragEventHandler<Element>
onDragStartHandler<"drag"> & DragEventHandler<Element>
onHoverHandler<"move">
onMoveHandler<"move">
onMoveEndHandler<"move">
onMoveStartHandler<"move">
onPinchHandler<"pinch">
onPinchEndHandler<"pinch">
onPinchStartHandler<"pinch">
onScrollHandler<"scroll">
onScrollEndHandler<"scroll">
onScrollStartHandler<"scroll">
onWheelHandler<"wheel">
onWheelEndHandler<"wheel">
onWheelStartHandler<"wheel">
    Example
    Example
    Lightbox Controls
    Lightbox Controls
    Controlled
    Controlled
    Customizing contents
    Customizing contents
    Animations
    Animations
    Integration with @seaweb/file-viewer
    Integration with @seaweb/file-viewer
    Accessibility
    Accessibility
    API
    API
    Lightbox
    Lightbox
    LightboxArrowButton
    LightboxArrowButton
    LightboxControls
    LightboxControls
    LightboxHeader
    LightboxHeader
    LightboxItem
    LightboxItem
    LightboxOverlay
    LightboxOverlay
    LightboxPlaceholder
    LightboxPlaceholder
    LightboxItemsCount
    LightboxItemsCount
    LightboxTransform
    LightboxTransform
    LightboxTransformControls
    LightboxTransformControls
    useLightboxTransformItem
    useLightboxTransformItem
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2026 Sea Labs