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

              
                <div class="container">
  <h1 class="slds-text-heading_large pb">
    Testing buttons with changing text
  </h1>
  <p>
     Finding which way of changing a button's text works best with Dragon Naturally Speaking.
  </p>
  <h2 class="slds-text-heading_medium pv">With aria-label</h2>
  <div class="slds-dropdown-trigger slds-dropdown-trigger_click">
    <button class="slds-button slds-button_neutral" aria-label="Search Salesforce:">
       <i class="fas fa-search"></i>
      <span>
        Search Salesforce
      </span>
    </button>
    <div
      aria-hidden="true"
      aria-label="Search Salesforce"
      class="slds-dropdown slds-dropdown_left"
      role="dialog"
    >
      <div class="slds-form-element pa">
        <label class="slds-form-element__label" for="text-input-id-1">
          Search
        </label>
         <div class="slds-form-element__control">
            <input
              type="text"
              id="input"
              placeholder="Search..."
              class="slds-input" />
        </div>
      </div>
    </div>
  </div>

  <h2 class="slds-text-heading_medium pv">With assistive text</h2>
  <div class="slds-dropdown-trigger slds-dropdown-trigger_click">
    <button class="slds-button slds-button_neutral">
      <i class="fas fa-search"></i>
      <span class="slds-assistive-text">
        Search Salesforce:
      </span>
      <span aria-hidden="true">
        Search Salesforce
      </span>
    </button>
    <div
      aria-hidden="true"
      aria-label="Search Salesforce Dialog 2"
      class="slds-dropdown slds-dropdown_left"
      role="dialog"
    >
      <div class="slds-form-element pa">
        <label class="slds-form-element__label" for="text-input-id-2">
          Search
        </label>
         <div class="slds-form-element__control">
            <input
              type="text"
              id="text-input-id-2"
              placeholder="Search..."
              class="slds-input" />
        </div>
      </div>
    </div>
  </div>
  <h2 class="slds-text-heading_medium pv bold">Results</h2>
  <p class="pb">
    Tested Dragon with Chrome and Firefox on Windows and both worked! Edge is not supported by Dragon.
  </p>
  <p>
    Will go forward with the aria-label solution because it is easier to maintain.
  </p>
</div>
              
            
!

CSS

              
                .container {
  background-color: white;
  width: fit-content;
  margin: auto;
  padding: 2rem;
}

.pa { padding: 0.5rem; }
.pb { padding-bottom: 1rem; }

.pv {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.bold { font-weight: bold; }

              
            
!

JS

              
                $(document).ready(() => {
  $('button').on('click', function(event) {
    const button = $(event.currentTarget);
    const wrapper = button.parents('.slds-dropdown-trigger');
    const dialog = wrapper.children('div[role="dialog"]');
    const input = dialog.find('input');

    if (wrapper.hasClass('slds-is-open')) {
      wrapper.removeClass('slds-is-open');
      dialog.attr('aria-hidden', true);
      if (input.val() !== '') {
        if (button[0].hasAttribute('aria-label')) {
          button.attr('aria-label', `Search Salesforce: ${input.val()}`);
          button.find('span').text(`${input.val()}`);
        } else {
          button.find('span.slds-assistive-text').text(`Search Salesforce: ${input.val()}`);
          button.find('span[aria-hidden="true"]').text(input.val());
        }
      }
    } else {
      wrapper.addClass('slds-is-open');
      dialog.attr('aria-hidden', false);
      input.focus();
    }
  });
  
  $('input').on('keypress', function(event) {
    const input = $(event.currentTarget);
    const wrapper = input.parents('.slds-dropdown-trigger');
    const dialog = wrapper.children('div[role="dialog"]');
    const button = wrapper.find('button');
    
    if (event.key === 'Enter') {
      wrapper.removeClass('slds-is-open');
      dialog.attr('aria-hidden', true);
      button.focus();
      
      if (input.val() !== '') {
        if (button[0].hasAttribute('aria-label')) {
          button.attr('aria-label', `Search Salesforce: ${input.val()}`);
          button.find('span').text(`${input.val()}`);
        } else {
          button.find('span.slds-assistive-text').text(`Search Salesforce: ${input.val()}`);
          button.find('span[aria-hidden="true"]').text(input.val());
        }
      } 
    }
  });
  
  // had to move the escape key to keydown because apparently the touchbar
  // doesn't generate a keypress event -____-
  $('input').on('keydown', function(event) {
    const input = $(event.currentTarget);
    const wrapper = input.parents('.slds-dropdown-trigger');
    const dialog = wrapper.children('div[role="dialog"]');
    const button = wrapper.find('button');
    
    if (event.key === 'Escape') {
      wrapper.removeClass('slds-is-open');
      dialog.attr('aria-hidden', true);
      button.focus();
    }
  });
});

              
            
!
999px

Console