Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Radio Group

    Group of native radios inside a fieldset and legend for picking one of several options.

    Subscription plan

    For personal projects.

    For small teams of up to 10 people.

    For organizations with custom needs.

    Billing cycle
    Subscription plan

    For personal projects.

    For small teams of up to 10 people.

    For organizations with custom needs.

    Billing cycle
    Subscription plan

    For personal projects.

    For small teams of up to 10 people.

    For organizations with custom needs.

    Billing cycle
    Subscription plan

    For personal projects.

    For small teams of up to 10 people.

    For organizations with custom needs.

    Billing cycle
    Subscription plan

    For personal projects.

    For small teams of up to 10 people.

    For organizations with custom needs.

    Billing cycle
    <div class="grid gap-6">
        <x-markas.radio-group
            name="plan"
            label="Subscription plan"
            value="pro"
            :options="[
                ['value' => 'free', 'label' => 'Free', 'description' => 'For personal projects.'],
                ['value' => 'pro', 'label' => 'Pro', 'description' => 'For small teams of up to 10 people.'],
                ['value' => 'business', 'label' => 'Business', 'description' => 'For organizations with custom needs.'],
            ]"
        />
        <x-markas.radio-group
            name="billing"
            label="Billing cycle"
            value="monthly"
            orientation="horizontal"
            :options="[
                ['value' => 'monthly', 'label' => 'Monthly'],
                ['value' => 'yearly', 'label' => 'Yearly'],
            ]"
        />
    </div>
    import { RadioGroup } from "@/components/markas/RadioGroup";
    
    const plan = [
      { value: "free", label: "Free", description: "For personal projects." },
      {
        value: "pro",
        label: "Pro",
        description: "For small teams of up to 10 people.",
      },
      {
        value: "business",
        label: "Business",
        description: "For organizations with custom needs.",
      },
    ];
    const billing = [
      { value: "monthly", label: "Monthly" },
      { value: "yearly", label: "Yearly" },
    ];
    
    export default function RadioGroupExample() {
      return (
        <div className="grid gap-6">
          <RadioGroup
            name="plan"
            label="Subscription plan"
            defaultValue="pro"
            options={plan}
          />
          <RadioGroup
            name="billing"
            label="Billing cycle"
            defaultValue="monthly"
            orientation="horizontal"
            options={billing}
          />
        </div>
      );
    }
    <script setup lang="ts">
    import { ref } from "vue";
    import RadioGroup from "@/components/markas/RadioGroup.vue";
    
    const planOptions = [
      { value: "free", label: "Free", description: "For personal projects." },
      {
        value: "pro",
        label: "Pro",
        description: "For small teams of up to 10 people.",
      },
      {
        value: "business",
        label: "Business",
        description: "For organizations with custom needs.",
      },
    ];
    const billingOptions = [
      { value: "monthly", label: "Monthly" },
      { value: "yearly", label: "Yearly" },
    ];
    const plan = ref("pro");
    const billing = ref("monthly");
    </script>
    
    <template>
      <div class="grid gap-6">
        <RadioGroup
          v-model="plan"
          name="plan"
          label="Subscription plan"
          :options="planOptions"
        />
        <RadioGroup
          v-model="billing"
          name="billing"
          label="Billing cycle"
          orientation="horizontal"
          :options="billingOptions"
        />
      </div>
    </template>
    <script lang="ts">
      import RadioGroup from "$lib/components/markas/RadioGroup.svelte";
    
      const plan = [
        {
          value: "free",
          label: "Free",
          description: "For personal projects.",
        },
        {
          value: "pro",
          label: "Pro",
          description: "For small teams of up to 10 people.",
        },
        {
          value: "business",
          label: "Business",
          description: "For organizations with custom needs.",
        },
      ];
      const billing = [
        {
          value: "monthly",
          label: "Monthly",
        },
        {
          value: "yearly",
          label: "Yearly",
        },
      ];
    </script>
    
    <div class="grid gap-6">
      <RadioGroup
        name="plan"
        label="Subscription plan"
        value="pro"
        options={plan}
      />
      <RadioGroup
        name="billing"
        label="Billing cycle"
        value="monthly"
        orientation="horizontal"
        options={billing}
      />
    </div>
    ---
    import RadioGroup from "@/components/markas/RadioGroup.astro";
    
    const plan = [
      {
        value: "free",
        label: "Free",
        description: "For personal projects."
      },
      {
        value: "pro",
        label: "Pro",
        description: "For small teams of up to 10 people."
      },
      {
        value: "business",
        label: "Business",
        description: "For organizations with custom needs."
      }
    ];
    const billing = [
      {
        value: "monthly",
        label: "Monthly"
      },
      {
        value: "yearly",
        label: "Yearly"
      }
    ];
    ---
    
    <div class="grid gap-6">
      <RadioGroup
        name="plan"
        label="Subscription plan"
        value="pro"
        options={plan}
      />
      <RadioGroup
        name="billing"
        label="Billing cycle"
        value="monthly"
        orientation="horizontal"
        options={billing}
      />
    </div>
    import { Component } from "@angular/core";
    import { RadioGroup } from "./markas/radio-group.component";
    
    @Component({
      selector: "markas-example",
      imports: [RadioGroup],
      template: `
        <div class="grid gap-6">
          <markas-radio-group
            name="plan"
            label="Subscription plan"
            value="pro"
            [options]="plan"
          />
          <markas-radio-group
            name="billing"
            label="Billing cycle"
            value="monthly"
            orientation="horizontal"
            [options]="billing"
          />
        </div>
      `,
    })
    export default class RadioGroupFixture {
      protected readonly plan = [
        {
          value: "free",
          label: "Free",
          description: "For personal projects.",
        },
        {
          value: "pro",
          label: "Pro",
          description: "For small teams of up to 10 people.",
        },
        {
          value: "business",
          label: "Business",
          description: "For organizations with custom needs.",
        },
      ];
      protected readonly billing = [
        {
          value: "monthly",
          label: "Monthly",
        },
        {
          value: "yearly",
          label: "Yearly",
        },
      ];
    }

    Examples

    Horizontal

    Theme
    Size
    Theme
    Size
    Theme
    Size
    Theme
    Size
    Theme
    Size

    With descriptions

    Shipping method

    Arrives in 4 to 6 business days. Free.

    Arrives in 1 to 2 business days. $12.

    Ready for pickup tomorrow at 10:00.

    Shipping method

    Arrives in 4 to 6 business days. Free.

    Arrives in 1 to 2 business days. $12.

    Ready for pickup tomorrow at 10:00.

    Shipping method

    Arrives in 4 to 6 business days. Free.

    Arrives in 1 to 2 business days. $12.

    Ready for pickup tomorrow at 10:00.

    Shipping method

    Arrives in 4 to 6 business days. Free.

    Arrives in 1 to 2 business days. $12.

    Ready for pickup tomorrow at 10:00.

    Shipping method

    Arrives in 4 to 6 business days. Free.

    Arrives in 1 to 2 business days. $12.

    Ready for pickup tomorrow at 10:00.

    Cards

    Plan

    1 project and 2 GB storage. Free forever.

    Unlimited projects and 100 GB storage. $29 per month.

    SSO, audit logs, and a dedicated manager.

    Plan

    1 project and 2 GB storage. Free forever.

    Unlimited projects and 100 GB storage. $29 per month.

    SSO, audit logs, and a dedicated manager.

    Plan

    1 project and 2 GB storage. Free forever.

    Unlimited projects and 100 GB storage. $29 per month.

    SSO, audit logs, and a dedicated manager.

    Plan

    1 project and 2 GB storage. Free forever.

    Unlimited projects and 100 GB storage. $29 per month.

    SSO, audit logs, and a dedicated manager.

    Plan

    1 project and 2 GB storage. Free forever.

    Unlimited projects and 100 GB storage. $29 per month.

    SSO, audit logs, and a dedicated manager.

    Disabled

    Payout schedule

    Verify your bank account to change the payout schedule.

    Payout schedule

    Verify your bank account to change the payout schedule.

    Payout schedule

    Verify your bank account to change the payout schedule.

    Payout schedule

    Verify your bank account to change the payout schedule.

    Payout schedule

    Verify your bank account to change the payout schedule.

    In a card

    Digest emails

    A summary of activity in projects you follow.

    Frequency

    Every morning at 08:00.

    Every Monday morning.

    Only important account notices.

    Digest emails

    A summary of activity in projects you follow.

    Frequency

    Every morning at 08:00.

    Every Monday morning.

    Only important account notices.

    Digest emails

    A summary of activity in projects you follow.

    Frequency

    Every morning at 08:00.

    Every Monday morning.

    Only important account notices.

    Digest emails

    A summary of activity in projects you follow.

    Frequency

    Every morning at 08:00.

    Every Monday morning.

    Only important account notices.

    Digest emails

    A summary of activity in projects you follow.

    Frequency

    Every morning at 08:00.

    Every Monday morning.

    Only important account notices.

    Installation

    npx markasui@latest add radio-group

    Usage

    <x-markas.radio-group
        name="plan"
        label="Subscription plan"
        :value="old('plan', 'pro')"
        :options="[
            ['value' => 'free', 'label' => 'Free', 'description' => 'For personal projects.'],
            ['value' => 'pro', 'label' => 'Pro'],
        ]"
    />

    Livewire

    <x-markas.radio-group name="plan" wire:model.live="plan" :options="$plans" />

    wire:model (and x-model) is copied to every radio, so Livewire reads the checked value. Other attributes stay on the fieldset.

    import { RadioGroup } from "@/components/markas/RadioGroup";
    
    <RadioGroup
      name="plan"
      label="Subscription plan"
      defaultValue="pro"
      onValueChange={(value) => console.log(value)}
      options={[
        { value: "free", label: "Free", description: "For personal projects." },
        { value: "pro", label: "Pro" },
      ]}
    />;
    <script setup lang="ts">
    import { ref } from "vue";
    import RadioGroup from "@/components/markas/RadioGroup.vue";
    
    const plan = ref("pro");
    </script>
    
    <template>
      <RadioGroup
        v-model="plan"
        name="plan"
        label="Subscription plan"
        :options="[
          { value: 'free', label: 'Free', description: 'For personal projects.' },
          { value: 'pro', label: 'Pro' },
        ]"
      />
    </template>
    <script lang="ts">
      import RadioGroup from "$lib/components/markas/RadioGroup.svelte";
    
      let plan = $state("pro");
    </script>
    
    <RadioGroup
      bind:value={plan}
      name="plan"
      label="Subscription plan"
      options={[
        { value: "free", label: "Free", description: "For personal projects." },
        { value: "pro", label: "Pro" },
      ]}
    />
    ---
    import RadioGroup from "@/components/markas/RadioGroup.astro";
    ---
    
    <RadioGroup
      name="plan"
      label="Subscription plan"
      value="pro"
      options={[
        { value: "free", label: "Free", description: "For personal projects." },
        { value: "pro", label: "Pro" },
      ]}
    />

    No client script: the options are native radios.

    import { Component, signal } from "@angular/core";
    import { RadioGroup } from "./markas/radio-group.component";
    
    @Component({
      selector: "app-billing",
      imports: [RadioGroup],
      template: `
        <markas-radio-group
          [(value)]="plan"
          name="plan"
          label="Subscription plan"
          [options]="plans"
        />
      `,
    })
    export class Billing {
      readonly plan = signal<string | undefined>("pro");
      readonly plans = [
        { value: "free", label: "Free", description: "For personal projects." },
        { value: "pro", label: "Pro" },
      ];
    }
    • Extra attributes (class, disabled, aria-*) fall through to the <fieldset>. disabled on the fieldset disables every radio at once.
    • Option values are used in ids, so stick to lowercase letters, digits, hyphens, or underscores.
    • Use orientation="horizontal" for short options laid out in a row.
    • The component has no built-in text. Translate label and each option’s label and description directly.

    Props

    NameTypeDefaultDescription
    namestringrequiredThe name attribute shared by every radio in the group.
    options{ value, label, description? }[][]List of options. The value is also used as part of the id.
    labelstring-Group title, rendered as the legend.
    value / defaultValue / v-model / bind:valuestring-Selected option. Blade and Astro use value, React value or defaultValue, Vue v-model, Svelte bind:value, Angular value or [(value)].
    onValueChange(value: string) => void-React only. Called with the value of the newly selected option.
    orientation"vertical" | "horizontal"verticalOption layout: stacked or in a row.
    idstringautoFieldset id, also the prefix of each radio id. Generated when empty.

    Accessibility

    • Uses fieldset and legend, so the group title is announced when focus enters a radio.
    • Native radios: Tab moves to the selected option, arrow keys change the selection.
    • Option descriptions are linked to their radio through aria-describedby.

    Related components

    More form components with the same classes in every framework.