Skip to content

Segmented Control Examples

The examples below assume that you have imported the component and set up the theme.

Basic

Build a single-choice switch from plain buttons. Each button has a value, and value on the control picks the selected one.

Layout
State
<div class="segmented-basic">
<label for="segmented-basic-plan">Plan</label>
<sv-segmented-control id="segmented-basic-plan" value="business">
<button value="personal">Personal</button>
<button value="business">Business</button>
<button value="enterprise">Enterprise</button>
</sv-segmented-control>
</div>
<style>
.segmented-basic {
display: grid;
gap: 0.5em;
inline-size: min(100%, 24rem);
margin-inline: auto;
label {
justify-self: center;
font-weight: 600;
}
sv-segmented-control[vertical] {
justify-self: center;
}
button {
font-weight: 600;
}
/* Smaller buttons keep the row on small screens */
@media (max-width: 430px) {
font-size: 0.8em;
button {
padding-inline: 0.4em;
}
}
}
</style>

Custom Content

Put icons or other markup inside the options. Each option is a plain button that holds an SVG and a text label, and your own CSS styles it with no parts.

<div class="segmented-custom-content">
<label for="segmented-custom-content-device">Device</label>
<sv-segmented-control id="segmented-custom-content-device" value="pc">
<button value="laptop">
<!-- Laptop -->
<svg aria-hidden="true" viewBox="0 0 24 24">
<path
d="M20 18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"
></path>
</svg>
Laptop
</button>
<button value="pc">
<!-- Desktop -->
<svg aria-hidden="true" viewBox="0 0 24 24">
<path
d="M21 3H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.1-.9-2-2-2m0 14H3V5h18z"
></path>
</svg>
PC
</button>
<button value="phone">
<!-- Phone -->
<svg aria-hidden="true" viewBox="0 0 24 24">
<path
d="M16 1H8C6.34 1 5 2.34 5 4v16c0 1.66 1.34 3 3 3h8c1.66 0 3-1.34 3-3V4c0-1.66-1.34-3-3-3m-2 20h-4v-1h4zm3.25-3H6.75V4h10.5z"
></path>
</svg>
Phone
</button>
</sv-segmented-control>
</div>
<style>
.segmented-custom-content {
display: grid;
gap: 0.5em;
inline-size: min(100%, 24rem);
margin-inline: auto;
label {
justify-self: center;
font-weight: 600;
}
button {
display: flex;
gap: 0.5em;
align-items: center;
justify-content: center;
font-weight: 600;
svg {
inline-size: 1.2em;
block-size: 1.2em;
fill: currentcolor;
}
}
/* Smaller buttons keep the row on small screens */
@media (max-width: 440px) {
font-size: 0.85em;
button {
gap: 0.35em;
padding-inline: 0.4em;
}
}
}
</style>