Primary buttons are the most prominent type of button available. They are used for a single, necessary action a developer must complete, or for a highly recommended, promoted action. Use them sparingly and with purpose.
Use tonal buttons in dialogs for actions that stand secondary to a primary action and are not a cancel or close action.
Outlined buttons are the default button style. Use them for regular actions in the UI or to cancel dialogs.
Text buttons are the least prominent button choice. Use them in cases outlined buttons would create too much visual noise.
Micro buttons are used if we have a small line height.
Use icon buttons in toolbars of contextual actions that shouldn’t take up much space.
devtools-button
for Primary, Outlined, Text, Micro and Icon buttonsToolbarButton
for buttons inside Toolbars
. Underneath they make use of devtools-button
.<button>
, as they are not styled correctlyUsage with lit-html:
html`<devtools-button class="some-class" .variant=${Buttons.Button.Variant.PRIMARY} .title=${i18nString(UIStrings.someString)} .jslogContext=${'some-context')} @click=${onClick})></devtools-button>`
Usage with the imperative API:
const button = new Buttons.Button.Button(); button.data = { variant: Buttons.Button.Variant.PRIMARY, title: i18nString(UIStrings.someString), jslogContext: 'some-context', }; button.classList.add('some-class'); button.addEventListener('click', event => onClick(event));
<select>
with <option>
and <optgroup>
if necessary, together with core styles.width
with CSS if necessary.Usage with lit-html:
html`<select aria-label="Choose your champion" @onchange=${onChange}> <option hidden value="Choose your champion"></option> <option jslog=${VisualLogging.item('hamster').track({click: true})} value="Hamster">Hamster</option> <option jslog=${VisualLogging.item('mouse').track({click: true})} value="Mouse">Mouse</option> <option jslog=${VisualLogging.item('cat').track({click: true})} value="Cat">Cat</option> </select>`
Usage with the imperative API:
const select = UI.UIUtils.createSelect('Choose your champion', [ 'Hamster', 'Mouse', 'Cat', ]); select.addEventListener('change', event => onChange(event))
<input type="radio">
nested within a <label>
for radio buttons, together with core styles.Usage with lit-html:
const jslog = VisualLogging.toggle().track({change: true}).context(jslogContext); html`<label><input type="radio" name=${name} jslog=${jslog}>${title}</label>`
Usage with the imperative API:
const {label, radio} = UI.UIUtils.createRadioButton(name, title, jslogContext); radio.addEventListener('change', event => onChange(event))
<input type="range">
for sliders, together with core styles.Usage with lit-html:
html`<input type="range" min=${min} max=${max} tabindex=${tabIndex} @change=${onChange}>`
Usage with the imperative API:
const slider = UI.UIUtils.createSlider(min, max, tabIndex); slider.addEventListener('change', event => onChange(event))
Find an exhaustive collection of icons currently used in DevTools here
js icon.style.color = ‘some-color’
Usage with lit-html:
html`<devtools-icon name=${'some-icon-name'}></devtools-icon>`
Usage with the imperative API:
const someIcon = IconButton.Icon.create('some-icon-name', 'some-class');