Skip to content
Get started

Components

GlowOrb

Unstable: the voice orb as a WebGL shader, a glossy sphere that grows with the voice level, for VoiceOrb or on its own. Import it from @nizivo/react/unstable/glow-orb.

Tier: clientUnstable

Examples

Basic

The shader orb in VoiceOrb's orb slot, speaking. Without a level, it simulates a voice; give it a function that returns your audio's level (0 to 1) and it follows that each frame.

Speaking…
import type { JSX } from 'react';
import { VoiceOrb } from '@nizivo/react/unstable/voice-orb';
import { GlowOrb } from '@nizivo/react/unstable/glow-orb';

export function GlowOrbExample(): JSX.Element {
  return <VoiceOrb state="speaking" orb={<GlowOrb state="speaking" />} />;
}

Import

import { GlowOrb } from '@nizivo/react/unstable/glow-orb';

// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/glow-orb.css';

Static or interactive

Client. The server renders the CSS orb VoiceOrb draws, as a poster; once the page hydrates, a canvas draws the shader over it from its first frame. A browser without WebGL keeps the poster. How to choose.

With VoiceOrb

Pass it as VoiceOrb's orb, with the same state: <VoiceOrb state={state} orb={<GlowOrb state={state} />} />. It fills VoiceOrb's 160 px orb, and VoiceOrb drops its own halo behind it. The same goes for AiWelcome's 72 px orb (orb={<GlowOrb />}, idle, so it breathes). On its own it fills its box, a square.

The voice level

level is the voice's loudness, from 0 to 1. Pass a number, or a function the orb calls on every frame, such as one that reads a Web Audio AnalyserNode, so the page does not re-render sixty times a second. Without level, the orb simulates a voice for its state: still when idle, soft while listening, in syllables while speaking. The sphere grows with the level, its outline moves while it is live, the light drifts so the highlight changes angle, and the halo widens.

Light on a phone

No library: one fragment shader on WebGL 1 and a few kilobytes of script. It draws only while it is on screen and the page is visible, at a pixel ratio of at most 2. Under Reduced motion it draws one still frame. In forced colours it shows the poster with an outline, since the canvas is only colour.

Colours

It reads Nizivo's accent and brand colours, and follows the theme. Set --nz-glow-orb-light, --nz-glow-orb-deep and --nz-glow-orb-halo (a colour whose alpha is the halo's strength) to recolour it. It is decoration, hidden from assistive technology: say the state in words beside it, as VoiceOrb's label does.

Props

Client component Renders data-slot="glow-orb" with the class nz-glow-orb. Props: GlowOrbProps. Source: src/unstable/glow-orb/glow-orb.client.tsx.

NameTypeDefaultDescription
levelnumber | (() => number)–

The voice level, 0 to 1: a number, or a function the orb calls each frame (a Web Audio analyser's level), so the page does not re-render 60 times a second. Without it, the orb simulates a voice for the state.

stateGlowOrbState
"idle""listening""speaking"
'idle'

VoiceOrb's state: the outline moves while listening or speaking.

  • Also takes every attribute of <span> except children. (Omit<ComponentPropsWithRef<"span">, "children">)

Other exports

GlowOrbProps type

import type { GlowOrbProps } from '@nizivo/react/unstable/glow-orb'

The props of GlowOrb, listed above.

GlowOrbState type

import type { GlowOrbState } from '@nizivo/react/unstable/glow-orb'

The voice states, as VoiceOrb names them.

type GlowOrbState = "idle" | "listening" | "speaking"

Data attributes and slots

Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.

SlotRendered byData attributes
glow-orb
.nz-glow-orb
GlowOrb
root (no render)
none

CSS hooks

Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.

HookDefaultRead as
--nz-glow-orb-deep--nz-bg-brand
  • outline-color on .nz-glow-orb
--nz-glow-orb-halocolor-mix(in srgb, color-mix(in oklab, var(--nz-bg-accent) 50%, var(--nz-bg-brand-muted)) 55%, transparent)
  • -webkit-text-decoration-color on .nz-glow-orb
  • text-decoration-color on .nz-glow-orb
--nz-glow-orb-light--nz-bg-accent
  • color on .nz-glow-orb

Layers: nz.components. Classes: .nz-glow-orb, .nz-glow-orb-canvas, .nz-glow-orb-poster, .nz-glow-orb-sphere.

Tokens this stylesheet reads (5)

--nz-bg-accent, --nz-bg-brand, --nz-bg-brand-muted, --nz-bg-canvas, --nz-radius-full

Accessibility

Nothing in this component takes focus or keyboard input.

Keyboard

None.

On this page