Skip to content

[Badge] export default component for 'badge' slot #43390

Open
@Janpot

Description

@Janpot

Summary

Would like to be able to use the badge slot on the badge component, so that I can wrap it with a ButtonBase and make it interactive. The badge exposes a slot for the "badge" component, but no way to reuse the default component.

Exporting the default component could potentially make sense for any slot that is offered.

Examples

import Badge, { BadgeSlot } from '@mui/material/badge'
import ButtonBase from '@mui/material/ButtonBase'

function MyBadge() {
  return <ButtonBase onClick={() => alert('hello word!')}><BadgeSlot {...props} /></ButtonBase>
}

<Badge 
  badgeContent="click me"
  slots={{
    badge: MyBadge
  }} 
>
  ...
</Badge>

Motivation

No response

Search keywords: badge slot

Metadata

Metadata

Assignees

Labels

component: badgeThis is the name of the generic UI component, not the React module!customization: domComponent's DOM customizability, e.g. slot

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions