<div class="demo-caption">Billing period</div>
<div class="demo-pricing">
<ray-segmented-control id="demo-billing" radius="full" value="monthly" aria-label="Billing period">
<option value="monthly">Monthly</option>
<option value="yearly">Yearly · save 20%</option>
</ray-segmented-control>
<div class="demo-price-cards">
<div class="demo-price-card"><span>Hobby</span><strong data-monthly="0" data-yearly="0">$0</strong><small>Free forever</small></div>
<div class="demo-price-card featured"><span>Pro</span><strong data-monthly="12" data-yearly="115">$12</strong><small data-unit>per month</small></div>
<div class="demo-price-card"><span>Team</span><strong data-monthly="32" data-yearly="307">$32</strong><small data-unit>per month</small></div>
</div>
</div>
<div class="demo-caption">Switch the view</div>
<div class="demo-views">
<ray-segmented-control id="demo-view" size="xs" value="grid" aria-label="View">
<option value="list">List</option>
<option value="grid">Grid</option>
</ray-segmented-control>
<ul class="demo-view-items" id="demo-view-items" data-view="grid">
<li><span class="sw" style="--c: var(--ray-blue-light-color)"></span>Release notes<small>12 KB</small></li>
<li><span class="sw" style="--c: var(--ray-teal-light-color)"></span>Roadmap<small>8 KB</small></li>
<li><span class="sw" style="--c: var(--ray-violet-light-color)"></span>Brand kit<small>2.4 MB</small></li>
<li><span class="sw" style="--c: var(--ray-orange-light-color)"></span>Invoices<small>640 KB</small></li>
<li><span class="sw" style="--c: var(--ray-pink-light-color)"></span>Screenshots<small>18 MB</small></li>
<li><span class="sw" style="--c: var(--ray-green-light-color)"></span>Contracts<small>1.1 MB</small></li>
</ul>
</div>
<div class="demo-caption">Colors, sizes and radius</div>
<div class="demo-stack demo-start">
<ray-segmented-control color="teal" size="xs" radius="full" aria-label="Range">
<option>1h</option><option>24h</option><option>7d</option><option disabled>30d</option>
</ray-segmented-control>
<ray-segmented-control color="violet" aria-label="Alignment" value="center">
<option value="left">Left</option><option value="center">Center</option><option value="right">Right</option>
</ray-segmented-control>
<ray-segmented-control color="orange" size="lg" radius="xs" aria-label="Mode">
<option>Design</option><option>Prototype</option><option>Inspect</option>
</ray-segmented-control>
<ray-segmented-control disabled aria-label="Disabled">
<option>Disabled</option><option>as a whole</option>
</ray-segmented-control>
</div>
<div class="demo-caption">Vertical, full width, and from data</div>
<div class="demo-grid">
<ray-segmented-control orientation="vertical" aria-label="Section" value="profile">
<option value="profile">Profile</option><option value="security">Security</option><option value="billing">Billing</option>
</ray-segmented-control>
<div class="demo-stack">
<ray-segmented-control full-width size="md" aria-label="Platform">
<option>macOS</option><option>Linux</option><option>Windows</option>
</ray-segmented-control>
<ray-segmented-control id="demo-seg-data" full-width aria-label="Status"></ray-segmented-control>
</div>
</div>
<div class="demo-caption">Narrow containers: drag the corner of the box</div>
<div class="demo-resize">
<ray-segmented-control orientation="auto" full-width size="md" value="normal" aria-label="Text size">
<option value="normal">Normal</option><option value="large">Large</option><option value="larger">Very large</option>
</ray-segmented-control>
</div>
<p class="demo-muted"><code>orientation="auto"</code> stacks the options when they do not fit in a row. In a box narrower than even the stack, the labels end in an ellipsis.</p>
<script type="module">
const billing = document.getElementById("demo-billing");
billing.addEventListener("change", () => {
const yearly = billing.value === "yearly";
for (const el of document.querySelectorAll(".demo-price-card strong")) el.textContent = `$${yearly ? el.dataset.yearly : el.dataset.monthly}`;
for (const el of document.querySelectorAll(".demo-price-card [data-unit]")) el.textContent = yearly ? "per year" : "per month";
});
const view = document.getElementById("demo-view");
view.addEventListener("change", () => { document.getElementById("demo-view-items").dataset.view = view.value; });
const status = document.getElementById("demo-seg-data");
status.data = [{ value: "open", label: "Open" }, { value: "review", label: "In review" }, { value: "done", label: "Done" }, { value: "archived", label: "Archived", disabled: true }];
status.value = "review";
</script>
import type { CSSProperties } from "react";
import { RaySegmentedControl } from "@raylang/react";
export function SegmentedControlExample() {
return (
<>
<div className="demo-caption">Billing period</div>
<div className="demo-pricing">
<RaySegmentedControl id="demo-billing" radius="full" value="monthly" aria-label="Billing period">
<option value="monthly">Monthly</option>
<option value="yearly">Yearly · save 20%</option>
</RaySegmentedControl>
<div className="demo-price-cards">
<div className="demo-price-card"><span>Hobby</span><strong data-monthly="0" data-yearly="0">$0</strong><small>Free forever</small></div>
<div className="demo-price-card featured"><span>Pro</span><strong data-monthly="12" data-yearly="115">$12</strong><small data-unit>per month</small></div>
<div className="demo-price-card"><span>Team</span><strong data-monthly="32" data-yearly="307">$32</strong><small data-unit>per month</small></div>
</div>
</div>
<div className="demo-caption">Switch the view</div>
<div className="demo-views">
<RaySegmentedControl id="demo-view" size="xs" value="grid" aria-label="View">
<option value="list">List</option>
<option value="grid">Grid</option>
</RaySegmentedControl>
<ul className="demo-view-items" id="demo-view-items" data-view="grid">
<li><span className="sw" style={{ "--c": "var(--ray-blue-light-color)" } as CSSProperties} />Release notes<small>12 KB</small></li>
<li><span className="sw" style={{ "--c": "var(--ray-teal-light-color)" } as CSSProperties} />Roadmap<small>8 KB</small></li>
<li><span className="sw" style={{ "--c": "var(--ray-violet-light-color)" } as CSSProperties} />Brand kit<small>2.4 MB</small></li>
<li><span className="sw" style={{ "--c": "var(--ray-orange-light-color)" } as CSSProperties} />Invoices<small>640 KB</small></li>
<li><span className="sw" style={{ "--c": "var(--ray-pink-light-color)" } as CSSProperties} />Screenshots<small>18 MB</small></li>
<li><span className="sw" style={{ "--c": "var(--ray-green-light-color)" } as CSSProperties} />Contracts<small>1.1 MB</small></li>
</ul>
</div>
<div className="demo-caption">Colors, sizes and radius</div>
<div className="demo-stack demo-start">
<RaySegmentedControl color="teal" size="xs" radius="full" aria-label="Range">
<option>1h</option><option>24h</option><option>7d</option><option disabled>30d</option>
</RaySegmentedControl>
<RaySegmentedControl color="violet" aria-label="Alignment" value="center">
<option value="left">Left</option><option value="center">Center</option><option value="right">Right</option>
</RaySegmentedControl>
<RaySegmentedControl color="orange" size="lg" radius="xs" aria-label="Mode">
<option>Design</option><option>Prototype</option><option>Inspect</option>
</RaySegmentedControl>
<RaySegmentedControl disabled aria-label="Disabled">
<option>Disabled</option><option>as a whole</option>
</RaySegmentedControl>
</div>
<div className="demo-caption">Vertical, full width, and from data</div>
<div className="demo-grid">
<RaySegmentedControl orientation="vertical" aria-label="Section" value="profile">
<option value="profile">Profile</option><option value="security">Security</option><option value="billing">Billing</option>
</RaySegmentedControl>
<div className="demo-stack">
<RaySegmentedControl fullWidth size="md" aria-label="Platform">
<option>macOS</option><option>Linux</option><option>Windows</option>
</RaySegmentedControl>
<RaySegmentedControl id="demo-seg-data" fullWidth aria-label="Status" />
</div>
</div>
<div className="demo-caption">Narrow containers: drag the corner of the box</div>
<div className="demo-resize">
<RaySegmentedControl orientation="auto" fullWidth size="md" value="normal" aria-label="Text size">
<option value="normal">Normal</option><option value="large">Large</option><option value="larger">Very large</option>
</RaySegmentedControl>
</div>
<p className="demo-muted"><code>orientation="auto"</code> stacks the options when they do not fit in a row. In a box narrower than even the stack, the labels end in an ellipsis.</p>
</>
);
}
<template>
<div class="demo-caption">Billing period</div>
<div class="demo-pricing">
<RaySegmentedControl id="demo-billing" radius="full" value="monthly" aria-label="Billing period">
<option value="monthly">Monthly</option>
<option value="yearly">Yearly · save 20%</option>
</RaySegmentedControl>
<div class="demo-price-cards">
<div class="demo-price-card"><span>Hobby</span><strong data-monthly="0" data-yearly="0">$0</strong><small>Free forever</small></div>
<div class="demo-price-card featured"><span>Pro</span><strong data-monthly="12" data-yearly="115">$12</strong><small data-unit>per month</small></div>
<div class="demo-price-card"><span>Team</span><strong data-monthly="32" data-yearly="307">$32</strong><small data-unit>per month</small></div>
</div>
</div>
<div class="demo-caption">Switch the view</div>
<div class="demo-views">
<RaySegmentedControl id="demo-view" size="xs" value="grid" aria-label="View">
<option value="list">List</option>
<option value="grid">Grid</option>
</RaySegmentedControl>
<ul class="demo-view-items" id="demo-view-items" data-view="grid">
<li><span class="sw" style="--c: var(--ray-blue-light-color)"></span>Release notes<small>12 KB</small></li>
<li><span class="sw" style="--c: var(--ray-teal-light-color)"></span>Roadmap<small>8 KB</small></li>
<li><span class="sw" style="--c: var(--ray-violet-light-color)"></span>Brand kit<small>2.4 MB</small></li>
<li><span class="sw" style="--c: var(--ray-orange-light-color)"></span>Invoices<small>640 KB</small></li>
<li><span class="sw" style="--c: var(--ray-pink-light-color)"></span>Screenshots<small>18 MB</small></li>
<li><span class="sw" style="--c: var(--ray-green-light-color)"></span>Contracts<small>1.1 MB</small></li>
</ul>
</div>
<div class="demo-caption">Colors, sizes and radius</div>
<div class="demo-stack demo-start">
<RaySegmentedControl color="teal" size="xs" radius="full" aria-label="Range">
<option>1h</option><option>24h</option><option>7d</option><option disabled>30d</option>
</RaySegmentedControl>
<RaySegmentedControl color="violet" aria-label="Alignment" value="center">
<option value="left">Left</option><option value="center">Center</option><option value="right">Right</option>
</RaySegmentedControl>
<RaySegmentedControl color="orange" size="lg" radius="xs" aria-label="Mode">
<option>Design</option><option>Prototype</option><option>Inspect</option>
</RaySegmentedControl>
<RaySegmentedControl disabled aria-label="Disabled">
<option>Disabled</option><option>as a whole</option>
</RaySegmentedControl>
</div>
<div class="demo-caption">Vertical, full width, and from data</div>
<div class="demo-grid">
<RaySegmentedControl orientation="vertical" aria-label="Section" value="profile">
<option value="profile">Profile</option><option value="security">Security</option><option value="billing">Billing</option>
</RaySegmentedControl>
<div class="demo-stack">
<RaySegmentedControl full-width size="md" aria-label="Platform">
<option>macOS</option><option>Linux</option><option>Windows</option>
</RaySegmentedControl>
<RaySegmentedControl id="demo-seg-data" full-width aria-label="Status" />
</div>
</div>
<div class="demo-caption">Narrow containers: drag the corner of the box</div>
<div class="demo-resize">
<RaySegmentedControl orientation="auto" full-width size="md" value="normal" aria-label="Text size">
<option value="normal">Normal</option><option value="large">Large</option><option value="larger">Very large</option>
</RaySegmentedControl>
</div>
<p class="demo-muted"><code>orientation="auto"</code> stacks the options when they do not fit in a row. In a box narrower than even the stack, the labels end in an ellipsis.</p>
</template>