diff --git a/docs/assets/plugins/metadata/metadata.js b/docs/assets/plugins/metadata/metadata.js
index 0204fef6a..1038d7ac9 100644
--- a/docs/assets/plugins/metadata/metadata.js
+++ b/docs/assets/plugins/metadata/metadata.js
@@ -292,11 +292,11 @@
diff --git a/docs/components/badge.md b/docs/components/badge.md
index 47ccae0b7..6d7566b81 100644
--- a/docs/components/badge.md
+++ b/docs/components/badge.md
@@ -22,6 +22,16 @@ Set the `type` attribute to change the badge's type.
Danger
```
+### Pill Badges
+
+```html preview
+Primary
+Success
+Info
+Warning
+Danger
+```
+
### With Buttons
One of the most common use cases for badges is attaching them to buttons. To make this easier, badges will be automatically positioned at the top-right when they're a child of a button.
@@ -29,17 +39,17 @@ One of the most common use cases for badges is attaching them to buttons. To mak
```html preview
Requests
- 30
+ 30
Warnings
- 8
+ 8
Errors
- 6
+ 6
```
@@ -52,8 +62,8 @@ When including badges in menu items, use the `suffix` slot to make sure they're
style="max-width: 240px; border: solid 1px var(--sl-color-gray-90); border-radius: var(--sl-border-radius-medium);"
>
Messages
- Comments 4
- Replies 12
+ Comments 4
+ Replies 12
```
diff --git a/src/components.d.ts b/src/components.d.ts
index 1cc363a7d..2c0336138 100644
--- a/src/components.d.ts
+++ b/src/components.d.ts
@@ -47,6 +47,10 @@ export namespace Components {
"shape": 'circle' | 'square' | 'rounded';
}
interface SlBadge {
+ /**
+ * Set to true to draw a pill-style badge with rounded edges.
+ */
+ "pill": boolean;
/**
* The badge's type.
*/
@@ -1105,6 +1109,10 @@ declare namespace LocalJSX {
"shape"?: 'circle' | 'square' | 'rounded';
}
interface SlBadge {
+ /**
+ * Set to true to draw a pill-style badge with rounded edges.
+ */
+ "pill"?: boolean;
/**
* The badge's type.
*/
diff --git a/src/components/badge/badge.scss b/src/components/badge/badge.scss
index 35ac9570c..47f0eb129 100644
--- a/src/components/badge/badge.scss
+++ b/src/components/badge/badge.scss
@@ -2,8 +2,6 @@
:host {
display: inline-flex;
- border-radius: var(--sl-border-radius-pill);
- pointer-events: none;
}
.badge {
@@ -14,9 +12,10 @@
font-weight: var(--sl-font-weight-semibold);
letter-spacing: var(--sl-letter-spacing-normal);
line-height: 1;
- border-radius: inherit;
+ border-radius: var(--sl-border-radius-small);
white-space: nowrap;
- padding: 4px 8px;
+ padding: 3px 6px;
+ pointer-events: none;
user-select: none;
cursor: inherit;
}
@@ -49,3 +48,11 @@
background-color: var(--sl-color-danger-50);
color: var(--sl-color-white);
}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Pill modifiers
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+.badge--pill {
+ border-radius: var(--sl-border-radius-pill);
+}
diff --git a/src/components/badge/badge.tsx b/src/components/badge/badge.tsx
index e7582bf65..6765c0f3f 100644
--- a/src/components/badge/badge.tsx
+++ b/src/components/badge/badge.tsx
@@ -21,6 +21,9 @@ export class Badge {
/** The badge's type. */
@Prop() type: 'primary' | 'success' | 'info' | 'warning' | 'danger' | 'text' = 'primary';
+ /** Set to true to draw a pill-style badge with rounded edges. */
+ @Prop() pill = false;
+
render() {
return (