Components
- AccordionNew
- Alert
- Alert DialogNew
- AutocompleteNew
- AvatarNew
- Badge
- Breadcrumb
- Button
- CalendarNew
- CardNew
- Checkbox
- Checkbox GroupNew
- CollapsibleNew
- ComboboxNew
- CommandNew
- Context MenuNew
- Date PickerNew
- DialogNew
- DrawerNew
- EmptyNew
- FieldNew
- FieldsetNew
- FormNew
- FrameNew
- GroupNew
- Input
- Input GroupNew
- KbdNew
- Label
- MenuNew
- MeterNew
- Number Field
- OTP FieldNew
- Pagination
- PopoverNew
- Preview CardNew
- Progress
- Radio Group
- Scroll AreaNew
- Select
- Separator
- SheetNew
- SkeletonNew
- Slider
- Spinner
- StepperNew
- Switch
- Table
- TabsNew
- Textarea
- ToastNew
- ToggleNew
- Toggle GroupNew
- ToolbarNew
- Tooltip
Radio Group
A set of checkable buttons where no more than one of the buttons can be checked at a time.
import { Label } from "mako-ui/components/label";
import { Radio, RadioGroup } from "mako-ui/components/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="next">
<Label>
<Radio value="next" /> Next.js
</Label>
<Label>
<Radio value="vite" /> Vite
</Label>
<Label>
<Radio value="astro" /> Astro
</Label>
</RadioGroup>
);
}
Usage
import { Label } from "mako-ui/components/label"
import { Radio, RadioGroup } from "mako-ui/components/radio-group"<RadioGroup defaultValue="next">
<Label>
<Radio value="next" /> Next.js
</Label>
<Label>
<Radio value="vite" /> Vite
</Label>
<Label>
<Radio value="astro" /> Astro
</Label>
</RadioGroup>API Reference
RadioGroup
Root component. Includes flex column layout.
Radio
Individual radio button. Includes built-in indicator. Also exported as RadioGroupItem.
Examples
For accessible labelling and validation, prefer using the Field component to wrap radio buttons. See the related example: Radio Group field.
Disabled
import { Label } from "mako-ui/components/label";
import { Radio, RadioGroup } from "mako-ui/components/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="next">
<Label>
<Radio value="next" /> Next.js
</Label>
<Label>
<Radio disabled value="vite" /> Vite (disabled)
</Label>
<Label>
<Radio value="astro" /> Astro
</Label>
</RadioGroup>
);
}
With Description
Basic features for personal use.
Advanced tools for professionals.
import { Label } from "mako-ui/components/label";
import { Radio, RadioGroup } from "mako-ui/components/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="r-1">
<div className="flex items-start gap-2">
<Radio id="r-1" value="r-1" />
<div className="flex flex-col gap-1">
<Label htmlFor="r-1">Free</Label>
<p className="text-muted-foreground text-xs">
Basic features for personal use.
</p>
</div>
</div>
<div className="flex items-start gap-2">
<Radio id="r-2" value="r-2" />
<div className="flex flex-col gap-1">
<Label htmlFor="r-2">Pro</Label>
<p className="text-muted-foreground text-xs">
Advanced tools for professionals.
</p>
</div>
</div>
</RadioGroup>
);
}
Card Style
import { Label } from "mako-ui/components/label";
import { Radio, RadioGroup } from "mako-ui/components/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="r-1">
<Label className="flex items-start gap-2 rounded-lg border p-3 hover:bg-accent/50 has-data-checked:border-primary/48 has-data-checked:bg-accent/50">
<Radio value="r-1" />
<div className="flex flex-col gap-1">
<p>Email</p>
<p className="text-muted-foreground text-xs">
Receive notifications via email.
</p>
</div>
</Label>
<Label className="flex items-start gap-2 rounded-lg border p-3 hover:bg-accent/50 has-data-checked:border-primary/48 has-data-checked:bg-accent/50">
<Radio value="r-2" />
<div className="flex flex-col gap-1">
<p>SMS</p>
<p className="text-muted-foreground text-xs">
Receive notifications via text message.
</p>
</div>
</Label>
</RadioGroup>
);
}
Form Integration
"use client";
import { Button } from "mako-ui/components/button";
import { Field, FieldItem, FieldLabel } from "mako-ui/components/field";
import { Fieldset, FieldsetLegend } from "mako-ui/components/fieldset";
import { Form } from "mako-ui/components/form";
import { Radio, RadioGroup } from "mako-ui/components/radio-group";
import type { FormEvent } from "react";
import { useState } from "react";
export default function Particle() {
const [loading, setLoading] = useState(false);
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
setLoading(true);
await new Promise((r) => setTimeout(r, 800));
setLoading(false);
const selected = formData.get("frameworks");
alert(`Selected: ${typeof selected === "string" ? selected : "none"}`);
};
return (
<Form
className="flex w-full max-w-[160px] flex-col gap-4"
onSubmit={onSubmit}
>
<Field
className="gap-2"
name="frameworks"
render={(props) => <Fieldset {...props} />}
>
<FieldsetLegend className="font-medium text-sm">
Frameworks
</FieldsetLegend>
<RadioGroup defaultValue="next">
<FieldItem>
<FieldLabel>
<Radio value="next" /> Next.js
</FieldLabel>
</FieldItem>
<FieldItem>
<FieldLabel>
<Radio value="vite" /> Vite
</FieldLabel>
</FieldItem>
<FieldItem>
<FieldLabel>
<Radio value="astro" /> Astro
</FieldLabel>
</FieldItem>
</RadioGroup>
</Field>
<Button loading={loading} type="submit">
Submit
</Button>
</Form>
);
}