static/app/components/emptyMessage.mdx
import {Button} from '@sentry/scraps/button';
import {EmptyMessage} from 'sentry/components/emptyMessage'; import {Panel} from 'sentry/components/panels/panel'; import {IconSearch} from 'sentry/icons'; import * as Storybook from 'sentry/stories';
To create a basic empty message, wrap your message in an <EmptyMessage> component.
<Panel>
<EmptyMessage>
This is a simple empty message with default styling and balanced text wrapping for
better readability.
</EmptyMessage>
</Panel>
React.ReactNode) - The title of the empty messageReact.ReactNode) - Optional icon elementReact.ReactElement) - Optional action button"md" | "lg") - Size of the text (default: md)React.ReactNode) - Main content text (automatically uses balanced text wrapping)Add a title to provide context for the empty state.
<Storybook.Demo> <Panel> <EmptyMessage title="No Results Found"> We couldn't find any results matching your search criteria. Try adjusting your filters or search terms. </EmptyMessage> </Panel> </Storybook.Demo>
<EmptyMessage title="No Results Found">
We couldn't find any results matching your search criteria. Try adjusting your filters
or search terms.
</EmptyMessage>
Add an icon to make the empty state more visually distinctive. Icons are defaulted to lg size, so there is typically no need to specify an icon size.
<Storybook.Demo> <Panel> <EmptyMessage icon={<IconSearch />} title="No Results"> We couldn't find any results matching your search criteria. </EmptyMessage> </Panel> </Storybook.Demo>
<EmptyMessage icon={<IconSearch />} title="No Results">
We couldn't find any results matching your search criteria.
</EmptyMessage>
Add action buttons to guide users toward resolving the empty state.
<Storybook.Demo> <Panel> <EmptyMessage icon={<IconSearch />} title="No Results Found" action={<Button variant="primary">Clear Filters</Button>} > We couldn't find any results matching your search criteria. Try adjusting your filters or search terms. </EmptyMessage> </Panel> </Storybook.Demo>
<EmptyMessage
icon={<IconSearch />}
title="No Results Found"
action={<Button variant="primary">Clear Filters</Button>}
>
We couldn't find any results matching your search criteria. Try adjusting your filters
or search terms.
</EmptyMessage>
EmptyMessage supports two sizes: md (default) and lg.
<Storybook.Demo>
<div style={{display: 'flex', gap: '1rem'}}> <Panel style={{flex: 1}}> <EmptyMessage icon={<IconSearch />} title="Medium Size"> This is the default medium size empty message. </EmptyMessage> </Panel> <Panel style={{flex: 1}}> <EmptyMessage size="lg" icon={<IconSearch />} title="Large Size"> This is a large size empty message with bigger text. </EmptyMessage> </Panel> </div> </Storybook.Demo> ```jsx <EmptyMessage size="medium" icon={<IconSearch />} title="Medium Size"> This is the default medium size empty message. </EmptyMessage><EmptyMessage size="lg" icon={<IconSearch />} title="Large Size"> This is a large size empty message with bigger text. </EmptyMessage>
### Text Wrapping
All text content automatically uses CSS text-wrap balance mode for better readability, especially with longer messages.
<Storybook.Demo>
<Panel>
<EmptyMessage icon={<IconSearch />} title="Text Wrapping">
Sure you haven't misspelled? If you're using a lesser-known platform, consider
choosing a more generic SDK like Browser JavaScript, Python, Node, .NET & Java or
create a generic project.
</EmptyMessage>
</Panel>
</Storybook.Demo>
```jsx
<EmptyMessage icon={<IconSearch />} title="Text Wrapping">
Sure you haven't misspelled? If you're using a lesser-known platform, consider choosing
a more generic SDK like Browser JavaScript, Python, Node, .NET & Java or create a
generic project.
</EmptyMessage>