Skip to content
ui8kit

primitive / primitives

Radio

Radio primitive

Install

npx ui8kit add radio

Pulls in: kit-radio, recipes, utils

Preview

size: default
size: sm
variant: default
variant: ghost

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add radio
compose/Radio.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Radio: Radio + recipe radio. -->
<script lang="ts">
  import type { ComponentProps, Snippet } from "svelte";
  import Prim from "../kit/ui/radio/Radio.svelte";
  import { cn } from "../kit/utils";
  import { rc } from "./recipes";

  let { "size": v_size, "variant": v_variant, class: className, children, ...rest }: ComponentProps<typeof Prim> & { "size"?: string | number; "variant"?: string | number; class?: string; children?: Snippet } = $props();
  const cls = $derived(cn(rc("radio", { "size": v_size, "variant": v_variant }), className));
</script>

<Prim class={cls} {...rest} />

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add radio
compose/radio.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Radio as Prim } from "../kit/ui/radio/radio";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type RadioProps = Omit<ComponentProps<typeof Prim>, "tag" | "size" | "variant"> & { "size"?: string | number; "variant"?: string | number; className?: string };

/** Radio: Radio + recipe radio. */
export function Radio({ "size": v_size, "variant": v_variant, className, ...rest }: RadioProps) {
  return <Prim className={cn(rc("radio", { "size": v_size, "variant": v_variant }), className)} {...rest} />;
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add radio
compose/Radio.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Radio: Radio + recipe radio. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/radio/Radio.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

defineOptions({ name: "Radio", inheritAttrs: false });
const props = defineProps<{ "size"?: string | number; "variant"?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
  const { class: _class, ...r } = attrs;
  return r;
});
const cls = computed(() => cn(rc("radio", { "size": props["size"], "variant": props["variant"] }), attrs.class as string | undefined));
const tagValue = computed(() => "");
</script>

<template>
  <Prim :class="cls" v-bind="rest" />
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add radio
compose/radio.solid.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import { splitProps, type ComponentProps } from "solid-js";
import { Radio as Prim } from "../kit/ui/radio/radio.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type RadioProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "size" | "variant"> & { "size"?: string | number; "variant"?: string | number; class?: string; className?: string };

/** Radio: Radio + recipe radio. */
export function Radio(props: RadioProps) {
  const [local, rest] = splitProps(props, ["size", "variant", "class", "className"]);
  return <Prim class={cn(rc("radio", { "size": local["size"], "variant": local["variant"] }), local.class ?? local.className)} {...rest} />;
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add radio
compose/radio.templ
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.

package compose

import "github.com/ui8kit/codegen/generated/templ/ui/radio"

// RadioProps: Radio: Radio + recipe radio.
type RadioProps struct {
	Size string
	Variant string
	radio.RadioProps
}

func radioInner(p RadioProps) radio.RadioProps {
	in := p.RadioProps
	in.Class = Join(Rc("radio", map[string]string{"size": p.Size, "variant": p.Variant}), p.RadioProps.Class)
	return in
}

// Radio renders Radio with the composition classes.
templ Radio(p RadioProps) {
	@radio.Radio(radioInner(p))
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add radio
compose/Radio.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Radio: Radio + recipe radio. Params: size, variant, class, attrs + the params of Radio. #}
{% include 'ui/radio/Radio.html.twig' with compose_props('Radio', _context) only %}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add radio
compose/Radio.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Radio: Radio + recipe radio. *}
{parameters
  string $class = '',
  ?string $id = null,
  ?string $name = null,
  ?string $value = null,
  bool $checked = false,
  bool $required = false,
  bool $disabled = false,
  ?string $ariaInvalid = null,
  ?string $ariaDescribedBy = null,
  array $attrs = [],
  $size = null,
  $variant = null,
}
{include '../ui/radio/Radio.latte', ...\CodegenX\Compose\Latte\Compose::props('Radio', ['class' => $class, 'id' => $id, 'name' => $name, 'value' => $value, 'checked' => $checked, 'required' => $required, 'disabled' => $disabled, 'ariaInvalid' => $ariaInvalid, 'ariaDescribedBy' => $ariaDescribedBy, 'attrs' => $attrs, 'size' => $size, 'variant' => $variant])}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add radio
compose/radio.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
    Radio: Radio + recipe radio. Props (p): Size, Variant, Class, Attrs + the props of Radio. -#}
{%- with p = compose_props('Radio', p) %}{% include 'ui/radio/radio.html.j2' %}{% endwith %}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

Radio renders input[type=radio].

Props of Radio
PropTypeDefault Description
checked boolean-
required boolean-
disabled boolean-