Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="root"></div>




                const root = document.getElementById('root')
const bus = new Bulb.Bus()

// A signal that searches for books by ISBN and emits the result as a new state.
const searchSignal = bus
  // Don't bother searching for empty queries.
  .filter(a => a !== '')

  // Search for the book using the API.

  // Create a new state.
  .map(result => ({ result, loading: false }))

// A signal that emits a loading state while the request is processing.
const loadingSignal = bus.always({ result: null, loading: true })

// Start with the default state and re-render the view when the other signals emit values.
Bulb.Signal.of({ result: null, loading: false })
  .merge(searchSignal, loadingSignal)
    state => ReactDOM.render(<RootView bus={bus} loading={state.loading} result={state.result} />, root)

// Returns a signal that emits the result of the search request to the API.
function findBook (isbn) {
  const url = `${isbn}`
  return Bulb.Signal
    .fromPromise(fetch(url).then(response => response.json()))
      data => data.totalItems > 0 ? data.items[0].volumeInfo.title : null

function RootView ({ bus, loading, result }) {
  const [query, setQuery] = React.useState('')

  return (
    <div className='jumbotron jumbotron-fluid'>
      <div className='container'>
        <h1>Book Search 📚</h1>
        <p className='lead'>This example demonstrates using a signal to handle an AJAX request.</p>
        <p>Enter an ISBN to find on Google Books (e.g. 0747532699).</p>
        <div class='input-group mb-3'>
          <input className='form-control' onChange={event => setQuery(} placeholder='ISBN' type='text' />
          <div className='input-group-append'>
            <Button disabled={loading} onClick={() =>}>
              {loading ? <Spinner /> : null}
        {result ? <pre>{result}</pre> : null}

function Button ({ children, disabled, onClick }) {
  return (
    <button className='btn btn-primary' disabled={disabled} onClick={onClick}>{children}</button>

function Spinner () {
  return (
      <span className='spinner-grow spinner-grow-sm' role='status' aria-hidden='true'></span>