sref
- Attribute
sref- Type
string- Default
""
The Sefaria reference to load when data isn't set.
Created/edited by GitHub Copilot; pending human review.
This page lists the attributes, properties, data, empty states, events, and style settings of the toolkit's five elements. The generator builds it from the package's custom-elements.json.
The elements are registered when you load the script tag or when you import the package root with import "@sefaria/web-components";. The element subpaths, such as @sefaria/web-components/source-card, don't register their element. They export types and a few helpers.
This page documents the code on the main branch. The source stamp is not an npm release or a development snapshot. This copy was built from commit 6fde603.
Install an exact npm version or use a version-pinned npm CDN module. The npm alpha tag moves between reviewed prereleases. It is not a main-build snapshot. Older pinned releases keep their own behavior and can lack APIs added since. Install and status lists package commands and jsDelivr/UNPKG files.
<sefaria-text-segment><sefaria-bilingual-segment><sefaria-source-card><sefaria-connections-panel><sefaria-reader><sefaria-text-segment>. Shows the text of one passage in one selected edition. How to use it.
Set an attribute in HTML or a property in JavaScript. If a property has no attribute, set it in JavaScript.
srefsrefstring""The Sefaria reference to load when data isn't set.
dataunknown | undefinedundefinedSefaria API response data to render. When it's set, the element doesn't fetch anything.
sourceSefariaDataSource | undefinedundefinedWhere this element gets its data, instead of the shared data source.
versionLanguageversion-languagestring | undefinedundefinedLanguage of the edition to show, instead of the primary edition.
versionTitleversion-titlestring | undefinedundefinedversion-title alone chooses another edition in the original language. To choose a translation by title, also set translation-language.
translationLanguagetranslation-languagestring | undefinedundefinedPreferred translation language. Can't be combined with versionLanguage.
translationFallbacktranslation-fallback"default" | "none""none"What happens when the preferred translation language is missing: default loads Sefaria's default translation, none shows a status such as "No french text.".
vocalizationModevocalization-modeVocalizationMode"taamim_and_nikkud"How much Hebrew vowel and cantillation marking to keep. none removes both.
selectedVersionTextSegmentSelectedVersionInfo | undefinedDetails of the edition currently shown.
statusSefariaElementStatusLoading state: "empty", "loading", "ready" or "error".
data takes the body of a successful GET /api/v3/texts/{tref} response, typed CoreV3TextsResponse from @sefaria/api-client. It also accepts a TextSegmentSelectedData object with kind: "selected". When data is defined, the element uses it instead of loading sref, even when it is invalid. It treats the value as a status 200 response.
The element shows its empty state when the chosen edition has no text. The message depends on how the edition was chosen. If the default primary edition is missing, you see No primary text is available. If an edition you selected has no text, you can see a message that names that edition. On some paths, the element shows the response's warning instead.
sefaria-text-segment-errorReports a failure while loading or validating data from sref.
CSS parts: none.
<sefaria-bilingual-segment>. Shows one passage in its primary edition, together with a translation. The primary edition is the one marked isPrimary. How to use it.
Set an attribute in HTML or a property in JavaScript. If a property has no attribute, set it in JavaScript.
srefsrefstring""The Sefaria reference to load when data isn't set.
dataunknown | undefinedundefinedSefaria API response data to render. When it's set, the element doesn't fetch anything.
sourceSefariaDataSource | undefinedundefinedWhere this element gets its data, instead of the shared data source.
primaryVersionTitleprimary-version-titlestring | undefinedundefinedExact title of the edition to show as the primary text.
translationVersionTitletranslation-version-titlestring | undefinedundefinedExact title of the edition to show as the translation.
translationLanguagetranslation-languagestring | undefinedundefinedPreferred translation language. translationFallback controls what happens when Sefaria has none.
translationFallbacktranslation-fallback"default" | "none""none"What happens when the preferred translation language is missing: default loads Sefaria's default translation, none shows a status such as "No french text.".
contentLanguagecontent-languageBilingualSegmentContentLanguage"both"Which text to show: primary, translation or both.
layoutlayoutBilingualSegmentLayout"auto"How the two texts are arranged: auto, stacked or side-by-side.
sideOrderside-orderBilingualSegmentSideOrder"primary-first"Which text comes first side by side: primary-first or translation-first.
vocalizationModevocalization-modeVocalizationMode"taamim_and_nikkud"How much Hebrew vowel and cantillation marking to keep. none removes both.
statusSefariaElementStatusLoading state: "empty", "loading", "ready" or "error".
data takes the body of a successful GET /api/v3/texts/{tref} response, typed CoreV3TextsResponse from @sefaria/api-client. When data is defined, the element uses it instead of loading sref, even when it is invalid. It treats the value as a status 200 response.
The element shows its empty state when neither side has text. Each missing side has its own message, such as No primary text is available. or No translation text is available. The element can show the response's warning for that side instead. When only one side is missing, you see the other side's text and the missing side's message. contentLanguage filters which sides are shown.
sefaria-bilingual-segment-errorReports a failure while loading or validating data from sref.
CSS parts: none.
<sefaria-source-card>. Shows a passage as a card. The card has a heading, the text in the primary edition, a translation, and the title of each edition shown. When an edition's source is a valid http(s) address, the title links to it. Any other source appears as plain text. How to use it.
Set an attribute in HTML or a property in JavaScript. If a property has no attribute, set it in JavaScript.
srefsrefstring""The Sefaria reference to load when data isn't set.
dataunknown | undefinedundefinedSefaria API response data to render. When it's set, the element doesn't fetch anything.
sourceSefariaDataSource | undefinedundefinedWhere this element gets its data, instead of the shared data source.
primaryVersionTitleprimary-version-titlestring | undefinedundefinedExact title of the edition to show as the primary text.
translationVersionTitletranslation-version-titlestring | undefinedundefinedExact title of the edition to show as the translation.
translationLanguagetranslation-languagestring | undefinedundefinedPreferred translation language. translationFallback controls what happens when Sefaria has none.
translationFallbacktranslation-fallback"default" | "none""default"What happens when the preferred translation language is missing: default loads Sefaria's default translation, none shows a status such as "No french text.".
contentLanguagecontent-languageBilingualPairContentLanguage"both"Which text to show: primary, translation or both.
layoutlayoutBilingualPairLayout"auto"How each pair of texts is arranged: auto, stacked or side-by-side.
sideOrderside-orderBilingualPairSideOrder"primary-first"Which text comes first side by side: primary-first or translation-first.
vocalizationModevocalization-modeVocalizationMode"taamim_and_nikkud"How much Hebrew vowel and cantillation marking to keep. none removes both.
showAddressLabelsbooleantrueWhether small reference labels are shown beside the texts.
selectableselectablebooleanfalseLets readers select the verses that have their own reference.
selectedPositionreadonly number[] | undefinedundefinedPosition of the selected verse, as an array of numbers rather than a reference.
hideAttributionshide-attributionsbooleanfalseHides the edition attribution.
statusSefariaElementStatusLoading state: "empty", "loading", "ready" or "error".
data takes the body of a successful GET /api/v3/texts/{tref} response, typed CoreV3TextsResponse from @sefaria/api-client. When data is defined, the element uses it instead of loading sref, even when it is invalid. It treats the value as a status 200 response.
The element shows its empty state when the response has no text for either side. The card keeps its heading and edition details. It shows why each side is missing, such as No primary text is available.
sefaria-source-selectReports that a reader selected one item in the source card.
sefaria-source-card-errorReports a failure while loading or validating data from sref.
CSS parts: none.
<sefaria-connections-panel>. Lists the commentaries and other texts that Sefaria connects to a reference. It groups them by category. How to use it.
Set an attribute in HTML or a property in JavaScript. If a property has no attribute, set it in JavaScript.
srefsrefstring""The Sefaria reference whose connections to load.
sourceSefariaDataSource | undefinedundefinedWhere this element gets its data, instead of the shared data source.
withTextwith-textbooleantrueWhether the links include the connected texts.
categorycategorystring | undefinedundefinedCategory of the loaded links to show.
pagepagenumber0Zero-based page of the loaded links to show.
showPreviewsshow-previewsbooleantrueShows or hides the text previews already loaded, without fetching more.
vocalizationModevocalization-modeVocalizationMode"taamim_and_nikkud"How much Hebrew vowel and cantillation marking to keep in previews. none removes both.
statusSefariaElementStatusLoading state: "empty", "loading", "ready" or "error".
It has no data property. To give it local data, set source to { kind: "custom", loader }, where the custom loader's getText and getLinks functions answer from your data. See Give components your own data.
The element shows its empty state when no text connections remain after the element leaves out sheet links. A response with only sheets is empty too. The message is No text connections were returned.
sefaria-connections-category-changeAsks to show a different connection category. Call preventDefault() to stop the panel from switching to that category and returning to the first page.
sefaria-connections-preview-requestRequests connection previews. The element loads them unless a listener cancels the event. Call preventDefault() to stop the panel from loading previews itself. If you don't call it, a panel that loads from sref requests the connections again with their text.
sefaria-connections-page-changeAsks to show a different page of connections. Call preventDefault() to stop the panel from changing page.
sefaria-connection-selectReports that a reader selected one connected reference. Call preventDefault() to do nothing. The panel has no default action for this event.
sefaria-connections-panel-errorReports a failure while loading or validating data from sref.
CSS parts: none.
<sefaria-reader>. Shows a passage with its connected texts. Readers can move between them. How to use it.
Set an attribute in HTML or a property in JavaScript. If a property has no attribute, set it in JavaScript.
srefsrefstring""The reference the Reader starts from. Navigating inside the Reader doesn't change it.
sourceSefariaDataSource | undefinedundefinedWhere this element gets its data, instead of the shared data source.
translationLanguagetranslation-languagestring | undefinedundefinedPreferred translation language, for the starting text and texts you navigate to.
translationFallbacktranslation-fallback"default" | "none""default"What happens when the preferred translation language is missing: default loads Sefaria's default translation, none shows a status such as "No french text.".
primaryVersionTitleprimary-version-titlestring | undefinedundefinedExact title of the primary edition for the starting reference.
translationVersionTitletranslation-version-titlestring | undefinedundefinedExact title of the translation edition for the starting reference.
hideAttributionshide-attributionsbooleanfalseHides the edition attribution on the source card.
activePaneactive-paneReaderPane"source"Which pane the compact layout shows: source or connections.
chatExportchat-exportbooleanfalseShows a button that sends the selected reference to your page's chat, when one is selected.
contentLanguagecontent-languageBilingualPairContentLanguage"both"Which text the source card shows: primary, translation or both.
layoutlayoutBilingualPairLayout"auto"How the source card arranges its two texts: auto, stacked or side-by-side.
sideOrderside-orderBilingualPairSideOrder"primary-first"Which text comes first side by side: primary-first or translation-first.
showConnectionPreviewsshow-connection-previewsbooleantrueWhether connection previews are shown.
vocalizationModevocalization-modeVocalizationMode"taamim_and_nikkud"How much Hebrew vowel and cantillation marking to keep. none removes both.
statusSefariaElementStatusLoading state: "empty", "loading", "ready" or "error".
currentEntryIdstring | undefinedThe ID of the current history entry.
selectedRefstring | undefinedThe selected reference, when there is one.
rootLoadingbooleanWhether the starting text is still loading.
readerErrorstring | undefinedThe error message, when the latest action failed.
canGoBackbooleanWhether Back can return to an earlier entry.
historyTruncatedbooleanWhether older history entries were dropped to stay within the history limit.
It has no data property. To give it local data, set source to { kind: "custom", loader }, where the custom loader's getText and getLinks functions answer from your data. See Give components your own data.
A Reader that has never had sref is blank. Its status is empty. A missing pane shows Source text is not available for this entry. or Connections are not available for this entry. The Reader reports a passage with no text as a source failure, not as an empty Source Card. A valid links response with no text connections shows the Connections Panel's empty message.
sefaria-reader-backRequests navigation to the previous entry. Call preventDefault() to stop the Reader from going back.
sefaria-reader-history-activateAsks to return to one saved history entry. Call preventDefault() to stop the Reader from returning to that entry.
sefaria-reader-pane-changeAsks to show a different pane in the compact layout. Call preventDefault() to stop the Reader from switching pane.
sefaria-reader-chat-exportAsks your page to send a reference to chat. Call preventDefault() to do nothing. The Reader has no default action. Your page handles the export.
sefaria-reader-source-selectReports that a reader selected one item in the source card. Call preventDefault() to stop the Reader from selecting that segment.
sefaria-reader-connections-category-changeAsks to show a different connection category. Call preventDefault() to stop the Reader from switching category.
sefaria-reader-connections-page-changeAsks to show a different connection page. Call preventDefault() to stop the Reader from changing page.
sefaria-reader-connection-selectReports that a reader selected one connected reference. Call preventDefault() to stop the Reader from opening the connected text.
sefaria-reader-connections-preview-requestRequests connection previews. The element loads them unless a listener cancels the event. Call preventDefault() to stop the Reader from loading previews.
sefaria-reader-errorReports a failure while loading the starting text or a text you navigate to, or when loading is disabled.
| Slot | Description |
|---|---|
toolbar-actions | Host-owned actions placed after the Reader's built-in toolbar controls. |
Style these from your page with ::part(name).
| Part | Description |
|---|---|
toolbar | Container for compact pane and host action controls. |
history | Back and retained-history controls. |
source-pane | Scrollable source-text pane. |
connections-pane | Scrollable connections pane. |
Each element dispatches CustomEvents that bubble and cross shadow roots. Listen for them with addEventListener on the element or an ancestor. For a cancelable event, call preventDefault() in your listener to stop the element's own action. The element acts after your listener returns.
Invalid supplied data puts Text Segment, Bilingual Segment and Source Card into their error state. They dispatch no error event for it. Their error events report only failures while loading sref. The Reader has no data property. It dispatches sefaria-reader-error when loading fails or loading is disabled.
Make components respond to each other shows how to use them.
The elements share these CSS custom properties. Not every element uses every one. Set them on the element or on any ancestor. Match your site's look shows how.
--sefaria-surfacetransparentsefaria-bilingual-segment, sefaria-connections-panel, sefaria-reader, sefaria-source-card, sefaria-text-segmentPrimary surface color. Text Segment is transparent unless this is set.
--sefaria-surface-mutedlight-dark(#f5f1e8, #222521)sefaria-reader, sefaria-source-cardMuted surface color.
--sefaria-fglight-dark(#25231f, #f1eee7)sefaria-bilingual-segment, sefaria-connections-panel, sefaria-reader, sefaria-source-card, sefaria-text-segmentPrimary foreground color.
--sefaria-fg-mutedlight-dark(#6d675d, #bdb7ac)sefaria-bilingual-segment, sefaria-connections-panel, sefaria-reader, sefaria-source-card, sefaria-text-segmentMuted foreground color.
--sefaria-borderlight-dark(#d7cfc1, #555b53)sefaria-connections-panel, sefaria-reader, sefaria-source-cardStandard border color.
--sefaria-border-stronglight-dark(#aaa094, #73796f)Reserved. No component uses it yet. Strong border color.
--sefaria-accentlight-dark(#8e2449, #ff93b4)sefaria-reader, sefaria-source-cardAccent and focus color.
--sefaria-accent-softlight-dark(rgb(142 36 73 / 10%), rgb(255 147 180 / 14%))Reserved. No component uses it yet. Translucent accent surface.
--sefaria-dangerlight-dark(#9c1c1c, #ffaaa4)Reserved. No component uses it yet. Error foreground color.
--sefaria-linklight-dark(#8e2449, #ff93b4)sefaria-reader, sefaria-source-cardLink foreground color.
--sefaria-shadow0 1rem 3rem rgb(0 0 0 / 28%)Reserved. No component uses it yet. Elevated-surface shadow.
--sefaria-panel-radius0.75remsefaria-connections-panel, sefaria-reader, sefaria-source-cardPanel corner radius.
--sefaria-control-radius0.3remsefaria-connections-panel, sefaria-source-cardControl corner radius.
--sefaria-font-scale1sefaria-bilingual-segment, sefaria-connections-panel, sefaria-reader, sefaria-source-card, sefaria-text-segmentComponent font-size multiplier.
--sefaria-font-hebrew"Noto Serif Hebrew", "SBL Hebrew", "Times New Roman", serifsefaria-connections-panel, sefaria-source-card, sefaria-text-segmentHebrew body font stack.
--sefaria-font-englishGeorgia, "Times New Roman", serifsefaria-bilingual-segment, sefaria-connections-panel, sefaria-reader, sefaria-source-card, sefaria-text-segmentEnglish body font stack.
--sefaria-font-label-hebrew"Noto Sans Hebrew", system-ui, sans-serifReserved. No component uses it yet. Hebrew label font stack.
--sefaria-font-label-englishsystem-ui, sans-serifsefaria-readerEnglish label font stack.