diff --git a/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx b/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx index 548a1a66477..28d7f67724e 100644 --- a/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx +++ b/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx @@ -1,6 +1,10 @@ +import { css } from '@emotion/css'; import React, { ReactNode } from 'react'; import SVG from 'react-inlinesvg'; +import { GrafanaTheme2 } from '@grafana/data'; + +import { useStyles2 } from '../../themes'; import { Box } from '../Layout/Box/Box'; import { Stack } from '../Layout/Stack/Stack'; import { Text } from '../Text/Text'; @@ -37,22 +41,25 @@ export const EmptyState = ({ hideImage = false, variant, }: React.PropsWithChildren) => { + const styles = useStyles2(getStyles); const imageToShow = image ?? getDefaultImageForVariant(variant); return ( - - {!hideImage && imageToShow} - - - {message} - - {children && ( - - {children} + +
+ {!hideImage && imageToShow} + + + {message} - )} - - {button} + {children && ( + + {children} + + )} + + {button} +
); }; @@ -73,3 +80,13 @@ function getDefaultImageForVariant(variant: Props['variant']) { } } } + +const getStyles = (theme: GrafanaTheme2) => ({ + container: css({ + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + gap: theme.spacing(4), + maxWidth: '600px', + }), +});