Spotlight
A spotlight focuses attention on a specific part of the UI, like a button or an icon.Installation
| Install | yarn add @atlaskit/spotlight |
|---|---|
| Source | Bitbucket.org, (opens new window) |
| npm | @atlaskit/spotlight, (opens new window) |
| Bundle | unpkg.com, (opens new window) |
PopoverContent props
| Description | Invoked when the user clicks |
|---|---|
| Type | (event: BackEvent) => void |
| Description | The content to be rendered in Pass ONE element. On the top-layer code path it is rendered into a flex-row
host so the viewport cap can reach it, and a fragment's children would become
side-by-side flex items. See |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Spotlights can be dismissed by:
These events align to the React.MouseEvent<HTMLButtonElement, MouseEvent>, MouseEvent, and KeyboardEvent events respectively.
Defaults to |
|---|---|
| Type | (event: DismissEvent) => void |
| Description | Invoked when the user clicks If |
|---|---|
| Type | (event: DoneEvent) => void |
| Description | Controls whether or not |
|---|---|
| Type | boolean |
| Description | The motion to be applied to the |
|---|---|
| Type | React.ComponentClass<{ children: React.ReactNode; }, any> | React.FunctionComponent<{ children: React.ReactNode; }> |
| Description | Invoked when the user clicks If |
|---|---|
| Type | (event: NextEvent) => void |
| Description | Distance the spotlight should be offset from the target in the format of [along, away] (units in px).
Defaults to [0, 2] - which means the spotlight will be 2px away from the edge of the target specified
by the |
|---|---|
| Type | [number, number] |
| Description | The position in relation to the target the content should be shown at. |
|---|---|
| Type | "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" |
| Description | Controls whether the 'dismiss' action is invoked when the user clicks outside the content. Defaults to |
|---|---|
| Type | boolean |
| Description | Describes the positioning strategy to use. By default, it is For more details see: https://popper.js.org/docs/v2/constructors/#strategy Has no effect when |
|---|---|
| Type | "absolute" | "fixed" |
| Description | A |
|---|---|
| Type | string |
PopoverProvider props
| Description | The to be rendered in |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
PopoverTarget props
| Description | The content to be rendered in |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
SpotlightCard props
| Description | Elements to be rendered inside the |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | The position in relation to the target the content should be shown at. Overrides |
|---|---|
| Type | "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLDivElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightActions props
| Description | Elements to be rendered inside the |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLDivElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightBody props
| Description | Textual content is required for all spotlights. It should be brief and direct to quickly elaborate on the value. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLDivElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightControls props
| Description | Elements to be rendered inside the |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLDivElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightDismissControl props
| Description | Specifies whether the dismiss button should be focused when the spotlight is rendered.
For spotlights that are triggered by user-action, this should be |
|---|---|
| Default | true |
| Type | boolean |
| Description | The action to take when the button is clicked. |
|---|---|
| Type | (e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLButtonElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightHeader props
| Description | Elements to be rendered inside the |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLDivElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightHeadline props
| Description | A brief and direct title to clearly communicate the intent. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLHeadingElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightMedia props
| Description | Media to be displayed. This can be an image, video, gif that helps communicate spotlight intent. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLDivElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightPrimaryAction props
| Description | Visual style of the button. Defaults to |
|---|---|
| Type | "outline" | "primary" |
| Description | An accessible label to read out in the event that the displayed text does not provide enough context. |
|---|---|
| Type | string |
| Description | Text to be rendered inside the |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | The action to take when the button is clicked. |
|---|---|
| Type | (e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLButtonElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightPrimaryLink props
| Description | Visual style of the button. Defaults to |
|---|---|
| Type | "outline" | "primary" |
| Description | An accessible label to read out in the event that the displayed text does not provide enough context. |
|---|---|
| Type | string |
| Description | Text to be rendered inside the link. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | The destination URL. Accepts a URL string, or a router config object when using AppProvider's router link. |
|---|---|
| Type | string |
| Description | Handler called when the link is clicked. The second argument provides an Atlaskit UI analytics event when using Anchor. |
|---|---|
| Type | (e: MouseEvent<HTMLAnchorElement, globalThis.MouseEvent>) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLAnchorElement> |
| Description | Rel attribute for the link (e.g. |
|---|---|
| Type | string |
| Description | Target attribute for the link (e.g. |
|---|---|
| Type | (string & {}) | "_self" | "_blank" | "_parent" | "_top" |
| Description | A |
|---|---|
| Type | string |
SpotlightSecondaryAction props
| Description | An accessible label to read out in the event that the displayed text does not provide enough context. |
|---|---|
| Type | string |
| Description | Text to be rendered inside the |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | The action to take when the button is clicked. |
|---|---|
| Type | (e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLButtonElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightSecondaryLink props
| Description | An accessible label to read out in the event that the displayed text does not provide enough context. |
|---|---|
| Type | string |
| Description | Text to be rendered inside the link. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | The destination URL. Accepts a URL string, or a router config object when using AppProvider's router link. |
|---|---|
| Type | string |
| Description | Handler called when the link is clicked. The second argument provides an Atlaskit UI analytics event when using Anchor. |
|---|---|
| Type | (e: MouseEvent<HTMLAnchorElement, globalThis.MouseEvent>) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLAnchorElement> |
| Description | Rel attribute for the link (e.g. |
|---|---|
| Type | string |
| Description | Target attribute for the link (e.g. |
|---|---|
| Type | (string & {}) | "_self" | "_blank" | "_parent" | "_top" |
| Description | A |
|---|---|
| Type | string |
SpotlightShowMoreControl props
| Description | The action to take when the button is clicked. |
|---|---|
| Type | (e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLButtonElement> |
| Description | A |
|---|---|
| Type | string |
SpotlightStepCount props
| Description | Elements to be rendered inside the |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLSpanElement> |
| Description | A |
|---|---|
| Type | string |
usePreloadMedia
A hook that preloads media (video or image) files so they are cached by the browser before being rendered. Once loaded, the browser cache will be used when the actual media element is displayed. This improves perceived performance when showing spotlight cards with media.
Supported MIME types
video/mp4video/webmvideo/oggvideo/mpegvideo/x-matroskaimage/jpegimage/pngimage/gifimage/webpimage/svg+xml
Example
import { SpotlightMedia } from '@atlaskit/spotlight/media';
import { usePreloadMedia } from '@atlaskit/spotlight/use-preload-media';
import Image from '@atlaskit/image';
import imageSrc from './assets/image.png'
//...
usePreloadMedia(imageSrc, { mimetype: 'video/mp4' });
// ...
</SpotlightMedia>
<Image src={imageSrc} alt='description' />
</SpotlightMedia>