Skip to content

Semaphore

Class: FxSemaphore · Tag: <fx-semaphore> · Mixins: Animatable

The <fx-semaphore> component renders a multi-lamp indicator panel (traffic-light style) with round LEDs in a vertical or horizontal layout. By default, it functions as a stop/warn/go indicator, but can be fully customized with nested <fx-semaphore-state> elements. Each lamp supports custom colors, labels, and icons for clear, high-visibility status monitoring.


import '@salsafx/ui';

Interactive preview of the main variants:


With no state children, <fx-semaphore> uses FxSemaphore.defaultStates — stop (red), warn (amber), and go (green):

<fx-semaphore value="go" label="RUN"></fx-semaphore>

Pass <fx-semaphore-state> children with optional label text above each LED:

<fx-semaphore value="indigo" label="BUS A" orientation="vertical">
<fx-semaphore-state value="cyan" color="#06b6d4" label="CH1"></fx-semaphore-state>
<fx-semaphore-state value="indigo" color="#6366f1" label="CH2"></fx-semaphore-state>
<fx-semaphore-state value="violet" color="#a855f7" label="CH3"></fx-semaphore-state>
<fx-semaphore-state value="orange" color="#f97316" label="CH4"></fx-semaphore-state>
</fx-semaphore>

Set icon to an icon-font class list or a .svg path (same managed-slot pattern as Switch / PushButton), or nest custom markup with slot="icon". Lamps may be icon-only, label-only, or both:

<!-- icon only -->
<fx-semaphore value="indigo" label="ICONS" orientation="vertical">
<fx-semaphore-state value="cyan" color="#06b6d4" icon="fa-solid fa-droplet"></fx-semaphore-state>
<fx-semaphore-state value="indigo" color="#6366f1" icon="fa-solid fa-bolt"></fx-semaphore-state>
<fx-semaphore-state value="violet" color="#a855f7" icon="fa-solid fa-atom"></fx-semaphore-state>
<fx-semaphore-state value="orange" color="#f97316" icon="fa-solid fa-fire"></fx-semaphore-state>
</fx-semaphore>
<!-- icon + label via attribute -->
<fx-semaphore value="violet" label="BOTH" orientation="horizontal">
<fx-semaphore-state value="cyan" color="#06b6d4" label="CH1" icon="fa-solid fa-droplet"></fx-semaphore-state>
<fx-semaphore-state value="indigo" color="#6366f1" label="CH2" icon="fa-solid fa-bolt"></fx-semaphore-state>
<fx-semaphore-state value="violet" color="#a855f7" label="CH3" icon="fa-solid fa-atom"></fx-semaphore-state>
<fx-semaphore-state value="orange" color="#f97316" label="CH4" icon="fa-solid fa-fire"></fx-semaphore-state>
</fx-semaphore>
<!-- icon via slot -->
<fx-semaphore value="orange" label="SLOT" orientation="horizontal">
<fx-semaphore-state value="cyan" color="#06b6d4" label="CH1">
<i slot="icon" class="fa-solid fa-droplet"></i>
</fx-semaphore-state>
<fx-semaphore-state value="indigo" color="#6366f1" label="CH2">
<i slot="icon" class="fa-solid fa-bolt"></i>
</fx-semaphore-state>
<fx-semaphore-state value="violet" color="#a855f7" label="CH3">
<i slot="icon" class="fa-solid fa-atom"></i>
</fx-semaphore-state>
<fx-semaphore-state value="orange" color="#f97316" label="CH4">
<i slot="icon" class="fa-solid fa-fire"></i>
</fx-semaphore-state>
</fx-semaphore>

Use orientation="vertical" (default) or orientation="horizontal":

<fx-semaphore value="stop" label="VERTICAL" orientation="vertical"></fx-semaphore>
<fx-semaphore value="go" label="HORIZONTAL" orientation="horizontal"></fx-semaphore>

Set hasShell = false (or .hasShell=${false} in Lit templates) to render only the LED row/column:

<fx-semaphore id="caution" value="warn" label="CAUTION" orientation="horizontal" size="large">
<fx-semaphore-state value="stop" color="#ef4444"></fx-semaphore-state>
<fx-semaphore-state value="warn" color="#fbbf24" is-blinking></fx-semaphore-state>
<fx-semaphore-state value="go" color="#22c55e"></fx-semaphore-state>
</fx-semaphore>
<script>
document.getElementById('caution').hasShell = false;
</script>

If value matches no state, every LED stays off.

Set is-blinking on a <fx-semaphore-state> to blink that LED while it is active (host is-animated must stay on, which is the default):

<fx-semaphore value="alarm" label="ALARM" orientation="horizontal">
<fx-semaphore-state value="ok" color="#22c55e" label="OK"></fx-semaphore-state>
<fx-semaphore-state value="warn" color="#fbbf24" label="WARN" is-blinking></fx-semaphore-state>
<fx-semaphore-state value="alarm" color="#ef4444" label="ALARM" is-blinking></fx-semaphore-state>
</fx-semaphore>

Built-in sizes via the size attribute: small, medium (default), large, and x-large.

<fx-semaphore value="stop" label="S" size="small"></fx-semaphore>
<fx-semaphore value="warn" label="M" size="medium"></fx-semaphore>
<fx-semaphore value="go" label="L" size="large"></fx-semaphore>
<fx-semaphore value="go" label="XL" size="x-large"></fx-semaphore>

PropertyAttributeTypeDefaultDescription
valuevalueString""Active state value.
labellabelString""Optional caption label displayed below the housing.
hasShellhas-shellBooleantrueShows the outer housing around the LEDs.
sizesizeString"medium"Size of the LEDs (“small”, “medium”, “large”, or “x-large”).
orientationorientationString"vertical"Orientation of the LED strip (“vertical” or “horizontal”).
disableddisabledBooleanfalseDisables interaction and dims the control.
isAnimatedis-animatedBooleantrueEnables fluid, hardware-accelerated state transitions.
MemberTypeDescription
FxSemaphore.defaultStatesReadonlyArray<FxSemaphoreStateData>Built-in stop / warn / go configuration used when no state children are provided.

<fx-semaphore-state> Properties & Attributes

Section titled “<fx-semaphore-state> Properties & Attributes”
PropertyAttributeTypeDefaultDescription
valuevalueString""State id matched against the host value.
colorcolorString""Active LED color.
labellabelString""Optional label text displayed above the LED.
iconiconString""Optional Font Awesome icon class name.
isBlinkingis-blinkingBooleanfalseEnables blinking when the state is active.

Declarative only (display: none); not rendered as visible children. Icons are placed on the host so page-level stylesheets apply.

NameDescription
— (default)Optional <fx-semaphore-state> children. When empty, uses FxSemaphore.defaultStates.
icon-{value}Per-lamp icon slot (managed from icon attribute or from nested slot="icon" on the state).
PropertyDefaultDescription
--fx-semaphore-icon-size0.85remFont Awesome icon size above each LED.

classDiagram
    direction TB
    class FxElement
    class FxSemaphore

    FxElement <|-- FxSemaphore : Animatable

See also Architecture.