feat: add Checkbox and Radio field families

This commit is contained in:
maoyingjie
2026-10-22 09:15:27 +08:00
parent a4fb3c550a
commit bcadbeaf8c
75 changed files with 5293 additions and 22 deletions
@@ -0,0 +1,122 @@
<script setup lang="ts">
import {
RadioGroup,
RadioContent,
RadioControl,
RadioIndicator,
Radio,
Label,
Description,
} from "@heroui-vue/components";
import {
IconBrandMastercard,
IconBrandVisa,
IconBrandPaypal,
} from "@tabler/icons-vue";
const deliveryOptions = [
{
description: "4–10 个工作日",
price: "$5.00",
title: "标准",
value: "standard",
},
{
description: "2–5 个工作日",
price: "$16.00",
title: "快递",
value: "express",
},
{
description: "1 个工作日",
price: "$25.00",
title: "极速",
value: "super-fast",
},
];
const paymentOptions = [
{
description: "有效期至 2026/01",
icon: IconBrandMastercard,
title: "**** 8304",
value: "mastercard",
},
{
description: "有效期至 2026/01",
icon: IconBrandVisa,
title: "**** 0123",
value: "visa",
},
{
description: "使用 PayPal 支付",
icon: IconBrandPaypal,
title: "PayPal",
value: "paypal",
},
];
</script>
<template>
<div
class="flex w-full flex-col items-center gap-10"
style="
--accent: #006fee;
--accent-foreground: #fff;
--accent-hover: #006fee;
--border-width: 2px;
--border-width-field: 2px;
--focus: #006fee;
"
>
<section class="flex w-full max-w-lg flex-col gap-4">
<RadioGroup default-value="express" name="delivery" variant="secondary">
<Label>配送方式</Label>
<div class="grid gap-x-4 md:grid-cols-3">
<Radio
v-for="option in deliveryOptions"
:key="option.value"
:value="option.value"
>
<RadioContent
class="group relative flex w-full flex-col gap-6 rounded-xl border border-transparent bg-surface px-5 py-4 transition-all data-[selected=true]:border-accent data-[selected=true]:bg-accent/10 data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10"
>
<RadioControl class="absolute end-4 top-3 size-5">
<RadioIndicator />
</RadioControl>
<div class="flex flex-col gap-1">
<span>{{ option.title }}</span>
<Description>{{ option.description }}</Description>
</div>
<span class="text-sm font-semibold">{{ option.price }}</span>
</RadioContent>
</Radio>
</div>
</RadioGroup>
</section>
<section class="flex w-full max-w-lg flex-col gap-4">
<RadioGroup default-value="visa" name="payment" variant="secondary">
<div class="flex flex-wrap items-center justify-between gap-4">
<Label>支付方式</Label>
</div>
<div class="grid gap-x-4 md:grid-cols-2">
<Radio
v-for="option in paymentOptions"
:key="option.value"
:value="option.value"
>
<RadioContent
class="group relative flex w-full flex-row items-start justify-start gap-4 rounded-xl border border-transparent bg-surface px-5 py-4 transition-all data-[selected=true]:border-accent data-[selected=true]:bg-accent/10"
>
<RadioControl class="absolute end-4 top-3 size-5">
<RadioIndicator />
</RadioControl>
<component :is="option.icon" class="size-6" aria-hidden="true" />
<div class="flex flex-col gap-1">
<span>{{ option.title }}</span>
<Description>{{ option.description }}</Description>
</div>
</RadioContent>
</Radio>
</div>
</RadioGroup>
</section>
</div>
</template>