-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Badge][base] Drop component
prop
#37028
Conversation
Netlify deploy previewBundle size report |
b1482ab
to
c112f5d
Compare
@@ -89,6 +85,20 @@ The following code snippet applies a CSS class called `my-badge` to the badge sl | |||
<Badge slotProps={{ badge: { className: 'my-badge' } }} /> | |||
``` | |||
|
|||
#### Usage with TypeScript | |||
|
|||
In TypeScript, you can specify the custom component type used in the `slots.root` as a generic to the unstyled component. This way, you can safely provide the custom compoenent's props directly on the compnent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In TypeScript, you can specify the custom component type used in the `slots.root` as a generic to the unstyled component. This way, you can safely provide the custom compoenent's props directly on the compnent: | |
In TypeScript, you can specify the custom component type used in the `slots.root` as a generic parameter of the unstyled component. This way, you can safely provide the custom root's props directly on the component: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do the same for other components' markdown too
/> | ||
|
||
{/* @ts-expect-error onClick must be specified in the custom root component */} | ||
<Badge<typeof CustomRoot> slots={{ root: CustomRoot }} onClick={() => {}} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this test was pretty specific to a button. I don't think we need to have it in all components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
@@ -77,7 +76,7 @@ const Badge = React.forwardRef(function Badge<RootComponentType extends React.El | |||
className: classes.root, | |||
}); | |||
|
|||
const BadgeComponent = slots.badge || 'span'; | |||
const BadgeComponent = slots.badge ?? 'span'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more minor remark. The rest looks good!
::: | ||
|
||
Use the `component` prop to override the root slot with a custom element: | ||
Use the `slots.root` prop to override the root slot with a custom element: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this paragraph and change the next one to: "Use the slots
prop to override the root or any other interior slot."
8519708
to
b971587
Compare
The changes look OK. Please make sure the build check pass and it should be good to go. |
81a285c
to
ca1a638
Compare
05df30c
to
3bf3cc2
Compare
BREAKING CHANGE
It will be covered by codemod, see #36831
For Base UI components, the
component
prop value should be moved toslots.root
:If using TypeScript, you should add the custom component type as a generic on the
Badge
component.