API
Toggle group
Toggles joined into one control, single or multiple selection.
Installation
pnpm dlx zazz-ui add toggle-groupnpx zazz-ui add toggle-groupyarn dlx zazz-ui add toggle-groupbunx zazz-ui add toggle-groupAlso adds fields, kbd, button, toggle, which it depends on. Run zazz-ui init first if the project has no zazz/ folder yet.
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Paint the right theme (background, form controls, scrollbars) before CSS loads -->
<meta name="color-scheme" content="light dark">
<!-- Zazz styles: base layers, then fields, kbd, button, toggle, toggle-group in cascade order -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_layers.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_variables.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_shadows.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_breakpoints.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_reset.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_typography.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_view-transitions.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/fields/fields.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/kbd/kbd.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/button/button.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/toggle/toggle.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/toggle-group/toggle-group.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-sm.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-md.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-lg.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-2xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-disabled.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-active.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-visible.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-within.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-hover.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-checked.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-current.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-open.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-stuck.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-starting.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-sm.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-md.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-lg.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-2xl.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-disabled.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-active.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-visible.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-within.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-hover.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-checked.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-current.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-open.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-stuck.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-starting.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-flow.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-grid.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-spacing.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-margin.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sizing.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-typography.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-color.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-effects.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-box.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-pseudo.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_defaults.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sr.css">
<!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
<script type="importmap">
{
"imports": {
"signal-polyfill": "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js"
},
"integrity": {
"https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js": "sha384-0OqM7OXGT6Oz1z98u/geiFn/FUyz4iWexkXHCvbIGXRRDXl6bp6IKc0j78AQ6DEK"
}
}
</script>
<!-- Polyfill: Interest Invokers (interestfor) — native in Chromium only -->
<script type="module" src="https://cdn.jsdelivr.net/npm/invokers@2.2.2/dist/esm/production/interest.js" integrity="sha384-hR2BVNtsS7fIIMwOm+f7MY0JZfuByGhQQfevCBB6evFATKzBsTw0JzH/RxD94z2T" crossorigin="anonymous"></script>
<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/dialog-lifecycle.js"></script>
<!-- Theme: apply the persisted (or preferred) scheme before first paint -->
<script>
(() => {
try {
// A stored choice pins the scheme with data-theme; with no choice the
// page follows the system scheme.
const storedTheme = localStorage.getItem("theme");
if (storedTheme === "dark" || storedTheme === "light") {
document.documentElement.dataset.theme = storedTheme;
}
} catch {
/* no storage access: follow the system scheme */
}
})();
</script>A <head> that loads the base layers and toggle-group with its dependencies from jsDelivr, pinned to 0.14.2. To load the whole kit in two requests, see the CDN install.
Examples
Default
<ui-toggle-group role="group" aria-label="Text alignment">
<label data-ui="toggle" data-toggle-size="icon">
<input type="radio" name="align" aria-label="Align left" checked />
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<line x1="4" y1="6" x2="20" y2="6" />
<line x1="4" y1="12" x2="14" y2="12" />
<line x1="4" y1="18" x2="18" y2="18" />
</svg>
</label>
<label data-ui="toggle" data-toggle-size="icon">
<input type="radio" name="align" aria-label="Align center" />
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<line x1="4" y1="6" x2="20" y2="6" />
<line x1="7" y1="12" x2="17" y2="12" />
<line x1="5" y1="18" x2="19" y2="18" />
</svg>
</label>
<label data-ui="toggle" data-toggle-size="icon">
<input type="radio" name="align" aria-label="Align right" />
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<line x1="4" y1="6" x2="20" y2="6" />
<line x1="10" y1="12" x2="20" y2="12" />
<line x1="6" y1="18" x2="20" y2="18" />
</svg>
</label>
</ui-toggle-group>/**
* toggle-group.css: Toggle group (ui-toggle-group | [data-ui~="toggle-group"])
*
* @layer variables, components
* @requires _layers.css, _variables.css, _properties.css (--_*-resolved), toggle.css
* @uses :not(): first/last edge selection for shared-border collapse
* @uses logical border-radius longhands: RTL-safe corner rounding per orientation
* @uses flex-item z-index: raise the active control so its border/ring isn't clipped
* @uses corner-shape — superellipse corners; unsupported browsers keep plain
* rounded corners
* @tokens --ui-toggle-group-* (@layer variables; named after the utilities they back)
*/
@layer variables {
:root {
--ui-toggle-group-radius: var(--ui-toggle-radius);
--ui-toggle-group-corner-shape: var(--ui-toggle-corner-shape);
--ui-toggle-group-bg: var(--color-card);
}
}
@property --_toggle-group-radius {
syntax: "*";
inherits: false;
}
@property --_toggle-group-bg {
syntax: "*";
inherits: false;
}
@layer ui.components {
/* ===========================================================================
TOGGLE GROUP
Joins adjacent toggles into a single segmented unit: a single-select set
(radios sharing a `name`) or a multi-select set (checkboxes). Children keep
their own --ui-toggle-radius, so the outer corners follow the toggles' size
preset automatically; only the *inner* corners are squared off and the
doubled border is collapsed by dropping
each later control's leading border (no overlap).
=========================================================================== */
:where(ui-toggle-group, [data-ui~="toggle-group"]) {
display: flex;
inline-size: fit-content;
/* stretch so mixed-height children share one edge */
align-items: stretch;
--_radius-len: var(
--_radius-resolved,
var(--_toggle-group-radius, var(--ui-toggle-group-radius))
);
--_radius-num: var(
--_radius-resolved,
var(--_toggle-group-radius, var(--ui-toggle-group-radius))
);
border-radius: calc(
var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
);
corner-shape: var(--_corner-shape-resolved, var(--ui-toggle-group-corner-shape));
background-color: var(--_bg-resolved, var(--_toggle-group-bg, var(--ui-toggle-group-bg)));
position: relative;
isolation: isolate;
}
/* flex items honour z-index without positioning, but relative keeps the
stacking context robust across child types */
:where(ui-toggle-group, [data-ui~="toggle-group"]) > * {
position: relative;
}
/* the focused/hovered/checked toggle floats above its neighbors so its
focus ring paints over its neighbors */
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:hover:not(:has(> input:disabled)),
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:focus-within,
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:has(> input:checked) {
z-index: 1;
}
/* ===========================================================================
TOGGLE GROUP: HORIZONTAL (default)
=========================================================================== */
:where(ui-toggle-group, [data-ui~="toggle-group"]):not(
[data-toggle-group-orientation="vertical"]
) {
flex-direction: row;
}
:where(ui-toggle-group, [data-ui~="toggle-group"]):not([data-toggle-group-orientation="vertical"])
> :not(:last-child) {
border-start-end-radius: 0;
border-end-end-radius: 0;
}
:where(ui-toggle-group, [data-ui~="toggle-group"]):not([data-toggle-group-orientation="vertical"])
> :not(:first-child) {
/* drop the leading border so neighbors share one seam, not two */
border-inline-start-width: 0;
border-start-start-radius: 0;
border-end-start-radius: 0;
}
/* ===========================================================================
TOGGLE GROUP: VERTICAL — data-toggle-group-orientation="vertical"
=========================================================================== */
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
) {
flex-direction: column;
}
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
)
> :not(:last-child) {
border-end-start-radius: 0;
border-end-end-radius: 0;
}
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
)
> :not(:first-child) {
/* drop the leading border so neighbors share one seam, not two */
border-block-start-width: 0;
border-start-start-radius: 0;
border-start-end-radius: 0;
}
}Multiple
<ui-toggle-group role="group" aria-label="Text formatting">
<label data-ui="toggle">
<input type="checkbox" name="format" value="bold" checked />
<span>Bold</span>
</label>
<label data-ui="toggle">
<input type="checkbox" name="format" value="italic" />
<span>Italic</span>
</label>
<label data-ui="toggle">
<input type="checkbox" name="format" value="underline" checked />
<span>Underline</span>
</label>
</ui-toggle-group>/**
* toggle-group.css: Toggle group (ui-toggle-group | [data-ui~="toggle-group"])
*
* @layer variables, components
* @requires _layers.css, _variables.css, _properties.css (--_*-resolved), toggle.css
* @uses :not(): first/last edge selection for shared-border collapse
* @uses logical border-radius longhands: RTL-safe corner rounding per orientation
* @uses flex-item z-index: raise the active control so its border/ring isn't clipped
* @uses corner-shape — superellipse corners; unsupported browsers keep plain
* rounded corners
* @tokens --ui-toggle-group-* (@layer variables; named after the utilities they back)
*/
@layer variables {
:root {
--ui-toggle-group-radius: var(--ui-toggle-radius);
--ui-toggle-group-corner-shape: var(--ui-toggle-corner-shape);
--ui-toggle-group-bg: var(--color-card);
}
}
@property --_toggle-group-radius {
syntax: "*";
inherits: false;
}
@property --_toggle-group-bg {
syntax: "*";
inherits: false;
}
@layer ui.components {
/* ===========================================================================
TOGGLE GROUP
Joins adjacent toggles into a single segmented unit: a single-select set
(radios sharing a `name`) or a multi-select set (checkboxes). Children keep
their own --ui-toggle-radius, so the outer corners follow the toggles' size
preset automatically; only the *inner* corners are squared off and the
doubled border is collapsed by dropping
each later control's leading border (no overlap).
=========================================================================== */
:where(ui-toggle-group, [data-ui~="toggle-group"]) {
display: flex;
inline-size: fit-content;
/* stretch so mixed-height children share one edge */
align-items: stretch;
--_radius-len: var(
--_radius-resolved,
var(--_toggle-group-radius, var(--ui-toggle-group-radius))
);
--_radius-num: var(
--_radius-resolved,
var(--_toggle-group-radius, var(--ui-toggle-group-radius))
);
border-radius: calc(
var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
);
corner-shape: var(--_corner-shape-resolved, var(--ui-toggle-group-corner-shape));
background-color: var(--_bg-resolved, var(--_toggle-group-bg, var(--ui-toggle-group-bg)));
position: relative;
isolation: isolate;
}
/* flex items honour z-index without positioning, but relative keeps the
stacking context robust across child types */
:where(ui-toggle-group, [data-ui~="toggle-group"]) > * {
position: relative;
}
/* the focused/hovered/checked toggle floats above its neighbors so its
focus ring paints over its neighbors */
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:hover:not(:has(> input:disabled)),
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:focus-within,
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:has(> input:checked) {
z-index: 1;
}
/* ===========================================================================
TOGGLE GROUP: HORIZONTAL (default)
=========================================================================== */
:where(ui-toggle-group, [data-ui~="toggle-group"]):not(
[data-toggle-group-orientation="vertical"]
) {
flex-direction: row;
}
:where(ui-toggle-group, [data-ui~="toggle-group"]):not([data-toggle-group-orientation="vertical"])
> :not(:last-child) {
border-start-end-radius: 0;
border-end-end-radius: 0;
}
:where(ui-toggle-group, [data-ui~="toggle-group"]):not([data-toggle-group-orientation="vertical"])
> :not(:first-child) {
/* drop the leading border so neighbors share one seam, not two */
border-inline-start-width: 0;
border-start-start-radius: 0;
border-end-start-radius: 0;
}
/* ===========================================================================
TOGGLE GROUP: VERTICAL — data-toggle-group-orientation="vertical"
=========================================================================== */
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
) {
flex-direction: column;
}
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
)
> :not(:last-child) {
border-end-start-radius: 0;
border-end-end-radius: 0;
}
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
)
> :not(:first-child) {
/* drop the leading border so neighbors share one seam, not two */
border-block-start-width: 0;
border-start-start-radius: 0;
border-start-end-radius: 0;
}
}Vertical
<ui-toggle-group data-toggle-group-orientation="vertical" role="group" aria-label="Map layer">
<label data-ui="toggle">
<input type="radio" name="layer" value="map" checked />
<span>Map</span>
</label>
<label data-ui="toggle">
<input type="radio" name="layer" value="satellite" />
<span>Satellite</span>
</label>
<label data-ui="toggle">
<input type="radio" name="layer" value="terrain" />
<span>Terrain</span>
</label>
</ui-toggle-group>/**
* toggle-group.css: Toggle group (ui-toggle-group | [data-ui~="toggle-group"])
*
* @layer variables, components
* @requires _layers.css, _variables.css, _properties.css (--_*-resolved), toggle.css
* @uses :not(): first/last edge selection for shared-border collapse
* @uses logical border-radius longhands: RTL-safe corner rounding per orientation
* @uses flex-item z-index: raise the active control so its border/ring isn't clipped
* @uses corner-shape — superellipse corners; unsupported browsers keep plain
* rounded corners
* @tokens --ui-toggle-group-* (@layer variables; named after the utilities they back)
*/
@layer variables {
:root {
--ui-toggle-group-radius: var(--ui-toggle-radius);
--ui-toggle-group-corner-shape: var(--ui-toggle-corner-shape);
--ui-toggle-group-bg: var(--color-card);
}
}
@property --_toggle-group-radius {
syntax: "*";
inherits: false;
}
@property --_toggle-group-bg {
syntax: "*";
inherits: false;
}
@layer ui.components {
/* ===========================================================================
TOGGLE GROUP
Joins adjacent toggles into a single segmented unit: a single-select set
(radios sharing a `name`) or a multi-select set (checkboxes). Children keep
their own --ui-toggle-radius, so the outer corners follow the toggles' size
preset automatically; only the *inner* corners are squared off and the
doubled border is collapsed by dropping
each later control's leading border (no overlap).
=========================================================================== */
:where(ui-toggle-group, [data-ui~="toggle-group"]) {
display: flex;
inline-size: fit-content;
/* stretch so mixed-height children share one edge */
align-items: stretch;
--_radius-len: var(
--_radius-resolved,
var(--_toggle-group-radius, var(--ui-toggle-group-radius))
);
--_radius-num: var(
--_radius-resolved,
var(--_toggle-group-radius, var(--ui-toggle-group-radius))
);
border-radius: calc(
var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
);
corner-shape: var(--_corner-shape-resolved, var(--ui-toggle-group-corner-shape));
background-color: var(--_bg-resolved, var(--_toggle-group-bg, var(--ui-toggle-group-bg)));
position: relative;
isolation: isolate;
}
/* flex items honour z-index without positioning, but relative keeps the
stacking context robust across child types */
:where(ui-toggle-group, [data-ui~="toggle-group"]) > * {
position: relative;
}
/* the focused/hovered/checked toggle floats above its neighbors so its
focus ring paints over its neighbors */
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:hover:not(:has(> input:disabled)),
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:focus-within,
:where(ui-toggle-group, [data-ui~="toggle-group"]) > *:has(> input:checked) {
z-index: 1;
}
/* ===========================================================================
TOGGLE GROUP: HORIZONTAL (default)
=========================================================================== */
:where(ui-toggle-group, [data-ui~="toggle-group"]):not(
[data-toggle-group-orientation="vertical"]
) {
flex-direction: row;
}
:where(ui-toggle-group, [data-ui~="toggle-group"]):not([data-toggle-group-orientation="vertical"])
> :not(:last-child) {
border-start-end-radius: 0;
border-end-end-radius: 0;
}
:where(ui-toggle-group, [data-ui~="toggle-group"]):not([data-toggle-group-orientation="vertical"])
> :not(:first-child) {
/* drop the leading border so neighbors share one seam, not two */
border-inline-start-width: 0;
border-start-start-radius: 0;
border-end-start-radius: 0;
}
/* ===========================================================================
TOGGLE GROUP: VERTICAL — data-toggle-group-orientation="vertical"
=========================================================================== */
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
) {
flex-direction: column;
}
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
)
> :not(:last-child) {
border-end-start-radius: 0;
border-end-end-radius: 0;
}
:where(
ui-toggle-group[data-toggle-group-orientation="vertical"],
[data-ui~="toggle-group"][data-toggle-group-orientation="vertical"]
)
> :not(:first-child) {
/* drop the leading border so neighbors share one seam, not two */
border-block-start-width: 0;
border-start-start-radius: 0;
border-start-end-radius: 0;
}
}Attributes
| Attribute | Kind | Values | Notes |
|---|---|---|---|
data-ui="toggle-group" | Identity | free value | Identity token in data-ui. |
<ui-toggle-group> | Tag form | free value | Tag form; styled and, when scripted, registered under this name. |
data-toggle-group-orientation | Preset | vertical | Preset: a named bundle of values. |
Requires: toggle.
Hooks
Set a hook on :root, on a subtree, or inline on one element. A state hook (--…--hover) themes that state only; the primitive keeps its other states.
| Hook | Default | State |
|---|---|---|
--ui-toggle-group-bg | var(--color-card) | — |
--ui-toggle-group-corner-shape | var(--ui-toggle-corner-shape) | — |
--ui-toggle-group-radius | var(--ui-toggle-radius) | — |