Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <!-- 

Please enable your microphone.

Please close any other tabs/windows containing speech API projects, even if only showing the preview window. 

-->

<div class="notes-container">
    <h1>Take Notes with Your Voice</h1>
    <ul class="instructions">
        <li>Speak and your words will appear below!</li>
        <li>Click on any note to edit or delete it.</li>
        <li>Click the 'Save' button to save your notes.</li>
    </ul>
    <ol class="notes-list"></ol>
    <button class="btn-save">Save</button>
</div>
              
            
!

CSS

              
                * {
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: "Indie Flower", cursive;
    font-size: 25px;
    line-height: 1.5;
    color: #222;
    background-image: linear-gradient(#efd798, #ebcf82);
    text-align: center;
    padding: 20px;
}

h1 {
    font-size: 45px;
    font-weight: 600;
    margin: 20px 0;
}

.instructions {
    font-size: 22px;
    margin-bottom: 25px;
}

.instructions li {
    margin-bottom: 10px;
}

.notes-container {
    flex-basis: 1000px;
    padding: 20px;
    margin: 0 auto;
    border-radius: 10px;
    background-color: #fcfcfc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 
                0 1px 2px rgba(0, 0, 0, 0.24);
}

.notes-list {
    width: 90%;
    min-height: 57px;
    background-image: repeating-linear-gradient(
        #a7d3ff 0px,
        #a7d3ff 1px,
        transparent 2px,
        transparent 55px
    );
    margin: 0 auto;
    padding-bottom: 2px;
    text-align: left;
    counter-reset: listCounter;
}

.note {
    line-height: 2.2;
    animation: fadeInUp 400ms linear;
}

.note::before {
    color: #26383a;
    content: counter(listCounter) ". ";
    counter-increment: listCounter;
}

.note:focus {
    cursor: text;
}

.btn-save {
    font-family: inherit;
    font-size: inherit;
    color: #fff;
    background-color: #999;
    border: none;
    border-radius: 5px;
    margin-top: 20px;
    padding: 5px 25px;
    cursor: pointer;
    transition: background-color 300ms;
}

.unsaved {
    background-color: #40ad40;
    animation: pulse 1s infinite ease-in-out;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(100%);
    }
}

@keyframes pulse {
    50% {
        transform: scale(1.07);
    }
}

              
            
!

JS

              
                //DOM load event
window.addEventListener("DOMContentLoaded",	() => {
    
    //Set speech recognition fallback
    window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;

    const recognition = new SpeechRecognition(),
          notes = document.querySelector('.notes-list'),
          saveBtn = document.querySelector('.btn-save'),
          createNote = (transcript, newNote = true) => {
              //Create list item element
              const note = document.createElement('li');

              //Add attributes to note
              note.textContent = transcript;
              note.classList.add('note');
              note.setAttribute('contenteditable', '');

              //Add note to notes list
              notes.appendChild(note);

              //Check save button class
              if (newNote && !saveBtn.classList.contains('unsaved')) saveBtn.classList.add('unsaved');
          },
          saveNotes = () => {
              //Get notes
              const noteList = document.querySelectorAll('.note');

              if (noteList.length > 0) {
                  //Store notes in local storage
                  localStorage.setItem('notes', Array.from(noteList).map(note => note.textContent).join(', '));
              } else {
                  //Delete notes entry from local storage
                  if (localStorage.getItem('notes') !== null) localStorage.removeItem('notes');
              }

              //Check save button class
              if (saveBtn.classList.contains('unsaved')) saveBtn.classList.remove('unsaved');
          },
          loadNotes = () => {
              //Check if notes exist in local storage
              if (localStorage.getItem('notes') !== null) {
                  //Get notes from local storage
                  const noteList = localStorage.getItem('notes').split(', ');

                  //Display notes
                  noteList.forEach(note => createNote(note, false));
              }
          },
          checkNoteLength = e => {
              //Check if note should be deleted
              if (e.target.textContent.length === 0) e.target.remove();

              //Check save button class
              if (!saveBtn.classList.contains('unsaved')) saveBtn.classList.add('unsaved');
          }

    notes.addEventListener('keyup', e => checkNoteLength(e));

    saveBtn.addEventListener('click', () => saveNotes());

    recognition.addEventListener('result', e => createNote(e.results[0][0].transcript));

    recognition.addEventListener('end', recognition.start);

    recognition.start();

    loadNotes();
});

              
            
!
999px

Console