Stencil — guide & examples
Online Stencil playground with real TypeScript decorators, TSX components, scoped styles, events, and browser compilation.
About Stencil
Online Stencil playground with real TypeScript decorators, TSX components, scoped styles, events, and browser compilation.
Runtime: v3.2.2
Features
- Stencil 3.2
- TypeScript and TSX
- Component Decorators
- Reactive State and Props
- Shadow DOM Encapsulation
- Local File Imports
Browser playground limits
- • Code runs in a sandboxed browser preview, without Node.js, a backend, or private environment variables.
- • The Console prompt can inspect browser globals and the rendered DOM, but not variables scoped inside ES modules or component state.
- • Download the project when you need build plugins, server APIs, native modules, or a production dependency workflow.
How to use the Stencil playground
- Edit a source file from the project explorer — the live preview recompiles automatically.
- Add, rename, duplicate or delete project files as needed. Update affected imports after renaming or moving a file.
- Use the console for logs and errors, and Format to tidy the active file.
- Share the complete project or download a Stencil CLI project ZIP with its source files and configuration.
Editing
Select next occurrenceCtrl / ⌘+D
Delete lineCtrl / ⌘+Shift+K
Move line up / downAlt+↑ / ↓
Copy line up / downAlt+Shift+↑ / ↓
Navigation
Go to symbolCtrl / ⌘+Shift+O
Selection
Select all occurrencesCtrl / ⌘+Shift+L
Terminal
Interrupt / kill processCtrl+C
Send EOF (close stdin)Ctrl+D
Console shortcuts
Press Enter to evaluate, ↑ and ↓ to browse command history, and Ctrl/⌘ + L to clear the console.
import './components/counter-card/counter-card'
import './global.css'
document.addEventListener('countChanged', (event) => {
console.log('Stencil event:', (event as CustomEvent<number>).detail)
})
src/components/counter-card/counter-card.tsx import { Component, Event, EventEmitter, h, Prop, State } from '@stencil/core'
@Component({
tag: 'counter-card',
styleUrl: 'counter-card.css',
shadow: true,
})
export class CounterCard {
@Prop() start = 0
@State() count = 0
@Event() countChanged!: EventEmitter<number>
componentWillLoad() {
this.count = this.start
}
private increment = () => {
this.count += 1
this.countChanged.emit(this.count)
}
render() {
return (
<section class="card">
<div>
<span>Reactive state</span>
<strong>{this.count}</strong>
</div>
<button type="button" onClick={this.increment}>
Increment
</button>
</section>
)
}
}
Frequently asked questions
- Is the Stencil playground free?
- Yes. The Stencil playground is completely free with no sign-up — write, run and share Stencil code in your browser.
- Do I need to install anything to run Stencil online?
- No. The live preview compiles and runs in your browser. After downloading the project, install its dependencies before running it locally.
- Can I share or export my Stencil code?
- Yes. Share creates a link to your project. Download exports a Stencil CLI project ZIP with its source files and configuration.
- Does the editor support autocomplete and live preview?
- It does — a Monaco-powered editor with autocomplete and formatting, a live preview that updates as you type, and a console for logs and errors.
compilebytes.com/tools/stencil