Player Customization

Lexora provides two ways to embed and customize the Audio Player:

  • Markup embed (<lexora data-speech="...">) automatically uses the settings configured inside Lexora, including colors, labels, and enabled controls.
  • JavaScript embed (new Lexora(target, { ... })) gives you runtime control over style, labels, icons, sticky behavior, playback options, and Auto Mode behavior.

Embedding Methods

Start by installing the Lexora library on your website. Once the installation is complete, you can integrate Text to Speech using one of the following approaches:

1) Markup Embed

This is the simplest integration method. The player initializes automatically and applies the settings already configured in your Lexora project.

<lexora data-speech="[YOUR_SPEECH_ID]"></lexora>

Use this method when you want consistent styling and behavior across multiple pages without writing custom JavaScript.

2) JavaScript Initialization

Use JavaScript when you need more control over rendering, runtime updates, or page-specific behavior.

const target = document.querySelector('#lexora-target');

new Lexora(target, {
  speech: '[YOUR_SPEECH_ID]'
});

Lexora merges your configuration with the default player settings, so you only need to pass the options you want to override.

Supported JavaScript Options

Core Options

OptionTypePurpose
speechstringSpeech key (Audio ID).
stickyplayerbooleanEnables or disables the sticky mini player.
playspeedbooleanEnables or disables playback speed controls.
glassbooleanEnables or disables the glass visual treatment.
jumpSecondsnumberSets the jump amount for skip controls. Default is 10.
seekStepnumberLegacy alias of jumpSeconds.
playbackJumpbooleanLegacy playback jump flag kept for backward compatibility.
new Lexora(target, {
  speech: '[YOUR_SPEECH_ID]',
  stickyplayer: true,
  playspeed: true,
  glass: true,
  jumpSeconds: 10
});

Style Customization

The style object controls the visual theme of the player. These values are applied internally as CSS variables.

Supported Style Keys

KeyPurpose
primaryMain accent color.
backgroundBase player background color.
foregroundBase player text and icon color.
widget-backgroundExplicit widget surface background override.
widget-foregroundExplicit widget text and icon override.
widget-btn-backgroundMain play and stop button background.
widget-btn-foregroundMain play and stop icon color.
seek-backgroundSeekbar track color.
seek-fillSeekbar progress fill color.
seek-thumbSeekbar thumb color.
visualizerAnalyzer and visualizer bar color.
new Lexora(target, {
  speech: '[YOUR_SPEECH_ID]',
  style: {
    primary: '#7CD259',
    background: '#0C120D',
    foreground: '#FFFFFF',
    'widget-background': '#0C120D',
    'widget-foreground': '#FFFFFF',
    'widget-btn-background': '#7CD259',
    'widget-btn-foreground': '#0C120D',
    'seek-background': '#FFFFFF',
    'seek-fill': '#7CD259',
    'seek-thumb': '#FFFFFF',
    visualizer: '#7CD259'
  }
});

If you only set primary, background, and foreground, Lexora automatically derives the other UI colors using its default fallback rules.

For accessibility, keep a strong contrast between background and foreground colors.

Labels Customization

The labels object lets you override the player text. This is useful for localization, product tone, or language-specific UI adjustments.

The loading label is used for standard loading states. The generating label is used in Auto Mode while speech is being generated progressively. The jumpForward and jumpBack labels are used automatically on iOS and Safari, where playback speed controls are replaced by jump controls.

Supported Label Keys

KeyPurpose
playMain play action label.
stopStops playback completely.
resumeResumes playback after pause.
pausePauses active playback.
speedLabel for playback speed controls.
closeCloses player-related modal interfaces.
initInitial idle message before playback starts.
loadingStandard loading state message.
generatingAuto Mode generation state message.
jumpBackJump back control label used automatically on iOS and Safari.
jumpForwardJump ahead control label used automatically on iOS and Safari.
new Lexora(target, {
  speech: '[YOUR_SPEECH_ID]',
  labels: {
    play: 'Play',
    stop: 'Stop',
    resume: 'Resume',
    pause: 'Pause',
    speed: 'Playback speed',
    close: 'Close',
    init: 'Press play to listen',
    loading: 'Loading speech...',
    generating: 'Generating speech...',
    jumpBack: 'Skip backward',
    jumpForward: 'Skip forward'
  }
});

Icons Customization

You can replace the default controls by passing inline SVG strings through the icons object.

Recommended: use fill="currentColor" or stroke="currentColor" so icons inherit your theme colors correctly.

Supported Icon Keys

KeyPurpose
playMain play icon.
pausePause icon.
stopStop icon.
closeClose icon.
minimizeSticky player minimize icon.
waveWave / voice indicator icon.
autoscrollAuto mode scrolling indicator icon.
jumpBackJump back icon.
jumpForwardJump forward icon.
new Lexora(target, {
  speech: '[YOUR_SPEECH_ID]',
  icons: {
    play: '<svg>...</svg>',
    pause: '<svg>...</svg>',
    stop: '<svg>...</svg>'
  }
});

Sticky Player Behavior

When stickyplayer is enabled, Lexora shows a compact sticky player when the main player leaves the viewport.

  • It appears only while playback is active or paused.
  • It hides automatically when playback stops.
  • It inherits the same style configuration as the main player.
new Lexora(target, {
  speech: '[YOUR_SPEECH_ID]',
  stickyplayer: true
});

Playback Speed

When enabled, the speed control cycles through 1x, 1.5x, and 2x.

On iOS and Safari, playback speed controls are not available. In that case, Lexora automatically replaces the speed control with jump backward and jump forward controls.

new Lexora(target, {
  speech: '[YOUR_SPEECH_ID]',
  playspeed: true,
  jumpSeconds: 15
});

Auto Mode Options

Auto Mode lets Lexora extract readable text directly from the page and generate speech on demand.

Supported Auto Mode Options

OptionTypePurpose
modestringSet to auto to enable Auto Mode.
contentTargetstringCSS selector of the content container to read.
scriptstringExplicit text content to read instead of extracting from the page.
languagestringLanguage code used to resolve Auto Mode voice.
voicestringVoice name, for example Aria.
new Lexora(target, {
  mode: 'auto',
  contentTarget: '.article-body',
  language: 'en-US',
  voice: 'Aria',
  stickyplayer: true,
  style: {
    primary: '#7CD259',
    background: '#0C120D',
    foreground: '#FFFFFF'
  }
});

In Auto Mode, runtime options passed through JavaScript take priority over the project defaults.