UI components · Data display
Badge
A count or a dot beside its content. Group: Data display · component 13 of 17, new in silverpoint 0.3.
States
The 3 reference states silverpoint declares for Badge, live on both grounds, with their code. As in upstream's documentation the examples are uncontrolled: the state's value is the default value. Pick a framework once and every example on the site follows it.
count
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpBadge } from '@silverpoint/react/ui/badge';
<SpBadge count={12}>Inbox</SpBadge><script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpBadge } from '@silverpoint/vue/ui/badge';
</script>
<template>
<SpBadge :count="12">
Inbox
</SpBadge>
</template>// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
// @import '@silverpoint/grounds/ui.css';
import { Component } from '@angular/core';
import { SpBadge } from '@silverpoint/angular/ui/badge';
@Component({
selector: 'app-root',
imports: [SpBadge],
template: `
<sp-badge [count]="12">
Inbox
</sp-badge>
`,
})
export class App {}from reflex_silverpoint_react import sp_badge
sp_badge(
"Inbox",
count=12,
)dot
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpBadge } from '@silverpoint/react/ui/badge';
<SpBadge dot>Alerts</SpBadge><script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpBadge } from '@silverpoint/vue/ui/badge';
</script>
<template>
<SpBadge dot>
Alerts
</SpBadge>
</template>// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
// @import '@silverpoint/grounds/ui.css';
import { Component } from '@angular/core';
import { SpBadge } from '@silverpoint/angular/ui/badge';
@Component({
selector: 'app-root',
imports: [SpBadge],
template: `
<sp-badge [dot]="true">
Alerts
</sp-badge>
`,
})
export class App {}from reflex_silverpoint_react import sp_badge
sp_badge(
"Alerts",
dot=True,
)overflow
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpBadge } from '@silverpoint/react/ui/badge';
<SpBadge count={120} max={99}>Mentions</SpBadge><script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import '@silverpoint/grounds/ui.css';
import { SpBadge } from '@silverpoint/vue/ui/badge';
</script>
<template>
<SpBadge :count="120" :max="99">
Mentions
</SpBadge>
</template>// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
// @import '@silverpoint/grounds/ui.css';
import { Component } from '@angular/core';
import { SpBadge } from '@silverpoint/angular/ui/badge';
@Component({
selector: 'app-root',
imports: [SpBadge],
template: `
<sp-badge [count]="120" [max]="99">
Mentions
</sp-badge>
`,
})
export class App {}from reflex_silverpoint_react import sp_badge
sp_badge(
"Mentions",
count=120,
max=99,
)Import
Each component has its own subpath under ui/, and every adapter exports them all from ui. Import @silverpoint/grounds/ui.css once, beside styles.css; Reflex adds it for you.
| Framework | Import |
|---|---|
| React | import { SpBadge } from '@silverpoint/react/ui/badge'; |
| Vue | import { SpBadge } from '@silverpoint/vue/ui/badge'; |
| Angular | import { SpBadge } from '@silverpoint/angular/ui/badge'; // <sp-badge> |
| Reflex | from reflex_silverpoint_react import sp_badge |
Props
The props Badge adds to the ones every UI component takes.
| React / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
count | count | count | int | The number shown, up to max. |
max | max | max | int | Above it the badge reads 99+ (99 by default). |
dot | dot | dot | bool | A dot with no number. |
label | label | label | str | Accessible text of the badge, e.g. unread messages. |
Common props
Every UI component also takes these. Like a chart's, they fall back to the dashboard the component sits in, then to the provider. Read more about the UI components.
| React / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
id | id | id | str | The frame variant and every related id derive from it. |
ground | ground | ground | Literal['silverpoint', 'cyanotype'] | str | dict[str, Any] | Style ground: "silverpoint" or "cyanotype", or a ground object. Defaults to the dashboard's, then the provider's, or silverpoint. |
substrate | substrate | substrate | Literal['cream', 'green', 'blue', 'ochre', 'prussian'] | Prepared substrate within the ground. |
mode | mode | mode | Literal['ink', 'precision'] | ink by default; precision disables inking. |
seed | seed | seed | str | int | Seed of the frame's hand; overrides id for the frame variant only. |
size | size | size | Literal['sm', 'md', 'lg'] | Control size: sm, md (default) or lg. |
palette | palette | palette | dict[str, str] | Colours over the ground's (set with palette=), merged over the dashboard's and the provider's. |
className | class-name | class_name | str | Added to the component's root element, after its own classes. |
Report it
Found something wrong with SpBadge? Open an issue on GitHub — the form comes pre-filled with the component and the version.