Skip to content

Pill

Class: FxPill · Tag: <fx-pill>

The <fx-pill> component is a rounded status chip designed for live system flags (such as ONLINE, TRIP, or WIND HIGH). It is commonly used in application headers, status bars, and monitoring views.


import '@salsafx/ui-pro';
<fx-pill
variant="success"
icon="fa-solid fa-circle"
label="ONLINE"
></fx-pill>
<fx-pill
variant="warning"
icon="fa-solid fa-triangle-exclamation"
label="WIND HIGH"
></fx-pill>

Use is-blinking to pulse the pill, drawing attention to active warnings or critical alarms.

<fx-pill
variant="success"
icon="fa-solid fa-circle"
label="ONLINE"
></fx-pill>
<fx-pill
variant="warning"
icon="fa-solid fa-triangle-exclamation"
label="WIND HIGH"
is-blinking
></fx-pill>

Pills support three sizes via the size attribute:

  • small (default): Compact status chip, ideal for dense toolbars and headers.
  • medium: Balanced intermediate size.
  • large: Larger chip with generous padding and larger text.
<fx-pill
variant="success"
icon="fa-solid fa-circle"
label="ONLINE"
size="small"
></fx-pill>
<fx-pill
variant="warning"
icon="fa-solid fa-triangle-exclamation"
label="WIND HIGH"
size="medium"
></fx-pill>
<fx-pill
variant="danger"
icon="fa-solid fa-circle-xmark"
label="TRIP"
size="large"
></fx-pill>

shape is "pill" by default. "roundedRect" is a lightly rounded rectangle and "rect" is square.

<fx-pill
variant="success"
icon="fa-solid fa-circle"
label="ONLINE"
shape="pill"
></fx-pill>
<fx-pill
variant="warning"
icon="fa-solid fa-triangle-exclamation"
label="WIND HIGH"
shape="roundedRect"
></fx-pill>
<fx-pill
variant="danger"
icon="fa-solid fa-circle-xmark"
label="TRIP"
shape="rect"
></fx-pill>

Set variant for standard semantic colors (success, warning, danger, primary, etc.). The background fill and border automatically adjust to complement the chosen accent color.

<fx-pill
variant="success"
icon="fa-solid fa-circle"
label="ONLINE"
></fx-pill>
<fx-pill
variant="danger"
icon="fa-solid fa-circle-xmark"
label="TRIP"
></fx-pill>

Display an icon before the label by setting the icon attribute to a Font Awesome class or SVG path. For custom icon components or markup, use the icon slot.

<!-- Via icon attribute -->
<fx-pill
variant="warning"
icon="fa-solid fa-triangle-exclamation"
label="WIND HIGH"
></fx-pill>
<!-- Via icon slot -->
<fx-pill variant="warning" label="WIND HIGH">
<fx-icon slot="icon" icon="fa-solid fa-wind"></fx-icon>
</fx-pill>

Override the default colors using color for text and icon, background for the fill, and border-color for the outline.

<fx-pill
color="#22c55e"
icon="fa-solid fa-circle"
label="ONLINE"
></fx-pill>
<fx-pill
color="#38bdf8"
background="#082f49"
border-color="#164e63"
label="UTC LIVE"
></fx-pill>

PropertyAttributeTypeDefaultDescription
variantvariantString—Semantic color style. See Variants. Defaults to success green.
labellabelString""Text label displayed inside the pill.
iconiconString""Icon class (e.g. "fa-solid fa-circle") or SVG path displayed before the label.
sizesizeString"small""small", "medium", or "large".
shapeshapeString"pill""pill", "roundedRect", or "rect".
isBlinkingis-blinkingBooleanfalseEnables a pulsing blink animation for active warnings.
colorcolorString""Custom text and icon color. Overrides variant.
backgroundbackgroundString""Custom background fill color.
borderColorborder-colorString""Custom border outline color.
NameDescription
— (default)Content displayed inside the pill when the label attribute is not set.
iconCustom icon element placed before the label. Overrides the icon attribute.
PropertyDefaultDescription
--fx-font-familysans-serifFont stack.
--fx-pill-foregroundaccentText and icon color.
--fx-pill-backgroundtranslucent accentBackground fill color.
--fx-pill-borderaccent borderBorder outline color.

classDiagram
    direction TB
    class FxElement
    class FxPill
    FxElement <|-- FxPill

See also Architecture, Badge, and Variants.