Skip to main content
cngx-src documentation

CngxSpeakButton

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AAA

projects/ui/speak/speak-button.ts

Import#

import { CngxSpeakButton } from '@cngx/ui/speak'

Description#

Ready-made speaker button that connects to a CngxSpeak directive via an explicit [speakRef] input - no ancestor injection.

Ships with a speaker/stop SVG icon and CSS custom properties for full theming control. Include speak-button-theme.scss for automatic Material theme integration.

Basic usage

<span [cngxSpeak]="text" #tts="cngxSpeak">{{ text }}</span>
<cngx-speak-button [speakRef]="tts" />

Material theme integration

@use '@cngx/themes/material/speak-button-theme' as speak;
@include speak.theme($theme);

https://cngxjs.github.io/cngx/examples/#/ui/speak/speak-button/styled-speaker-icon

Metadata#

Host#

Index#

Inputs#

speakRef#CngxSpeak
input()Required

The CngxSpeak directive instance to connect to.

HostBindings#

BindingExpression
[class.cngx-speak-button--speaking]speakRef().speaking()

Default visuals for CngxSpeakButton. The host carries .cngx-speak-button and renders a single __btn child with an inner __icon. The active / speaking accent deliberately uses warm orange rather than --cngx-color-primary so the speak surface reads as ambient feedback, not a primary call-to-action - brand-wide overrides target --cngx-speak-btn-active-color directly.

State modifiers

  • --speaking - fills the button with --cngx-speak-btn-speaking- bg (orange) and paints the icon white

On .cngx-speak-button__btn:

  • :hover - swaps to --cngx-speak-btn-active-color for icon and border, and to --cngx-speak-btn-hover-bg for the surface

Slots

  • .cngx-speak-button__btn - the actual <button>; carries shape, border, transition, and hover/active state painting
  • .cngx-speak-button__icon - inner glyph, nudged +1px on the inline axis to optically center against the rounded surface

Inheritance

  • --cngx-speak-btn-bg -> --cngx-color-surface
  • --cngx-speak-btn-hover-bg -> --cngx-speak-btn-bg -> --cngx-color-surface
  • --cngx-speak-btn-speaking-bg -> --cngx-speak-btn-active-color

Pair with

  • @cngx/themes/material/speak-button-theme - Material 3 icon-button surface

Index#

Layout

--cngx-speak-btn-size#<length>
Default value 36px

Hit-target diameter of the button.

--cngx-speak-btn-icon-size#<length>
Default value 18px

Inner icon size.

--cngx-speak-btn-radius#<length>
Default value 8px

Corner radius.

Surface

--cngx-speak-btn-border-width#<length>
Default value 1px

Border width.

--cngx-speak-btn-bg#<color>
Default value oklch(1 0 0)

Resting background. Falls back through --cngx-color-surface.

--cngx-speak-btn-color#<color>
Default value oklch(0.45 0 0)

Resting icon color - muted.

Motion

--cngx-speak-btn-transition#<time>
Default value 0.15s

Transition duration for the state-color crossfade.

State / Active

--cngx-speak-btn-active-color#<color>
Default value oklch(0.72 0.18 70)

Accent color of the speaking / hover state. Warm orange by design - independent of --cngx-color-primary.

State / Hover

--cngx-speak-btn-hover-bg#<color>
Default value oklch(1 0 0)

Background on hover.

State / Speaking

--cngx-speak-btn-speaking-color#<color>
Default value oklch(1 0 0)

Icon color while actively speaking.

--cngx-speak-btn-speaking-bg#<color>
Default value oklch(0.72 0.18 70)

Background while actively speaking - filled with the orange accent for unmistakable feedback.