How three games style themselves, and how to do something similar in SugarCube
This companion guide sits alongside the SugarCube tutorial file (Week 5 SugarCube Tutorial.twee). For each game in the week's reading list, it identifies a specific visual technique, shows the CSS that produces it, and explains how to adapt it in your own Twine game. The "demo panels" below are live CSS -- the code shown is exactly what creates the effect you see. Try adapting the code in your own StoryStylesheet and see what changes.
Howling Dogs uses almost no custom CSS. The game opens with an epigraph about a patient whose sobbing started the dogs howling, and then puts you in a small room with a food tray and a rusted door. The visual technique is not addition but removal: no sidebar, no background decoration, no competing interface elements. The game trusts the text entirely.
The technique: extreme reduction. Strip away everything that isn't the words. Give text room against a dark field. Let the prose carry all the weight. This is harder to do well than it looks -- it means the writing has nowhere to hide.
□Screenshot slot -- play the game and screenshot the opening passage (Cmd+Shift+4 on Mac, Win+Shift+S on Windows). Save it as screenshots/howling-dogs.png next to this HTML file.
/* Stark minimalism, after Howling Dogs */
body {
background-color: #000000;
color: #ffffff;
font-family: Verdana, sans-serif;
font-size: 16px;
line-height: 1.9;
}
#story {
max-width: 580px;
margin: 0 auto !important;
}
#passages {
border: none;
padding: 3em 2em;
margin-left: 0 !important;
}
/* Remove all sidebar chrome */
#ui-bar {
display: none;
}
/* Links sit quietly against the black */
a.link-internal {
color: #4d6ad8;
text-decoration: none;
}
a.link-internal:hover {
color: #8ea6ff;
}
Hiding the sidebar with display: none removes the history (back/forward) and restart buttons. This is a deliberate choice on Porpentine's part: Howling Dogs does not want you to go back. If you want to keep the restart button, hide only the history arrows with #ui-bar-history { display: none; }.
What to try
Write a passage with three sentences and one link. Apply this stylesheet. Run it and sit with it for a moment. Notice how differently text behaves when it has nothing competing with it. Then add a second color to one element and observe what that does to the feeling of the page.
Adding images and handing in your project
Section 8 of the SugarCube tutorial shows HTML and SugarCube image syntax, alternative text, and how to package an exported game with its images. For most image-based projects, use an images folder beside index.html and zip them together. It also explains embedded images when you need one HTML file.
With Those We Love Alive -- Porpentine (2014), music by Brenda Neotenomie
xrafstar.monster/games/twine/wtwla
The game opens with an instruction: "Before living this life, have a pen or sharpie nearby, something that can write on skin. Purple links change. Pink links move forward." Before the reader plays a single passage, Porpentine has taught them a new visual grammar. The link colours are not decoration: they tell you what a link will do before you click it.
The game also asks you to draw sigils on your actual skin at specific moments. The visual design extends beyond the screen into the reader's body.
□Screenshot slot -- a passage from the Empress's procession showing a purple (changing) link and a pink (forward) link. Save it as screenshots/wtwla.png next to this HTML file.
With Those We Love Alive, a passage from the Empress's procession: purple changes, pink moves forward. xrafstar.monster/games/twine/wtwla
Technique 1: The Gradient Background
Most of the game sits on a fixed linear gradient from bright cyan at the top to deep plum at the bottom. "Fixed" means the gradient stays still while the passage text scrolls over it, which creates a subtle sense of vertical depth -- you are moving through layers.
The palette also changes with where you are. Porpentine tags each passage (the main city, the Empress's scenes, dreams, and so on) and each tag has its own stylesheet, so the Empress's passages run from magenta to plum, as in the screenshot above. SugarCube can do the same thing with passage tags: it adds the current passage's tags to the page as data-tags, which your stylesheet can target.
Live demo -- the WTWLA main gradient (colours from the game's base stylesheet)
You are in the palace. The smell of salt and processed meat drifts from the lower levels.
/* Gradient background, after With Those We Love Alive
(gradient colours from the game's base stylesheet) */
body {
background: linear-gradient(
to bottom,
rgba(18, 184, 206, 1) 0%, /* bright cyan */
rgba(41, 0, 43, 1) 100% /* deep plum */
);
background-attachment: fixed; /* stays still while text scrolls */
color: #ffffff;
font-family: 'Open Sans', Verdana, sans-serif;
font-size: 20px;
line-height: 1.9;
margin: 0;
}
/* Open Sans: paste this into your PassageHeader passage (not the stylesheet):
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap">
*/
#story {
margin: 0 auto !important; /* reclaim the hidden sidebar's space */
max-width: 660px;
}
#passages {
margin: 100px 0 0 100px !important;
border: none;
}
.passage {
max-width: 620px;
}
/* A different palette for passages tagged "empress"
(the colours of the game's Empress stylesheet) */
body[data-tags~="empress"] {
background: linear-gradient(
to bottom,
rgba(201, 22, 114, 1) 0%, /* magenta */
rgba(41, 1, 43, 1) 100% /* plum */
);
background-attachment: fixed;
}
/* Subtle text shadow adds depth against the dark background */
.passage {
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.6);
}
/* Hide sidebar */
#ui-bar {
display: none;
}
Technique 2: Color-Coded Links
Porpentine's stylesheet defines three link colours. Two of them appear in play: pink for links that move you forward, and purple for links that change when clicked. The stylesheet also sets a green, but for a class the game never applies, so its reveal links (where a phrase expands into more text) show in pink. A third colour for reveals is still a useful idea, and the demo below uses the green for exactly that.
#ea6ab9-- pink -- moves forward
#6aea9b-- green -- in the stylesheet, unused in play; reveals text here
#cf97f0-- purple -- changes/cycles
Live demo -- three link colours, values from WTWLA's stylesheet
/* Three-color link system, after With Those We Love Alive */
/* Pink: navigation links (the default link color) */
a.link-internal {
color: #ea6ab9;
font-size: 1.2em;
text-decoration: none;
}
a.link-internal:hover {
color: #f095cd;
}
/* Green: for links that reveal content.
Wrap the <> macro in a span with class="reveal-link" */
.reveal-link a {
color: #6aea9b;
}
/* Purple: for changing/cycling elements.
Wrap a <> link in a span with class="cycle-link" */
.cycle-link a {
color: #cf97f0;
}
Passage text -- how to apply the classes
Navigation link (pink, the default):
[[Leave the workshop]]
Reveal link (green) -- wrap the linkappend macro in a span:
<span class="reveal-link"><<linkappend "Something catches your eye.">>
There is a knife on the workbench.
<</linkappend>></span>
Cycling link (purple) -- a native cycling link:
<span class="cycle-link"><<cycle "$mood" autoselect>>
<<option "curious">><<option "wary">><<option "certain">>
<</cycle>></span>
The green reveal links use <<linkappend>>, which keeps the trigger text visible and appends the revealed text after it. Older SugarCube tutorials may use <<click>>. It was deprecated in earlier SugarCube 2 versions and removed in 2.37. Use <<linkappend>> for this reveal.
WTWLA was made with Twine 1, whose games often used a <<cyclinglink>> macro to cycle through options on click. SugarCube 2 does not include <<cyclinglink>>, but it has a native <<cycle>> macro (added in SugarCube 2.29.0) that does the same job: it steps a variable through a list of <<option>> values each time the link is clicked. The SugarCube tutorial's WTWLA section shows the <<cycle>> syntax.
Where Porpentine's games reach for atmospheric darkness, Squinkifer reaches for excess and color. Quing's Quest riffs on the King's Quest series -- old-school text adventure conventions, room names and inventory -- refracted through a queer political lens. You are a monarch of "mysterious and indistinct gender" exiled from their home planet on a ship called the Social Justice Warrior. The over-the-top quality is part of the argument: games can be silly, lavish, and politically sharp at the same time.
The technique: font and color as political attitude. The game body text renders in hot pink against a scrolling starfield GIF. Links are lime green; hover turns them yellow with a glow. The font is Comic Neue Angular (a bold, oblique, small-caps variant of Comic Neue -- itself a response to Comic Sans) with font-variant: small-caps. Nothing about this is accidental. The visual lavishness is part of the argument.
□Screenshot slot -- at the ELC page click Begin, then BEGIN in the dialog; the game opens in a new tab. Screenshot the first passage (starfield, hot pink text, lime green links). Save it as screenshots/quings-quest.png next to this HTML file.
Quing's Quest VII, the captain's quarters, just after the title screen. collection.eliterature.org/3/work.html?work=quings-quest-vii
Demo: The Quing's Quest Aesthetic
The demo below uses the exact colors and font styling extracted from the game's CSS. The one thing it cannot replicate is the background: Quing's Quest uses an animated starfield GIF (stars-bb.gif), approximated here with CSS. The color palette and font treatment are accurate.
Live demo -- extracted from Quing's Quest VII CSS
You are in your Captain's Quarters. To the north is your closet. To the west is your en-suite bathroom. A door to the south leads out to the promenade.
StoryStylesheet -- Quing's Quest aesthetic
/* After Quing's Quest VII by Dietrich Squinkifer
Exact colors extracted from game source.
Background note: the real game uses an animated GIF (stars-bb.gif).
To use a background image in Twine, put the image file in the same
folder as your HTML export, then reference it as url('filename.gif').
Or use a CSS background-color instead. */
/* Comic Neue is on Google Fonts. Add to your PassageHeader:
<link href="https://fonts.googleapis.com/css2?family=Comic+Neue:ital,wght@1,700&display=swap" rel="stylesheet">
*/
body {
background-color: #000;
color: #D10E78; /* hot pink -- this is the BODY TEXT color */
font-family: 'Comic Neue', 'Comic Sans MS', cursive;
font-weight: 700;
font-style: italic;
font-variant: small-caps; /* makes all text render as small capitals */
font-size: 1.2em;
line-height: 1.6;
margin: 4% 2%;
}
#story {
margin: 0 auto !important; /* reclaim the hidden sidebar's space */
max-width: 660px;
}
#passages {
border: none;
padding: 0;
margin: 0 auto;
width: 96%;
}
#ui-bar {
display: none;
}
/* Links are lime green */
a.link-internal {
color: #A1EE10;
text-decoration: none;
}
/* Hover turns yellow with a glow effect */
a.link-internal:hover {
color: #FFFD11;
text-decoration: none;
text-shadow: #FFFD11 0 0 0.09em;
}
Passage text example
You are in your Captain's Quarters. To the north is your [[closet]].
To the west is your [[en-suite bathroom]].
A door to the south leads out to the [[promenade]].
Font variant: small-caps renders lowercase letters as smaller versions of capitals. This is what gives Quing's Quest its distinctive all-caps-but-not-screaming look. The hot pink is body text color, not link color -- this is the opposite of most web conventions. Squinkifer uses color to signal "this is a game world" rather than "these are hyperlinks." The lime green then reads as navigation precisely because it contrasts with the pink prose.
Combining and Adapting
None of these techniques belong exclusively to the games they came from. You could use the WTWLA gradient with Howling Dogs-style starkness -- removing Porpentine's colored links but keeping the atmospheric background. You could use Squinkifer's room-name convention with Porpentine's colour-coded links. You could put Squinkifer's small-caps Comic Neue on a pure black background with minimal text.
The more important question is what each choice does. Ask, before you add or remove a CSS rule: what does this passage need to feel like? What should be hard? What should feel warm, or cold, or distant? What does the interface tell the reader about how to be in this game?
Porpentine hides the sidebar because she doesn't want you to go back. That is a design decision with a philosophical position inside it. Every CSS rule can carry that kind of weight if you let it.
The SugarCube tutorial file (Week 5 SugarCube Tutorial.twee) covers the syntax for how all of these effects work. This guide covers the reasoning. Use them together.
Mechanics Examples
Three games that make the mechanic visible -- and how to build something similar in SugarCube
The games in this section are not on the Week 5 reading list but they demonstrate specific SugarCube features in ways that are hard to explain without a working example. Each one is short and free to play. Section 6 of the SugarCube tutorial has annotated code examples to copy into your own story.
Queers in Love at the End of the World -- Anna Anthropy (2013)
w.itch.io/end-of-the-world -- plays in browser -- 10 seconds
The entire game runs for ten seconds. It opens with a circle counting down and a single passage: "In the end, like you always said, it's just the two of you together. You have ten seconds, but there's so much you want to do: kiss her, hold her, take her hand, tell her." When the timer expires, you are taken to an end passage regardless of what you chose. The whole game is the feeling of not having enough time.
The technique: forced navigation via timed macro. This SugarCube adaptation uses <<timed>> and <<goto>> for a single-passage timeout. Leaving the passage cancels it. It does not reproduce the original game's persistent ten-second limit across multiple choices or its countdown ring.
□Screenshot slot -- open the game, click Begin, and screenshot within the first few seconds (countdown ring, passage text, blue links). Save it as screenshots/queers-in-love.png next to this HTML file.
Queers in Love at the End of the World, the opening seconds. w.itch.io/end-of-the-world
Demo: The Queers in Love Aesthetic
Minimal CSS. The aesthetic is almost nothing: black, grey text, a blue link. The countdown ring is not CSS -- it is an SVG rendered by JavaScript. The demo below approximates it statically.
Live demo -- extracted from Queers in Love CSS
7
In the end, like you always said, it's just the two of you together. You have ten seconds, but there's so much you want to do: kiss her, hold her, take her hand, tell her.
StoryStylesheet -- Queers in Love aesthetic
/* After Queers in Love at the End of the World (Anna Anthropy, 2013)
The game's CSS is nearly bare: black background, grey text, blue links.
The original countdown is not recreated by this stylesheet or the single-passage timeout below. */
body {
background: #000;
color: #fff;
font-family: Verdana, sans-serif;
font-size: 62.5%;
}
#story {
margin: 0 auto !important; /* reclaim the hidden sidebar's space */
max-width: 660px;
}
.passage {
color: #888; /* grey -- body text is desaturated */
font-size: 3em; /* 30px -- large, sparse, each word visible */
font-family: Arial, sans-serif;
line-height: 1.6;
padding: 1.5em;
}
a.link-internal {
color: #4d6ad8; /* blue */
text-decoration: none;
}
#ui-bar { display: none; }
Passage code -- a single-passage timeout
/% Create passages named The End and Another Passage, then try this %/
<<timed 10s>>
<<goto "The End">>
<</timed>>
In the end, like you always said, it's just the two of you together.
If you stay here, the story moves to The End after ten seconds.
[[Leave before the timeout|Another Passage]].
<<timed 10s>> runs the code inside after 10 seconds. <<goto "passage name">> navigates immediately. You can use any delay: 3s, 500ms, 120s. You can also use <<timed>> to reveal text within a passage: <<timed 2s>>new text appears here<</timed>>. Following a passage link cancels this timeout. A whole-game countdown needs a deadline that continues to be checked after navigation. This example does not create the visible countdown ring.
Depression Quest -- Zoe Quinn, Patrick Lindsey, Isaac Schankler (2013)
the-quinnspiracy.itch.io/depressionquest -- download, pay what you want
Depression Quest is a Twine game about living with depression. At the end of each passage you are given a list of choices, numbered 1 to 4 or 5. Some choices are crossed out in red with a strikethrough: you can see them, but you cannot take them. The level of your depression, tracked as a variable, determines which options are available. The unavailable choices are not hidden -- they are displayed with a line through them. The game makes you look at the things you cannot do.
The technique: visible unavailability via <del> and <<if>>. An <<if>> block checks a variable. If the condition isn't met, the option is wrapped in an HTML <del> tag rather than hidden. CSS gives del a red color. The reader sees the option but cannot click it.
□Screenshot slot -- open the game, click Begin then Next, and screenshot the second passage (crossed-out option in red, blue options, state boxes). Save it as screenshots/depression-quest.jpg next to this HTML file.
Depression Quest, an early passage with a crossed-out choice (from the archived browser version). the-quinnspiracy.itch.io/depressionquest
Demo: The Depression Quest Interface
The aesthetic is the opposite of Porpentine or Squinkifer -- light grey, textured, Verdana. The interface looks mundane on purpose. The crossed-out choice in red is the only visual shock.
Live demo -- extracted from Depression Quest CSS (available links #4d6ad8, unavailable del #D11D10); passage text abridged
You briefly consider using this serendipitous solitude to catch up on that project you've been working on haphazardly. The mere thought of trying to work sends your stress levels flying.
You are depressed. Interaction is exhausting, and you are becoming more and more withdrawn.
You are not currently seeing a therapist.
StoryStylesheet -- Depression Quest aesthetic
/* After Depression Quest (Zoe Quinn, 2013)
Key technique: unavailable choices shown with tag, colored red */
body {
background-color: #d8d8d8;
color: #222;
font-family: Verdana, sans-serif;
}
/* Unavailable option: visible but crossed out */
del {
color: #D11D10;
text-decoration: line-through;
display: block;
margin: 0.3em 0;
}
/* Available link */
a.link-internal {
color: #4d6ad8;
text-decoration: none;
display: block;
margin: 0.3em 0;
}
/* Depression state display box */
.state-display {
background: #c8c8c8;
padding: 0.5em 1em;
margin: 0.3em 0;
border-left: 2px solid #aaa;
}
Passage code -- visible unavailable option
/% Set a variable tracking state (lower = more depressed) %/
/% In StoryInit: <<set $depression to 2>> %/
Do you...
<<if $depression gte 4>>
[[Order some food and work through the night|Work]]
<<else>>
<del>Order some food and work through the night</del>
<</if>>
[[Reluctantly try to make yourself work|DesksWork]]
[[Turn on the TV|TV]]
<div class="state-display">Your depression level: <<print $depression>>/10</div>
The key design insight: showing the crossed-out option rather than hiding it creates a different emotional effect. The reader sees what is inaccessible. Hiding it would be a cleaner interface; showing it is the game. Think carefully about whether your <<if>> should hide or reveal.
Typewriter Effect -- SugarCube 2 built-in
no specific game -- SugarCube 2.32.0+ feature
SugarCube 2 includes a <<type>> macro that reveals text character by character at a set speed. It is not from any single source game -- it is a built-in feature of the story format. But it is worth covering here because it produces a quality you can feel in several of the Week 5 games even without a named macro: the sense that text is arriving, not already there. With Those We Love Alive achieves this through short passages and deliberate prose pacing. <<type>> makes it mechanical.
The technique: <<type speed>>text<</type>>. Speed is in milliseconds per character. 40ms is fast but visible. 120ms is slow and emphatic. You can type links, styled text, or multiple paragraphs. The reader waits; the waiting is part of the experience.
Demo: Typewriter Reveal
The demo below uses a CSS animation to approximate the effect. The real SugarCube <<type>> macro types character by character in the browser.
Live demo -- CSS approximation of <<type>> effect (animates on load)
You have been in this room for a very long time.The walls are the same colour as forgetting.
Passage code -- typewriter text reveal
/% Basic use: text types character by character at 40ms per character %/
<<type 40ms>>You have been in this room for a very long time.<</type>>
/% Slower, more deliberate -- good for emphasis %/
<<type 120ms>>The walls are the same colour as forgetting.<</type>>
/% You can type links too %/
<<type 60ms>>There is a [[door]].<</type>>
/% Keep typing with a delay before the next element %/
<<type 40ms start 1s>>A second line, after a pause.<</type>>
<<type>> only works in SugarCube 2.32.0 and above. The start option sets the pause before typing begins. You can chain multiple <<type>> blocks in one passage and they will play in sequence. Avoid typing very long passages -- if a reader needs to re-read, the wait becomes frustrating. Short, deliberate lines work best.
Advanced Techniques
Going further: persistent UI, sound, conditional styling, and reusable components
These techniques require more than a StoryStylesheet. They involve special passages, JavaScript, or SugarCube features beyond basic macros. Treat this section as a map of what is possible -- not everything you need to use for Assessment 2, but things worth knowing exist.
Persistent UI -- StoryCaption and PassageHeader/Footer
By default, SugarCube shows a sidebar (the UI bar) with a back button, saves, and story title. You can completely replace this with your own content by putting HTML and SugarCube code into a special passage called StoryCaption. Anything in StoryCaption appears in the sidebar on every passage without you having to repeat it.
Two other special passages, PassageHeader and PassageFooter, inject content at the top and bottom of every passage in the main content area. These are useful for things like: a persistent navigation bar, a "carrying" inventory display, or a Google Fonts import that needs to appear on every page.
Demo: Sidebar with persistent stats
Live demo -- approximation of a StoryCaption sidebar + passage content
Location
The Station
Carrying
notebook transit card
Day
Tuesday
The platform is empty. The train schedule board flickers.
/% Create a passage called exactly: StoryCaption %/
/% This content appears in the sidebar on every passage %/
<div class="sidebar-label">Location</div>
<div class="sidebar-stat"><<print $location>></div>
<div class="sidebar-label">Carrying</div>
<div class="sidebar-stat"><<print $inventory>></div>
PassageFooter passage -- persistent navigation
/% Create a passage called exactly: PassageFooter %/
/% This appears at the bottom of every passage %/
<hr>
[[Map|Map]]   [[Journal|Journal]]   [[Inventory|Inventory]]
StoryStylesheet -- sidebar styling
/* Hide the default SugarCube UI bar chrome, but keep #story-caption.
#story-caption lives inside #ui-bar-body, so hiding the whole body
hides your own sidebar content too. Hide only the parts you don't want: */
#title { display: none; } /* story title banner */
#menu { display: none; } /* saves, restart, settings */
#ui-bar-history { display: none; } /* back and forward arrows */
/* Style your StoryCaption content */
#story-caption .sidebar-label {
color: #505068;
font-size: 0.75em;
text-transform: uppercase;
letter-spacing: 0.1em;
margin: 1.2em 0 0.3em 0;
display: block;
}
#story-caption .sidebar-stat {
color: #9090b8;
font-size: 0.9em;
}
StoryCaption runs SugarCube code live, so <<print $variable>> updates as the story progresses. You can use <<if>> inside it too: show different sidebar content depending on what chapter you're in, or show a health bar only when health matters.
Sound -- <<cacheaudio>> and <<audio>>
SugarCube can play audio. You load a track once with <<cacheaudio>>, giving it a short id, then play, loop, and fade it from any passage with <<audio>>. No sound files ship with these materials, so treat the code below as syntax to adapt, not a live demo.
StoryInit -- cache the track once
/% StoryInit is the best place to cache tracks %/
<<cacheaudio "rain" "media/rain.mp3" "media/rain.ogg">>
Passage code -- play, loop, and fade
/% Start a quiet, looping ambient bed %/
<<audio "rain" loop volume 0.5 play>>
/% Stop it, or fade it out over five seconds %/
<<audio "rain" stop>>
<<audio "rain" fadeout>>
Give the track one or more source files (more than one format, since no single format plays in every browser). Browsers block audio from starting before the reader interacts with the page, so start ambient sound on a link or an early choice rather than on the opening passage. One low loop, used with restraint, does more for atmosphere than volume ever will.
Conditional Styling -- <<addclass>> and <<removeclass>>
You can change the visual state of a passage -- or the whole page -- by adding and removing CSS classes at runtime. Combined with a story stylesheet (Story > Stylesheet) that defines what each class does, this lets you create lighting changes, mood shifts, or game-state-driven visual effects without navigating to a new passage.
StoryStylesheet -- mood classes
/* Default passage style */
.passage { background: #09090f; color: #ccc8c4; }
/* Add class "danger" to body when tension rises */
body.danger .passage { background: #1a0000; color: #ffcccc; }
body.danger a.link-internal { color: #ff6666; }
/* Add class "memory" for flashback passages */
body.memory .passage {
filter: sepia(60%);
font-style: italic;
}
StoryInit - the starting state
<<set $inDanger to false>>
PassageHeader - apply the current state on every passage
<<set $inDanger to true>>
<<addclass "body" "danger">>
The alarm is sounding. The lights have gone red.
[[Run|Escape]]
Escape passage - end the danger state
<<set $inDanger to false>>
<<removeclass "body" "danger">>
You made it through the door. The alarm stops.
Put each block in the place named above it. SugarCube clears body classes when you navigate to another passage. The story variable keeps the danger state, and PassageHeader reapplies its class on each turn. The alarm and escape passages also update the class immediately, after changing the variable. <<toggleclass>> adds or removes a class in the current page; it does not store a story state.
Reusable Components -- <<widget>>
If you find yourself writing the same chunk of passage code in multiple places -- an inventory display, a character status line, a navigation footer -- SugarCube's <<widget>> system lets you define it once and call it by name. A widget is defined in a passage tagged widget, and called anywhere with <<widgetname>>.
Widget definition -- passage tagged "widget"
/% Create a passage, tag it "widget" (in the passage tags field) %/
/% Then define widgets inside it %/
<<widget "statusbar">>
<div class="status-bar">
Day: <<print $day>>  
Location: <<print $location>>  
<<if $hasKey>>[key]<</if>>
</div>
<</widget>>
Using the widget in any passage
<<statusbar>>
You are at the edge of the forest. The light is failing.
[[Go deeper|Forest2]] | [[Turn back|Town]]
Widgets can accept arguments (accessed inside as _args[0], _args[1] etc.), which makes them powerful templates. A widget called npc could take a name and disposition as arguments and render them consistently. See the SugarCube docs under "Macros > Widgets" for the full syntax.
The SugarCube tutorial file (Week 5 SugarCube Tutorial.twee) has annotated examples for these techniques. Section 6 covers mechanics and Section 7 covers advanced features. The playable demonstrations are in Sections 1 to 4; audio requires your own files.