Skip to content

Dictionary entry

A word set as a dictionary sets it, with pronunciation, part of speech, senses and origin.

<section class="cap-dictionary-entry" id="de-default" aria-label="Dictionary entry: Almanac" data-cap="dictionary-entry">
  <p class="cap-dictionary-entry-head">
    <dfn class="cap-dictionary-entry-word"><span class="cap-sr-only">almanac</span><span aria-hidden="true">al·ma·nac</span></dfn>
    <span class="cap-dictionary-entry-pron">
      <span class="cap-dictionary-entry-ipa">/ˈɔːl.mə.næk/</span>
      <span class="cap-dictionary-entry-respell">AWL-muh-nak</span>
      <a class="cap-dictionary-entry-listen" href="./missing-clip.mp3" data-cap-part="listen-link" aria-label="Listen to the pronunciation of Almanac">
        <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z" fill="currentColor" /><path class="cap-dictionary-entry-wave" d="M15 9.2a4 4 0 0 1 0 5.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /><path class="cap-dictionary-entry-wave" d="M17.6 6.6a7.6 7.6 0 0 1 0 10.8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /></svg>
      </a>
      <button type="button" class="cap-dictionary-entry-listen" data-cap-part="listen" data-src="./missing-clip.mp3" aria-label="Listen to the pronunciation of Almanac" aria-pressed="false" hidden>
        <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z" fill="currentColor" /><path class="cap-dictionary-entry-wave" d="M15 9.2a4 4 0 0 1 0 5.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /><path class="cap-dictionary-entry-wave" d="M17.6 6.6a7.6 7.6 0 0 1 0 10.8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /></svg>
      </button>
    </span>
  </p>
  <p class="cap-dictionary-entry-pos"><i>noun</i>; plural <i>almanacs</i></p>
  <ol class="cap-dictionary-entry-senses">
    <li>A yearly book of the calendar, with the dates of holidays, tides and the phases of the moon.</li>
    <li><i class="cap-dictionary-entry-label">publishing.</i> A yearly collection of facts and figures on one subject, such as the Example Co annual report.</li>
  </ol>
  <p class="cap-dictionary-entry-ety"><span class="cap-dictionary-entry-ety-label">Etymology</span> From Medieval Latin <i lang="la">almanach</i>, a table of the movements of the stars, of uncertain origin.</p>
</section>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/dictionary-entry.css";
import { enhance } from "capsomer/behavior/dictionary-entry";

enhance();

Usage

<section class="cap-dictionary-entry" aria-label="Dictionary entry: Almanac" data-cap="dictionary-entry">
  <p class="cap-dictionary-entry-head">
    <dfn class="cap-dictionary-entry-word"><span class="cap-sr-only">almanac</span><span aria-hidden="true">al·ma·nac</span></dfn>
    <span class="cap-dictionary-entry-pron">
      <span class="cap-dictionary-entry-ipa">/ˈɔːl.mə.næk/</span>
      <span class="cap-dictionary-entry-respell">AWL-muh-nak</span>
      <a class="cap-dictionary-entry-listen" href="/audio/almanac.mp3" data-cap-part="listen-link" aria-label="Listen to the pronunciation of Almanac"><svg aria-hidden="true">…</svg></a>
      <button type="button" class="cap-dictionary-entry-listen" data-cap-part="listen" data-src="/audio/almanac.mp3" aria-label="Listen to the pronunciation of Almanac" aria-pressed="false" hidden><svg aria-hidden="true">…</svg></button>
    </span>
  </p>
  <p class="cap-dictionary-entry-pos"><i>noun</i>; plural <i>almanacs</i></p>
  <ol class="cap-dictionary-entry-senses">
    <li>A yearly book of the calendar.</li>
    <li><i class="cap-dictionary-entry-label">publishing.</i> A yearly collection of facts on one subject.</li>
  </ol>
  <p class="cap-dictionary-entry-ety"><span class="cap-dictionary-entry-ety-label">Etymology</span> From Medieval Latin <i lang="la">almanach</i>.</p>
</section>
import { DictionaryEntry } from "capsomer/react/dictionary-entry";

<DictionaryEntry
  term="Almanac"
  syllables="al·ma·nac"
  ipa="/ˈɔːl.mə.næk/"
  respelling="AWL-muh-nak"
  partOfSpeech="noun"
  plural={["almanacs"]}
  senses={[{ text: "A yearly book of the calendar." }, { label: "publishing", text: "A yearly collection of facts on one subject." }]}
  etymology={["From Medieval Latin ", ["la", "almanach"], "."]}
  audio="/audio/almanac.mp3"
/>

Examples

Playing, and hover

<div class="cap-specimen-row">
  <button type="button" class="cap-dictionary-entry-listen" id="de-playing" aria-label="Listen to the pronunciation of Lantern" aria-pressed="true">
    <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z" fill="currentColor" /><path class="cap-dictionary-entry-wave" d="M15 9.2a4 4 0 0 1 0 5.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /><path class="cap-dictionary-entry-wave" d="M17.6 6.6a7.6 7.6 0 0 1 0 10.8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /></svg>
  </button>
  <button type="button" class="cap-dictionary-entry-listen" id="de-hover" aria-label="Listen to the pronunciation of Ledger" aria-pressed="false">
    <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z" fill="currentColor" /><path class="cap-dictionary-entry-wave" d="M15 9.2a4 4 0 0 1 0 5.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /><path class="cap-dictionary-entry-wave" d="M17.6 6.6a7.6 7.6 0 0 1 0 10.8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /></svg>
  </button>
</div>

Without script: the speaker is a link to the clip

<section class="cap-dictionary-entry" id="de-link" aria-label="Dictionary entry: Ledger">
  <p class="cap-dictionary-entry-head">
    <dfn class="cap-dictionary-entry-word"><span class="cap-sr-only">ledger</span><span aria-hidden="true">led·ger</span></dfn>
    <span class="cap-dictionary-entry-pron">
      <span class="cap-dictionary-entry-ipa">/ˈlɛdʒ.ər/</span>
      <span class="cap-dictionary-entry-respell">LEJ-er</span>
      <a class="cap-dictionary-entry-listen" href="./missing-clip.mp3" data-cap-part="listen-link" aria-label="Listen to the pronunciation of Ledger">
        <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z" fill="currentColor" /><path class="cap-dictionary-entry-wave" d="M15 9.2a4 4 0 0 1 0 5.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /><path class="cap-dictionary-entry-wave" d="M17.6 6.6a7.6 7.6 0 0 1 0 10.8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" /></svg>
      </a>
    </span>
  </p>
  <p class="cap-dictionary-entry-pos"><i>noun</i></p>
  <ol class="cap-dictionary-entry-senses">
    <li>A book in which the accounts of a business are kept.</li>
  </ol>
</section>

No clip, no etymology

<section class="cap-dictionary-entry" id="de-plain" aria-label="Dictionary entry: Lantern">
  <p class="cap-dictionary-entry-head">
    <dfn class="cap-dictionary-entry-word">Lantern</dfn>
    <span class="cap-dictionary-entry-pron"><span class="cap-dictionary-entry-ipa">/ˈlæn.tərn/</span></span>
  </p>
  <p class="cap-dictionary-entry-pos"><i>noun</i></p>
  <ol class="cap-dictionary-entry-senses">
    <li>A lamp in a case that shields its flame from the wind.</li>
  </ol>
</section>

API reference

SpeakerIcon

DictionaryEntry

PropTypeRequiredDoes
termstringYesThe word as it is spelled ("Almanac"); read by screen readers in lowercase.
syllablesstringThe headword as it is shown, with its syllable dots ("al·ma·nac"); hidden from screen readers.
ipastring
respellingstring
partOfSpeechstringYes
pluralstring[] | null
sensesDictionarySense[]Yes
etymologyEtymologyPart[]
audiostringThe clip. Without it there is no speaker.
listenstringThe speaker's name. Default: "Listen to the pronunciation of {term}".

Functions

FunctionSignatureDoes
listenLabel(term: string): stringThe dictionary entry's speaker. The server renders a plain link to the clip, which any browser plays with script off; this swaps in the button, which plays the clip in place on click, Enter or Space (a native button gives all three). Nothing plays until asked and the clip is fetched on the first press, not before. aria-pressed carries the state while it plays; a second press stops it. A clip that cannot load or play brings the link back, so the reader still has a way to hear it. The speaker's name: what it does and for which word.
wireListen(button: HTMLButtonElement, link: HTMLAnchorElement): () => voidWires one speaker pair: button (hidden in the markup, data-src the clip) and link (the no-script link). Shows the button, hides the link, and returns a function that detaches.
enhance(root?: Element | Document | DocumentFragment): () => voidAttaches to every [data-cap="dictionary-entry"] under root not yet attached. Returns a function that detaches. The root is Element | Document | DocumentFragment, not ParentNode: under @cloudflare/workers-types an HTMLFormElement does not type as a ParentNode, so a site could not pass its form.

Parts and data attributes

ClassIs
.cap-dictionary-entrythe root
.cap-dictionary-entry-etya part
.cap-dictionary-entry-ety-labela part
.cap-dictionary-entry-heada part
.cap-dictionary-entry-ipaa part
.cap-dictionary-entry-labela part
.cap-dictionary-entry-listena part
.cap-dictionary-entry-posa part
.cap-dictionary-entry-prona part
.cap-dictionary-entry-respella part
.cap-dictionary-entry-sensesa part
.cap-dictionary-entry-wavea part
.cap-dictionary-entry-worda part
StateRead from
:focus-visiblethe platform
:hoverthe platform
[aria-pressed="true"]an attribute
[hidden]an attribute

Accessibility

KeyDoes
TabReaches the speaker
Enter or Space on the speakerPlays the clip; again stops it
Enter on the speaker link (no script)Opens the clip
  • The speaker is named "Listen to the pronunciation of {term}" (listenLabel), its icon aria-hidden; as a button it is a toggle (aria-pressed).
  • Foreign words in the etymology carry their lang, so a screen reader pronounces them in their language.
  • The speaker's hit area is at least --target and --control; under forced colors a playing speaker keeps a heavier edge in Highlight, since its fill is gone.
  • Screen readers: no manual NVDA or VoiceOver run, by decision (2026-11-07); the automated browser checks and a front-end review stand in. Automated: see the site's Tests page.