AnyBio
Components

bio-mood

<bio-mood>

A daily mood observation widget that lets users select their mood from a configurable emoji scale. Records the selection as an AnyBio observation with trend tracking across days.

<bio-mood></bio-mood>

How It Works

When <bio-mood> receives context from a parent <bio-provider>:

  1. Resolves configuration — in profile-driven mode, reads the mood scale, labels, biosignal, and status from the SDK config's mood section; in static mode, uses attribute defaults
  2. Shows current state — if mood has already been logged for the current day, displays "Mood logged" with a timestamp and the selected emoji highlighted
  3. Presents emoji scale — renders buttons for each label in the scale (e.g., 😔 😐 🙂 😊 😄)
  4. Records observation — on selection, posts an observation with metadata: { widget: "bio-mood", day: N }
  5. Supports updates — clicking a different emoji after initial selection re-submits with the new value

Modes

Profile-Driven Mode

Omit all attributes. The widget reads its configuration from the episode profile's spec.sdk.mood section:

<bio-mood></bio-mood>

The profile defines:

  • scale — number of options (e.g., 5)
  • labels — emoji array (e.g., ["😔", "😐", "🙂", "😊", "😄"])
  • biosignal — the biosignal ID to record (e.g., "mood")

Static Mode

Pass configuration directly:

<bio-mood
  scale="5"
  labels='["😔","😐","🙂","😊","😄"]'
  biosignal="mood"
  episode-id="ep_abc123">
</bio-mood>

Attributes

AttributeTypeRequiredDescription
scalenumberNoNumber of mood options. Defaults to 5.
labelsstringNoJSON array of emoji labels. Defaults to ["😔","😐","🙂","😊","😄"].
biosignalstringNoBiosignal ID for the observation. Defaults to "mood".
episode-idstringNoEpisode ID. Falls back to the episode resolved by <bio-provider>.

Events

EventDetailDescription
anybio:mood:submit{ value, biosignal, episodeId, day }Fired on initial mood selection.
anybio:mood:update{ value, biosignal, episodeId, day }Fired when mood is changed after initial selection.
bio-mood-complete(same as anybio:mood:submit)Backward-compatible alias.

CSS Classes

ClassElement
.bio-mood-buttonsButton container (flex row)
.bio-mood-btnIndividual mood button
.bio-mood-selectedApplied to the selected button
.bio-mood-emojiEmoji text
.bio-mood-status"Mood logged 10:30 AM" status text

Each mood button sets a --mood-color CSS variable based on the mood index, using the --bio-mood-* palette:

VariableDefaultMood
--bio-mood-great#22c55eBest / happiest
--bio-mood-good#84cc16Good
--bio-mood-okay#eab308Okay
--bio-mood-bitoff#f97316A bit off
--bio-mood-notbest#ef4444Not my best

Code Examples

Profile-Driven

<bio-provider
  api-key="org_your_key"
  project-key="proj_your_key"
  xuser-id="user-123">

  <h3>How Do You Feel Today?</h3>
  <bio-mood></bio-mood>

</bio-provider>

With Event Handling

<bio-mood id="mood"></bio-mood>

<script>
  document.addEventListener('anybio:mood:submit', (e) => {
    const { value, biosignal } = e.detail;
    console.log(`Mood recorded: ${value} for ${biosignal}`);
    showToast('Mood logged!');
  });

  document.addEventListener('anybio:mood:update', (e) => {
    console.log(`Mood updated to: ${e.detail.value}`);
    showToast('Mood updated!');
  });
</script>

Custom Styling

/* Larger emoji buttons */
.bio-mood-btn {
  padding: 12px 20px;
}

.bio-mood-emoji {
  font-size: 2.5rem;
}

/* Custom mood palette */
bio-mood {
  --bio-mood-great: #34a853;
  --bio-mood-notbest: #ea4335;
}

On this page