0.42.2 • Published 27 days ago

@spectrum-web-components/badge v0.42.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
27 days ago

Description

<sp-badge> elements display a small amount of color-categorized metadata. They're ideal for getting a user's attention.

Usage

See it on NPM! How big is this package in your project? Try it on webcomponents.dev

yarn add @spectrum-web-components/badge

Import the side effectful registration of <sp-badge> via:

import '@spectrum-web-components/badge/sp-badge.js';

When looking to leverage the Badge base class as a type and/or for extension purposes, do so via:

import { Badge } from '@spectrum-web-components/badge';

Sizes

<div style="display: flex; gap: var(--spectrum-spacing-75);">
    <sp-badge size="s">Label</sp-badge>
    <sp-badge size="s">
        <sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
        Icon and label
    </sp-badge>
</div>
<div style="display: flex; gap: var(--spectrum-spacing-75);">
    <sp-badge size="m">Label</sp-badge>
    <sp-badge size="m">
        <sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
        Icon and label
    </sp-badge>
</div>
<div style="display: flex; gap: var(--spectrum-spacing-75);">
    <sp-badge size="l">Label</sp-badge>
    <sp-badge size="l">
        <sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
        Icon and label
    </sp-badge>
</div>
<div style="display: flex; gap: var(--spectrum-spacing-75);">
    <sp-badge size="xl">Label</sp-badge>
    <sp-badge size="xl">
        <sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
        Icon and label
    </sp-badge>
</div>

Variants

The <sp-badge> can be customized with either semantic or non-semantic variants.

Semantic

<div style="display: flex; gap: var(--spectrum-spacing-75);">
    <sp-badge variant="accent">Informative</sp-badge>
    <sp-badge variant="neutral">Neutral</sp-badge>
    <sp-badge variant="informative">Informative</sp-badge>
    <sp-badge variant="positive">Positive</sp-badge>
    <sp-badge variant="negative">Negative</sp-badge>
    <sp-badge variant="notice">Notice</sp-badge>
</div>

Non-Semantic

Non-semantic badge colors are no longer supported directly by Spectrum and Spectrum Web Components. You can mimic their delivery via the following CSS Custom Properties. These values for the variant attribute/property have not been marked as deprecated, but will no longer achieve the results you may have relied on in the past.

<div style="display: flex; gap: var(--spectrum-spacing-75); flex-wrap:wrap;">
    <sp-badge variant="seafoam">Seafoam</sp-badge>
    <sp-badge variant="indigo">Indigo</sp-badge>
    <sp-badge variant="purple">Purple</sp-badge>
    <sp-badge variant="fuchsia">Fuchsia</sp-badge>
    <sp-badge variant="magenta">Magenta</sp-badge>
    <sp-badge variant="yellow">Yellow</sp-badge>
    <sp-badge variant="gray">Gray</sp-badge>
    <sp-badge variant="red">Red</sp-badge>
    <sp-badge variant="orange">Orange</sp-badge>
    <sp-badge variant="chartreuse">Chartreuse</sp-badge>
    <sp-badge variant="celery">Celery</sp-badge>
    <sp-badge variant="green">Green</sp-badge>
    <sp-badge variant="cyan">Cyan</sp-badge>
    <sp-badge variant="blue">Blue</sp-badge>
</div>

Fixed

When you'd like to have the <sp-badge> display as if "fixed" to the edge of a UI, the fixed attribute/property can be leveraged to alter the border rounding based on the position you would like to achieve:

<div
    style="position: relative; width: 400px; height: 200px; background: #eee; max-width: 100%"
>
    <sp-badge>None</sp-badge>
    <sp-badge
        fixed="block-start"
        style="position: absolute; top: 0; left: 200px;"
    >
        block-start
    </sp-badge>
    <sp-badge
        fixed="inline-end"
        style="position: absolute; right: 0; top: 100px;"
    >
        inline-end
    </sp-badge>
    <sp-badge
        fixed="block-end"
        style="position: absolute; bottom: 0; left: 200px;"
    >
        block-end
    </sp-badge>
    <sp-badge
        fixed="inline-start"
        style="position: absolute; left: 0; top: 100px;"
    >
        inline-start
    </sp-badge>
</div>
0.42.2

27 days ago

0.42.1

28 days ago

0.42.0

1 month ago

0.41.2

2 months ago

0.41.1

2 months ago

0.41.0

3 months ago

0.40.5

3 months ago

0.40.4

3 months ago

0.40.3

4 months ago

0.40.2

4 months ago

0.40.1

5 months ago

0.38.0

8 months ago

0.35.1-rc.34

9 months ago

0.36.0

9 months ago

0.34.0

10 months ago

0.35.1-rc.43

9 months ago

0.35.1-rc.41

9 months ago

0.40.0

6 months ago

0.39.1

7 months ago

0.39.0

7 months ago

0.35.1-rc.15

9 months ago

0.37.0

9 months ago

0.35.0

9 months ago

0.39.4

6 months ago

0.39.3

6 months ago

0.39.2

7 months ago

0.34.1-rc.0

10 months ago

0.35.1-rc.25

9 months ago

0.35.1-rc.26

9 months ago

0.35.1-rc.24

9 months ago

0.33.3-overlay.66

10 months ago

0.33.3-overlay.65

10 months ago

0.33.3-overlay.61

10 months ago

0.31.1-react.21

11 months ago

0.32.0

11 months ago

0.30.0

12 months ago

0.33.1-overlay.41

11 months ago

0.31.1-react.3

12 months ago

0.31.1-react.1

12 months ago

0.31.1-react.2

12 months ago

0.30.1-overlay.30

12 months ago

0.33.1-overlay.39

11 months ago

0.30.1-overlay.31

12 months ago

0.32.1-overlay.33

11 months ago

0.33.2

11 months ago

0.33.0

11 months ago

0.30.1-overlay.38

12 months ago

0.30.1-overlay.37

12 months ago

0.30.1-overlay.41

12 months ago

0.30.1-overlay.42

12 months ago

0.30.1-overlay.40

12 months ago

0.32.1-overlay.41

11 months ago

0.31.0

12 months ago

0.31.1-overlay.29

12 months ago

0.4.9

1 year ago

0.4.8

1 year ago

0.4.8-overlay.8

1 year ago

0.4.8-overlay.9

1 year ago

0.4.7

1 year ago

0.4.6

1 year ago

0.4.5-react.75

1 year ago

0.4.5-react.48

1 year ago

0.4.5-react.49

1 year ago

0.4.5-react.50

1 year ago

0.4.5

1 year ago

0.4.2-react.54

1 year ago

0.4.5-react.32

1 year ago

0.4.4

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.1

2 years ago

0.1.4-devmode.0

2 years ago

0.1.4-devmode.7

2 years ago

0.3.0-devmode.0

2 years ago

0.3.0

2 years ago

0.1.2

2 years ago

0.2.0

2 years ago

0.2.1-devmode.0

2 years ago

0.1.3

2 years ago

0.2.1-devmode2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago