radio-group

Radio group with grid layout

Radio group with grid layout

Загрузка превью…

src/radio-group/c-radio-group-11.vue

<!--
  Расхождение с апстримом: `IconPlaceholder` заменена инлайновым `<svg>`
  (lucide-react v0.545.0 "circle-dollar-sign"/"file-text"/"credit-card"/
  "chart-no-axes-column-decreasing") — см. docs/PORTING.md §5. Исходный
  `items.map(...)` развёрнут в явную разметку: массив хранил JSX-иконки
  напрямую (`ReactNode`), для чего во Vue нет дешёвого эквивалента
  (правило 2), а развёрнутая разметка даёт идентичный DOM (тот же приём,
  что и c-checkbox-14.vue).
-->
<script setup lang="ts">
import { Field, FieldLabel, FieldTitle } from "@/components/ui/field"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
</script>

<template>
  <RadioGroup default-value="payments" class="grid w-full max-w-xs grid-cols-2 gap-4">
    <FieldLabel for="payments" class="relative p-0!">
      <Field orientation="horizontal">
        <div class="absolute top-3 right-3">
          <RadioGroupItem value="payments" id="payments" />
        </div>
        <FieldTitle class="flex flex-col items-start">
          <div class="bg-background border-border rounded-2xl flex shrink-0 items-center justify-center border p-2 shadow-xs shadow-black/5">
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
              aria-hidden="true"
              class="lucide lucide-circle-dollar-sign size-4"
            >
              <circle cx="12" cy="12" r="10" />
              <path d="M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8" />
              <path d="M12 18V6" />
            </svg>
          </div>
          <div class="flex flex-col items-start gap-0.5">
            <span class="text-sm font-semibold">Payments</span>
            <span class="text-muted-foreground text-xs">Receive payments from your customers</span>
          </div>
        </FieldTitle>
      </Field>
    </FieldLabel>
    <FieldLabel for="invoices" class="relative p-0!">
      <Field orientation="horizontal">
        <div class="absolute top-3 right-3">
          <RadioGroupItem value="invoices" id="invoices" />
        </div>
        <FieldTitle class="flex flex-col items-start">
          <div class="bg-background border-border rounded-2xl flex shrink-0 items-center justify-center border p-2 shadow-xs shadow-black/5">
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
              aria-hidden="true"
              class="lucide lucide-file-text size-4"
            >
              <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" />
              <path d="M14 2v4a2 2 0 0 0 2 2h4" />
              <path d="M10 9H8" />
              <path d="M16 13H8" />
              <path d="M16 17H8" />
            </svg>
          </div>
          <div class="flex flex-col items-start gap-0.5">
            <span class="text-sm font-semibold">Invoices</span>
            <span class="text-muted-foreground text-xs">Create and send invoices to your customers</span>
          </div>
        </FieldTitle>
      </Field>
    </FieldLabel>
    <FieldLabel for="billing" class="relative p-0!">
      <Field orientation="horizontal">
        <div class="absolute top-3 right-3">
          <RadioGroupItem value="billing" id="billing" />
        </div>
        <FieldTitle class="flex flex-col items-start">
          <div class="bg-background border-border rounded-2xl flex shrink-0 items-center justify-center border p-2 shadow-xs shadow-black/5">
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
              aria-hidden="true"
              class="lucide lucide-credit-card size-4"
            >
              <rect width="20" height="14" x="2" y="5" rx="2" />
              <line x1="2" x2="22" y1="10" y2="10" />
            </svg>
          </div>
          <div class="flex flex-col items-start gap-0.5">
            <span class="text-sm font-semibold">Billing</span>
            <span class="text-muted-foreground text-xs">Manage your billing and subscriptions</span>
          </div>
        </FieldTitle>
      </Field>
    </FieldLabel>
    <FieldLabel for="reports" class="relative p-0!">
      <Field orientation="horizontal">
        <div class="absolute top-3 right-3">
          <RadioGroupItem value="reports" id="reports" />
        </div>
        <FieldTitle class="flex flex-col items-start">
          <div class="bg-background border-border rounded-2xl flex shrink-0 items-center justify-center border p-2 shadow-xs shadow-black/5">
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
              aria-hidden="true"
              class="lucide lucide-chart-no-axes-column-decreasing size-4"
            >
              <path d="M5 21V3" />
              <path d="M12 21V9" />
              <path d="M19 21v-6" />
            </svg>
          </div>
          <div class="flex flex-col items-start gap-0.5">
            <span class="text-sm font-semibold">Reports</span>
            <span class="text-muted-foreground text-xs">View your reports and analytics</span>
          </div>
        </FieldTitle>
      </Field>
    </FieldLabel>
  </RadioGroup>
</template>

Установка

npx shadcn-vue@latest add https://revueui.rootapi.dev/r/c-radio-group-11.json

Зависимости реестра

Источник: порт из ReUI (Keenthemes, MIT)