Skip to main content
Elastic UI
Elastic UI
ComponentsPatternsContentData visualization
EUI ChangelogGitHubFigma
  • Guidelines
    • Getting started
    • Accessibility
    • Writing
    • Testing
  • Theming
    • Theme provider
    • Color mode
    • High contrast mode
    • Borders
    • Breakpoints
    • Colors
    • Sizing
    • Typography
  • Templates
    • Page template
    • Sitewide search
  • Layout
    • Accordion
    • Bottom bar
    • Flex
    • Flyout
    • Header
    • Horizontal rule
    • Modal
    • Page components
    • Page header
    • Panel
    • Popover
    • Resizable container
    • Spacer
  • Navigation
    • Breadcrumbs
    • Buttons
    • Collapsible nav
    • Context menu
    • Facet
    • Key pad menu
    • Link
    • Pagination
    • Side nav
    • Steps
    • Tabs
    • Tree view
  • Display
    • Aspect ratio
    • Avatar
    • Badge
      • Beta badge
      • Notification badge
    • Callout
    • Card
    • Comment list
    • Description list
    • Drag and drop
    • Empty prompt
    • Health
    • Icons
    • Image
    • List group
    • Loading
    • Progress
    • Skeleton
    • Stat
    • Text
    • Timeline
    • Title
    • Toast
    • Tooltip
    • Tour
  • Forms
    • Form controls
    • Form layouts
    • Form validation
    • Text controls
    • Numeric controls
    • Selection controls
    • Search and filter controls
    • Date and time controls
    • Other controls
  • Tabular content
    • Tables
    • Data grid
  • Editors & Syntax
    • Code
    • Markdown
  • Utilities
    • Accessibility
    • Auto sizer
    • Beacon
    • Color palettes
    • Copy
    • CSS utility classes
    • Delay
    • Error boundary
    • Focus trap
    • Highlight and mark
    • HTML ID generator
    • I18n
    • Inner text
    • Mutation observer
    • Outside click detector
    • Overlay mask
    • Portal
    • Pretty duration
    • Provider
    • Resize observer
    • Scroll
    • Text diff
    • Text truncation
    • Window events
  • EUI
  • Display
  • Badge

Badge

EuiBadges are used to focus on important bits of information. Although they will automatically space themselves if you use them in a repetitive fashion it is good form to wrap them using a EuiBadgeGroup so that they will wrap when width is constrained (as seen below).

Loading...

Badge with Icon

Badges can use icons on the left and right (default) sides.

Loading...

Badge with onClick events

Badges can have

onClick events applied to the badge itself or the icon within the badge. The latter option is useful for when you might use badges in other components (like a tag system with autocomplete where you need close events).

onClick with iconOnClick

When providing both these click handlers, EuiBadge must alter the contents so that it does not contain nested button tags. Please make note that if you provide props other than those explicit to EuiBadge, they will always be applied to the main button tag which may be inside of the outer most tag.

Loading...

Badge for health status

Badges can work as health status indicators in places where there are a lot of repeated statuses, e.g. in tables.

Loading...

Badge with href

Badges can also be made to render anchor tags by passing an href.

Loading...

Badge groups and truncation

Badges, like buttons, will only every be a single line of text. This means text will not wrap, but be truncated if the badge's width reaches that of its parent's.

For this reason, badges also auto-apply the inner text of the badge to the title attribute of the element to provide default browser tooltips with the full badge text.

To ensure proper wrapping, truncation and spacing of multiple badges, it is advisable to wrap them in a EuiBadgeGroup.

Loading...

Props

EuiBadge

Extends HTMLAttributes
𐘂𐘂
✄𐘗✄𐘗
Prop
↦
Description and type
↦
Default value
↵
Prop
iconType#
↦
Description and type

Accepts any string from our icon library

Type: IconType
↦
Default value
↵
Prop
iconSide#
↦
Description and type

The side of the badge the icon should sit

Type: "left" | "right"
↦
Default value
left
↵
Prop
color#
↦
Description and type

Accepts either our palette colors (primary, success ..etc) or a hex value #FFFFFF, #000.

Type: string
↦
Default value
default
↵
Prop
isDisabled#
↦
Description and type

Will override any color passed through the color prop.

Type: boolean
↦
Default value
↵
Prop
closeButtonProps#
↦
Description and type

Props passed to the close button.

Type: Partial<Omit<EuiIconProps, "stylesMemoizer"> & RefAttributes<unknown>>
↦
Default value
↵
Prop
className#
↦
Description and type
Type: string
↦
Default value
↵
Prop
aria-label#
↦
Description and type

Defines a string value that labels the current element.
@see aria-labelledby.

Type: string
↦
Default value
↵
Prop
data-test-subj#
↦
Description and type
Type: string
↦
Default value
↵
Prop
css#
↦
Description and type
Type: Interpolation<Theme>
↦
Default value
↵
Prop
iconOnClick#
↦
Description and type

Will apply an onclick to icon within the badge

Type: MouseEventHandler<HTMLButtonElement>
↦
Default value
↵
Prop
iconOnClickAriaLabel#
↦
Description and type

Aria label applied to the iconOnClick button

Type: string
↦
Default value
↵
Prop
target#
↦
Description and type
Type: string
↦
Default value
↵
Prop
href#
↦
Description and type
Type: string
↦
Default value
↵
Prop
onClick#
↦
Description and type

Will apply an onclick to the badge itself

Type: MouseEventHandler<HTMLButtonElement>
↦
Default value
↵
Prop
onClickAriaLabel#
↦
Description and type

Aria label applied to the onClick button

Type: string
↦
Default value
↵
𐘂𐘂

EuiBadgeGroup

Extends HTMLAttributes
𐘂𐘂
✄𐘗✄𐘗
Prop
↦
Description and type
↦
Default value
↵
Prop
className#
↦
Description and type
Type: string
↦
Default value
↵
Prop
aria-label#
↦
Description and type

Defines a string value that labels the current element.
@see aria-labelledby.

Type: string
↦
Default value
↵
Prop
data-test-subj#
↦
Description and type
Type: string
↦
Default value
↵
Prop
css#
↦
Description and type
Type: Interpolation<Theme>
↦
Default value
↵
Prop
children#
↦
Description and type

Should be a list of EuiBadges, but can also be any other element

Type: ReactNode
↦
Default value
↵
Prop
gutterSize#
↦
Description and type

Space between badges

Type: "xs" | "s" | "none"
↦
Default value
xs
↵
Prop
ref#
↦
Description and type

Allows getting a ref to the component instance.
Once the component unmounts, React will set ref.current to null
(or call the ref with null if you passed a callback ref).
@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}

Type: LegacyRef<HTMLDivElement>
↦
Default value
↵
𐘂𐘂
Edit this page

Previous
Avatar
Next
Beta badge
  • Badge with Icon
  • Badge with onClick events
  • Badge for health status
  • Badge with href
  • Badge groups and truncation
  • Props
EUI is dual-licensed under Elastic License 2.0 and Server Side Public License, v 1 | Crafted with ❤ by Elastic