/* Copyright 2026 Marimo. All rights reserved. */ import { type JSX, useId } from "react"; import { z } from "zod"; import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import type { IPlugin, IPluginProps } from "@/plugins/types"; import { cn } from "@/utils/cn"; import { Labeled } from "./common/labeled"; /** * Arguments for a radio group * * @param label - a label for the group * @param options - text labels for each radio option */ interface Data { label: string | null; inline: boolean; options: string[]; disabled?: boolean; } // The value is null when `initialValue` is null type S = string | null; export class RadioPlugin implements IPlugin { tagName = "marimo-radio"; validator = z.object({ initialValue: z.string().nullable(), inline: z.boolean().default(false), label: z.string().nullable(), options: z.array(z.string()), disabled: z.boolean().optional(), }); render(props: IPluginProps): JSX.Element { return ( ); } } interface RadioProps extends Data { value: S; setValue: (value: S) => void; } export const Radio = (props: RadioProps): JSX.Element => { const id = useId(); return ( {props.options.map((option, i) => (
))}
); };