Credits Screen
The credits screen lists the people who made your game and the ones you want to thank, in sections with headings. You write the credits in js/script.js; the screen draws them, and the main menu gets a Credits button as soon as there’s something to show.

| Tag | <credits-screen> |
| Where it lives | In index.html, inside <visual-novel> (the starter game has it) |
| Built on | ScreenComponent |
| Screen name | credits |
| Source | src/components/credits-screen/ |
Write your credits
The starter game’s js/script.js has an empty credits block. Fill it with sections; each section has roles and the people in them:
// js/script.js
monogatari.configuration('credits', {
'Story': {
'Writing': 'Yui',
'Art': ['Mio', 'Yui'],
},
'Thanks': {
'Testers': ['Alex', 'Sam', 'Robin'],
'_note': 'And everyone who played the first draft.',
},
});That’s the screenshot above:
- Each section’s name becomes a heading.
- A role with one name shows the name; a role with a list shows the names separated by commas.
- A role whose name starts with
_shows its text alone, centered, without the role. Use it for a line of thanks or a note. - A section can also be a single line of text instead of roles:
'Music': 'All music by Mio'shows the heading Music with that line under it. - Names, roles, headings and lines can use variables like
{{player.name}}, and HTML:'Music': '<a href="https://example.com">Mio</a>'makes a link. A variable’s value shows as text, as in dialog: a name the player typed with tags in it shows the tags. Before 2.9.0, values were inserted as HTML.
When the credits aren’t empty, the engine adds Credits to the Main Menu as the game starts. With empty credits there’s no button, but the screen stays in the page.
Before 2.9.0, a section written as a single line lost its heading and its variables; a role starting with _ ('Music': { '_all': 'All music by Mio' }) gives the same result in every version.
Calling monogatari.configuration('credits', { … }) again adds to the credits: sections and roles with new names are added, and the ones with the same names are replaced.
Markup
<credits-screen data-screen="credits" class="animated active">
<button class="top left" data-action="back"><span class="fas fa-arrow-left"></span><span class="visually-hidden" data-string="Back">Back</span></button>
<h2 data-string="Credits" data-content="title">Credits</h2>
<div data-content="credits" data-ui="credits">
<h3>Story</h3>
<div>
<p><b>Writing</b><span>Yui</span></p>
<p><b>Art</b><span>Mio, Yui</span></p>
</div>
<h3>Thanks</h3>
<div>
<p><b>Testers</b><span>Alex, Sam, Robin</span></p>
<p><span>And everyone who played the first draft.</span></p>
</div>
</div>
</credits-screen>| Hook | What it is |
|---|---|
[data-content="title"] |
The screen’s title. |
[data-content="credits"] |
Every section. |
[data-content="credits"] h3 |
A section’s heading; the <div> after it holds its rows. |
[data-content="credits"] p |
One role. Its <b> is the role, its <span> the names. |
Properties and attributes
| Name | Type | Default | What it does |
|---|---|---|---|
credits |
object |
the credits configuration | The credits it draws, read when the page loads. |
open (state) |
boolean |
false |
Whether the screen is shown. |
Events
None of its own.
Style it
The credits are a centered column at most 40rem wide, each role on the left and its names on the right, and a line without a role centered. Before 2.9.0 the screen’s stylesheet wasn’t part of the engine’s, so each role ran into its names (“WritingYui”).
To center each role next to its names instead, with lighter roles, add this to your game’s style/main.css:
credits-screen [data-content="credits"] p {
display: flex;
justify-content: center;
gap: 1rem;
}
credits-screen [data-content="credits"] b {
font-weight: normal;
opacity: 0.7;
}
Replace or extend it
Everything comes from your credits configuration, so most games need no code. The Credits title is a translation string. A subclass or a template (see Components) can draw the credits differently from this.props.credits; keep the back button (data-action="back").
Related pages
- Main Menu: the Credits button.
- Configuration:
monogatari.configuration(). - Variables and storage: the variables you can use in the credits.