radio.tsx 848 B

12345678910111213141516171819202122232425262728
  1. "use client";
  2. import type { ComponentRenderProps } from "./types";
  3. import { baseClass, getCustomClass } from "./utils";
  4. export function Radio({ element }: ComponentRenderProps) {
  5. const { props } = element;
  6. const customClass = getCustomClass(props);
  7. const options = (props.options as string[]) || [];
  8. return (
  9. <div className={`space-y-1 ${baseClass} ${customClass}`}>
  10. {props.label ? (
  11. <div className="text-[10px] text-muted-foreground mb-1 text-left">
  12. {props.label as string}
  13. </div>
  14. ) : null}
  15. {options.map((opt, i) => (
  16. <label key={i} className="flex items-center gap-2 text-xs">
  17. <div
  18. className={`w-3.5 h-3.5 border border-border rounded-full ${i === 0 ? "bg-foreground" : "bg-card"}`}
  19. />
  20. {opt}
  21. </label>
  22. ))}
  23. </div>
  24. );
  25. }