Skip to content
pixi-silk
GitHub repository
Function

silkRichLabel

import { silkRichLabel } from 'pixi-silk/text';
function silkRichLabel(inlines: Record<string, RichInline>, overrides?: Omit<SilkRichTextOptions, "text" | "inlines">): LabelFactory;

A label factory like silkLabel that makes SilkRichText labels, so a widget’s text can hold icons: pill.show('{up} 12%'). inlines lists the objects by name. Pass functions that build them when a label may show one more than once, or when the widget makes several labels.

Parameters#

ParameterType
inlinesRecord<string, RichInline>
overridesOmit<SilkRichTextOptions, "text" | "inlines">

Returns#

LabelFactory

Example#

import { SilkGraphics } from 'pixi-silk';
import { silkRichLabel } from 'pixi-silk/text';
import { ValuePill } from 'pixi-silk/ui/pill';

const up = () => new SilkGraphics().poly([0, 8, 5, 0, 10, 8]).fill(0x30d158);
const pill = new ValuePill({ label: silkRichLabel({ up: { object: up, height: 'cap' } }) });

pill.show('{up} 12%');