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
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
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
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
immediateboolean
initialActiveIndexnumber
onChange(activeIndex: number) => void
overlayElementReactElement<any, string | JSXElementConstructor<any>><LightboxOverlay />
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.
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.
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.
containerHTMLElementconfigs.getPortalContainer('Lightbox', 'container')
disableFocusLockboolean
disableScrollLockboolean
elevationLevelnumber3
LightboxItemsCount
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
LightboxZoom
Prop nameTypeDefaultDescription
initialScalenumber1
initialTranslateTranslate{ x: 0, y: 0 }
onScaleChange(scale: number) => void
onTranslateChange(translate: Translate) => void
scalenumber
translateTranslate
LightboxZoomControls
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
colorTypeColorTypesneuFore1st
Set color based on theme. If color is specified, that prop is used instead of this.
disabledboolean
Equivalent to button's disabled property.
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.
useLightboxZoomItem
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
    Accessibility
    Accessibility
    API
    API
    Lightbox
    Lightbox
    LightboxArrowButton
    LightboxArrowButton
    LightboxControls
    LightboxControls
    LightboxItem
    LightboxItem
    LightboxOverlay
    LightboxOverlay
    LightboxItemsCount
    LightboxItemsCount
    LightboxZoom
    LightboxZoom
    LightboxZoomControls
    LightboxZoomControls
    useLightboxZoomItem
    useLightboxZoomItem
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs