<div class="demo-caption">Delivery, with a live total</div>
<div class="demo-split">
<ray-radio-group id="demo-shipping" label="Delivery" name="shipping" value="standard" description="Prices include taxes.">
<ray-radio value="standard" label="Standard · free" description="4–6 business days"></ray-radio>
<ray-radio value="express" label="Express · $9.00" description="1–2 business days"></ray-radio>
<ray-radio value="pickup" label="Pick up in store · free" description="Ready tomorrow from 10:00"></ray-radio>
<ray-radio value="drone" label="Drone · $24.00" description="Not available at your address" disabled></ray-radio>
</ray-radio-group>
<dl class="demo-summary">
<div><dt>Subtotal</dt><dd>$48.00</dd></div>
<div><dt>Delivery</dt><dd id="demo-shipping-cost">$0.00</dd></div>
<div class="total"><dt>Total</dt><dd id="demo-shipping-total">$48.00</dd></div>
<p class="demo-muted" id="demo-shipping-eta">Arrives in 4–6 business days.</p>
</dl>
</div>
<div class="demo-caption">Cards: ray-radio-card in a ray-grid</div>
<ray-radio-group id="demo-preset" label="Preset" name="preset" value="pro">
<ray-grid cols="2" gap="sm">
<ray-radio-card value="pro" label="Pro boxing" description="12 × 3:00 / 1:00"></ray-radio-card>
<ray-radio-card value="amateur" label="Amateur" description="3 × 3:00 / 1:00"></ray-radio-card>
<ray-radio-card value="mma" label="MMA" description="5 × 5:00 / 1:00"></ray-radio-card>
<ray-radio-card value="hiit" label="HIIT" description="8 × 0:20 / 0:10"></ray-radio-card>
</ray-grid>
</ray-radio-group>
<div class="demo-grid">
<ray-radio-group label="Plan" name="plan" value="team" color="teal">
<ray-radio-card value="solo" label="Solo" description="One seat, every component."><ray-icon slot="icon" name="user"></ray-icon></ray-radio-card>
<ray-radio-card value="team" label="Team · $12/month" description="Up to 10 seats and shared themes."><ray-icon slot="icon" name="home"></ray-icon><ray-badge size="xs" variant="light" color="teal">Popular</ray-badge></ray-radio-card>
<ray-radio-card value="enterprise" label="Enterprise" description="Contact us." disabled><ray-icon slot="icon" name="settings"></ray-icon></ray-radio-card>
</ray-radio-group>
<ray-radio-group label="Without the circle" value="dark" orientation="horizontal">
<ray-radio-card value="light" label="Light" hide-indicator><ray-icon slot="icon" name="sun"></ray-icon></ray-radio-card>
<ray-radio-card value="dark" label="Dark" hide-indicator><ray-icon slot="icon" name="moon"></ray-icon></ray-radio-card>
<ray-radio-card value="system" label="System" hide-indicator><ray-icon slot="icon" name="monitor"></ray-icon></ray-radio-card>
</ray-radio-group>
</div>
<div class="demo-caption">Horizontal, colors and the outline variant</div>
<div class="demo-grid">
<ray-radio-group label="Theme" orientation="horizontal" color="violet" value="dark">
<ray-radio value="light">Light</ray-radio>
<ray-radio value="dark">Dark</ray-radio>
<ray-radio value="system">System</ray-radio>
</ray-radio-group>
<ray-radio-group label="Backups" orientation="horizontal" variant="outline" color="teal" value="daily">
<ray-radio value="hourly">Hourly</ray-radio>
<ray-radio value="daily">Daily</ray-radio>
<ray-radio value="weekly">Weekly</ray-radio>
</ray-radio-group>
<ray-radio-group label="Size" orientation="horizontal" color="orange" size="md" value="m">
<ray-radio value="s">S</ray-radio>
<ray-radio value="m">M</ray-radio>
<ray-radio value="l">L</ray-radio>
<ray-radio value="xl" disabled>XL</ray-radio>
</ray-radio-group>
</div>
<div class="demo-caption">Sizes</div>
<div class="demo-row">
<ray-radio-group aria-label="Extra small" size="xs" value="a"><ray-radio value="a">xs</ray-radio></ray-radio-group>
<ray-radio-group aria-label="Small" size="sm" value="a"><ray-radio value="a">sm</ray-radio></ray-radio-group>
<ray-radio-group aria-label="Medium" size="md" value="a"><ray-radio value="a">md</ray-radio></ray-radio-group>
<ray-radio-group aria-label="Large" size="lg" value="a"><ray-radio value="a">lg</ray-radio></ray-radio-group>
<ray-radio-group aria-label="Extra large" size="xl" value="a"><ray-radio value="a">xl</ray-radio></ray-radio-group>
</div>
<div class="demo-caption">Required, in a form</div>
<form class="demo-auth" id="demo-survey" novalidate>
<ray-radio-group id="demo-source" name="source" label="How did you hear about ray·elements?" description-position="below" description="One answer." required>
<ray-radio value="friend">A friend or a colleague</ray-radio>
<ray-radio value="search">A search engine</ray-radio>
<ray-radio value="talk">A talk or a meetup</ray-radio>
<ray-radio value="other">Somewhere else</ray-radio>
</ray-radio-group>
<div class="demo-actions"><ray-button type="submit">Send</ray-button><span class="demo-muted" id="demo-survey-out"></span></div>
</form>
<script type="module">
const prices = { standard: 0, express: 9, pickup: 0, drone: 24 };
const eta = { standard: "Arrives in 4–6 business days.", express: "Arrives in 1–2 business days.", pickup: "Ready tomorrow from 10:00.", drone: "" };
const shipping = document.getElementById("demo-shipping");
const money = (n) => `$${n.toFixed(2)}`;
shipping.addEventListener("change", () => {
const cost = prices[shipping.value] ?? 0;
document.getElementById("demo-shipping-cost").textContent = money(cost);
document.getElementById("demo-shipping-total").textContent = money(48 + cost);
document.getElementById("demo-shipping-eta").textContent = eta[shipping.value] ?? "";
});
const form = document.getElementById("demo-survey");
const source = document.getElementById("demo-source");
form.addEventListener("submit", (e) => {
e.preventDefault();
if (!source.value) {
source.error = "Pick one to continue.";
document.getElementById("demo-survey-out").textContent = "";
return;
}
document.getElementById("demo-survey-out").textContent = `Thanks! source=${new FormData(form).get("source")}`;
});
source.addEventListener("change", () => { source.error = ""; });
</script>
import { RayRadioGroup, RayRadio, RayGrid, RayRadioCard, RayIcon, RayBadge, RayButton } from "@raylang/react";
export function RadioExample() {
return (
<>
<div className="demo-caption">Delivery, with a live total</div>
<div className="demo-split">
<RayRadioGroup id="demo-shipping" label="Delivery" name="shipping" value="standard" description="Prices include taxes.">
<RayRadio value="standard" label="Standard · free" description="4–6 business days" />
<RayRadio value="express" label="Express · $9.00" description="1–2 business days" />
<RayRadio value="pickup" label="Pick up in store · free" description="Ready tomorrow from 10:00" />
<RayRadio value="drone" label="Drone · $24.00" description="Not available at your address" disabled />
</RayRadioGroup>
<dl className="demo-summary">
<div><dt>Subtotal</dt><dd>$48.00</dd></div>
<div><dt>Delivery</dt><dd id="demo-shipping-cost">$0.00</dd></div>
<div className="total"><dt>Total</dt><dd id="demo-shipping-total">$48.00</dd></div>
<p className="demo-muted" id="demo-shipping-eta">Arrives in 4–6 business days.</p>
</dl>
</div>
<div className="demo-caption">Cards: ray-radio-card in a ray-grid</div>
<RayRadioGroup id="demo-preset" label="Preset" name="preset" value="pro">
<RayGrid cols="2" gap="sm">
<RayRadioCard value="pro" label="Pro boxing" description="12 × 3:00 / 1:00" />
<RayRadioCard value="amateur" label="Amateur" description="3 × 3:00 / 1:00" />
<RayRadioCard value="mma" label="MMA" description="5 × 5:00 / 1:00" />
<RayRadioCard value="hiit" label="HIIT" description="8 × 0:20 / 0:10" />
</RayGrid>
</RayRadioGroup>
<div className="demo-grid">
<RayRadioGroup label="Plan" name="plan" value="team" color="teal">
<RayRadioCard value="solo" label="Solo" description="One seat, every component."><RayIcon slot="icon" name="user" /></RayRadioCard>
<RayRadioCard value="team" label="Team · $12/month" description="Up to 10 seats and shared themes."><RayIcon slot="icon" name="home" /><RayBadge size="xs" variant="light" color="teal">Popular</RayBadge></RayRadioCard>
<RayRadioCard value="enterprise" label="Enterprise" description="Contact us." disabled><RayIcon slot="icon" name="settings" /></RayRadioCard>
</RayRadioGroup>
<RayRadioGroup label="Without the circle" value="dark" orientation="horizontal">
<RayRadioCard value="light" label="Light" hideIndicator><RayIcon slot="icon" name="sun" /></RayRadioCard>
<RayRadioCard value="dark" label="Dark" hideIndicator><RayIcon slot="icon" name="moon" /></RayRadioCard>
<RayRadioCard value="system" label="System" hideIndicator><RayIcon slot="icon" name="monitor" /></RayRadioCard>
</RayRadioGroup>
</div>
<div className="demo-caption">Horizontal, colors and the outline variant</div>
<div className="demo-grid">
<RayRadioGroup label="Theme" orientation="horizontal" color="violet" value="dark">
<RayRadio value="light">Light</RayRadio>
<RayRadio value="dark">Dark</RayRadio>
<RayRadio value="system">System</RayRadio>
</RayRadioGroup>
<RayRadioGroup label="Backups" orientation="horizontal" variant="outline" color="teal" value="daily">
<RayRadio value="hourly">Hourly</RayRadio>
<RayRadio value="daily">Daily</RayRadio>
<RayRadio value="weekly">Weekly</RayRadio>
</RayRadioGroup>
<RayRadioGroup label="Size" orientation="horizontal" color="orange" size="md" value="m">
<RayRadio value="s">S</RayRadio>
<RayRadio value="m">M</RayRadio>
<RayRadio value="l">L</RayRadio>
<RayRadio value="xl" disabled>XL</RayRadio>
</RayRadioGroup>
</div>
<div className="demo-caption">Sizes</div>
<div className="demo-row">
<RayRadioGroup aria-label="Extra small" size="xs" value="a"><RayRadio value="a">xs</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Small" size="sm" value="a"><RayRadio value="a">sm</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Medium" size="md" value="a"><RayRadio value="a">md</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Large" size="lg" value="a"><RayRadio value="a">lg</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Extra large" size="xl" value="a"><RayRadio value="a">xl</RayRadio></RayRadioGroup>
</div>
<div className="demo-caption">Required, in a form</div>
<form className="demo-auth" id="demo-survey" novalidate>
<RayRadioGroup id="demo-source" name="source" label="How did you hear about ray·elements?" descriptionPosition="below" description="One answer." required>
<RayRadio value="friend">A friend or a colleague</RayRadio>
<RayRadio value="search">A search engine</RayRadio>
<RayRadio value="talk">A talk or a meetup</RayRadio>
<RayRadio value="other">Somewhere else</RayRadio>
</RayRadioGroup>
<div className="demo-actions"><RayButton type="submit">Send</RayButton><span className="demo-muted" id="demo-survey-out" /></div>
</form>
</>
);
}
<template>
<div class="demo-caption">Delivery, with a live total</div>
<div class="demo-split">
<RayRadioGroup id="demo-shipping" label="Delivery" name="shipping" value="standard" description="Prices include taxes.">
<RayRadio value="standard" label="Standard · free" description="4–6 business days" />
<RayRadio value="express" label="Express · $9.00" description="1–2 business days" />
<RayRadio value="pickup" label="Pick up in store · free" description="Ready tomorrow from 10:00" />
<RayRadio value="drone" label="Drone · $24.00" description="Not available at your address" disabled />
</RayRadioGroup>
<dl class="demo-summary">
<div><dt>Subtotal</dt><dd>$48.00</dd></div>
<div><dt>Delivery</dt><dd id="demo-shipping-cost">$0.00</dd></div>
<div class="total"><dt>Total</dt><dd id="demo-shipping-total">$48.00</dd></div>
<p class="demo-muted" id="demo-shipping-eta">Arrives in 4–6 business days.</p>
</dl>
</div>
<div class="demo-caption">Cards: ray-radio-card in a ray-grid</div>
<RayRadioGroup id="demo-preset" label="Preset" name="preset" value="pro">
<RayGrid cols="2" gap="sm">
<RayRadioCard value="pro" label="Pro boxing" description="12 × 3:00 / 1:00" />
<RayRadioCard value="amateur" label="Amateur" description="3 × 3:00 / 1:00" />
<RayRadioCard value="mma" label="MMA" description="5 × 5:00 / 1:00" />
<RayRadioCard value="hiit" label="HIIT" description="8 × 0:20 / 0:10" />
</RayGrid>
</RayRadioGroup>
<div class="demo-grid">
<RayRadioGroup label="Plan" name="plan" value="team" color="teal">
<RayRadioCard value="solo" label="Solo" description="One seat, every component."><RayIcon slot="icon" name="user" /></RayRadioCard>
<RayRadioCard value="team" label="Team · $12/month" description="Up to 10 seats and shared themes."><RayIcon slot="icon" name="home" /><RayBadge size="xs" variant="light" color="teal">Popular</RayBadge></RayRadioCard>
<RayRadioCard value="enterprise" label="Enterprise" description="Contact us." disabled><RayIcon slot="icon" name="settings" /></RayRadioCard>
</RayRadioGroup>
<RayRadioGroup label="Without the circle" value="dark" orientation="horizontal">
<RayRadioCard value="light" label="Light" hide-indicator><RayIcon slot="icon" name="sun" /></RayRadioCard>
<RayRadioCard value="dark" label="Dark" hide-indicator><RayIcon slot="icon" name="moon" /></RayRadioCard>
<RayRadioCard value="system" label="System" hide-indicator><RayIcon slot="icon" name="monitor" /></RayRadioCard>
</RayRadioGroup>
</div>
<div class="demo-caption">Horizontal, colors and the outline variant</div>
<div class="demo-grid">
<RayRadioGroup label="Theme" orientation="horizontal" color="violet" value="dark">
<RayRadio value="light">Light</RayRadio>
<RayRadio value="dark">Dark</RayRadio>
<RayRadio value="system">System</RayRadio>
</RayRadioGroup>
<RayRadioGroup label="Backups" orientation="horizontal" variant="outline" color="teal" value="daily">
<RayRadio value="hourly">Hourly</RayRadio>
<RayRadio value="daily">Daily</RayRadio>
<RayRadio value="weekly">Weekly</RayRadio>
</RayRadioGroup>
<RayRadioGroup label="Size" orientation="horizontal" color="orange" size="md" value="m">
<RayRadio value="s">S</RayRadio>
<RayRadio value="m">M</RayRadio>
<RayRadio value="l">L</RayRadio>
<RayRadio value="xl" disabled>XL</RayRadio>
</RayRadioGroup>
</div>
<div class="demo-caption">Sizes</div>
<div class="demo-row">
<RayRadioGroup aria-label="Extra small" size="xs" value="a"><RayRadio value="a">xs</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Small" size="sm" value="a"><RayRadio value="a">sm</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Medium" size="md" value="a"><RayRadio value="a">md</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Large" size="lg" value="a"><RayRadio value="a">lg</RayRadio></RayRadioGroup>
<RayRadioGroup aria-label="Extra large" size="xl" value="a"><RayRadio value="a">xl</RayRadio></RayRadioGroup>
</div>
<div class="demo-caption">Required, in a form</div>
<form class="demo-auth" id="demo-survey" novalidate>
<RayRadioGroup id="demo-source" name="source" label="How did you hear about ray·elements?" description-position="below" description="One answer." required>
<RayRadio value="friend">A friend or a colleague</RayRadio>
<RayRadio value="search">A search engine</RayRadio>
<RayRadio value="talk">A talk or a meetup</RayRadio>
<RayRadio value="other">Somewhere else</RayRadio>
</RayRadioGroup>
<div class="demo-actions"><RayButton type="submit">Send</RayButton><span class="demo-muted" id="demo-survey-out"></span></div>
</form>
</template>