You’re close. If you want to use sp-button
here, use a quiet
variant="secondary"
version. This avoids the extra border color.
Or if you want full control: use <div>
with an appropriate aria-role="button"
and maybe tabindex="0"
if you want TAB to work.
Note that you can use most SVG icons but the Ps tools themselves are not available for use – you’ll have to use your own icons (or use Spectrum’s).
Here’s an example of what I came up with (Note that the box-shadow
feature is not supported in UXP; I simulate it with some :before
and :after
pseudo elements). (Code after image)
<style>
.darkGray {
min-width: 0;
position: relative;
background:linear-gradient(to bottom, #999999 7.5%, #2c2c2c 100%);
border-radius: 4px;
display:inline-block;
padding: 0 1em;
color:#e6e6e6;
font-family:Arial, Helvetica;
font-size:11px;
font-weight: normal;
text-align: center;
height:20px;
line-height: 20px;
vertical-align: middle;
}
.darkGray:before {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
border: 1px solid black;
border-radius: 4px;
}
.darkGray:after {
position: absolute;
top: 1px; left: 1px; right: 1px; bottom: 1px;
border: 1px solid #7d7d7d30;
border-radius: 3px;
}
.darkGray:hover {
color: white;
}
.darkGray:active { /* click effect */
outline: 1px solid rgba(0,0,0,0); /* bug: force full update on click */
background:linear-gradient(to top, #999999 7.5%, #2c2c2c 100%);
}
.darkGray:focus { /* if you want a focus ring */
outline: 3px solid rgba(64,172,255,0.75);
outline-radius: 7px;
}
.darkGray svg { /* position the icon */
fill: currentColor;
width: 14px; height: 14px;
display: inline-block;
vertical-align: middle;
position: relative;
top: -1px;
margin-right: 1em;
}
</style>
<div style="margin: 1em">
<sp-detail>USING DIVS</sp-detail>
<sp-divider style="margin: 1em 0"></sp-divider>
<div aria-role="button" class="darkGray">Click</div>
<div aria-role="button" variant="secondary" quiet class="darkGray">
<svg xmlns="http://www.w3.org/2000/svg" height="14" viewBox="0 0 18 18" width="14" >
<path class="a" d="M10.75,7H9V5.25A.25.25,0,0,0,8.75,5H7.25A.25.25,0,0,0,7,5.25V7H5.25A.25.25,0,0,0,5,7.25v1.5A.25.25,0,0,0,5.25,9H7v1.75a.25.25,0,0,0,.25.25h1.5A.25.25,0,0,0,9,10.75V9h1.75A.25.25,0,0,0,11,8.75V7.25A.25.25,0,0,0,10.75,7Z" />
<path class="a" d="M17.587,16.1075,13.628,12.15a7.0155,7.0155,0,1,0-1.478,1.4785l3.958,3.958a1.05,1.05,0,0,0,1.479-1.479ZM3,8a5,5,0,1,1,5,5A5,5,0,0,1,3,8Z" />
</svg>Zoom
</div>
<div aria-role=button" class="darkGray" tabindex="0">With Focus Ring</div>
</div>
<div style="margin: 2em 1em">
<sp-detail>USING QUIET SECONDARY SP-BUTTONS</sp-detail>
<sp-divider style="margin: 1em 0"></sp-divider>
<sp-button variant="secondary" quiet class="darkGray">Click</sp-button>
<sp-button variant="secondary" quiet class="darkGray">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18">
<path class="a" d="M10.75,7H9V5.25A.25.25,0,0,0,8.75,5H7.25A.25.25,0,0,0,7,5.25V7H5.25A.25.25,0,0,0,5,7.25v1.5A.25.25,0,0,0,5.25,9H7v1.75a.25.25,0,0,0,.25.25h1.5A.25.25,0,0,0,9,10.75V9h1.75A.25.25,0,0,0,11,8.75V7.25A.25.25,0,0,0,10.75,7Z" />
<path class="a" d="M17.587,16.1075,13.628,12.15a7.0155,7.0155,0,1,0-1.478,1.4785l3.958,3.958a1.05,1.05,0,0,0,1.479-1.479ZM3,8a5,5,0,1,1,5,5A5,5,0,0,1,3,8Z" />
</svg>Zoom
</sp-button>
<sp-button variant="secondary" quiet class="darkGray"> <!-- icon from icomoon.io -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<path d="M31.008 27.231l-7.58-6.447c-0.784-0.705-1.622-1.029-2.299-0.998 1.789-2.096 2.87-4.815 2.87-7.787 0-6.627-5.373-12-12-12s-12 5.373-12 12 5.373 12 12 12c2.972 0 5.691-1.081 7.787-2.87-0.031 0.677 0.293 1.515 0.998 2.299l6.447 7.58c1.104 1.226 2.907 1.33 4.007 0.23s0.997-2.903-0.23-4.007zM12 20c-4.418 0-8-3.582-8-8s3.582-8 8-8 8 3.582 8 8-3.582 8-8 8zM14 6h-4v4h-4v4h4v4h4v-4h4v-4h-4z"></path>
</svg>110%
</sp-button>
<sp-body size="XS" style="margin-top: 1em">Note: all have focus rings; delete :focus to remove.</sp-body>
</div>