primitives

Table

Table — базовый примитив RevueUI (Reka UI + shadcn-совместимый API).

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

src/ui/table/Table.vue

<!-- Presentational: обычные HTML-элементы, Radix/Reka-примитива нет. -->
<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  /** Доп. классы. Имя `class` — соглашение shadcn-vue (не `className`). */
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <div data-slot="table-container" class="cn-table-container">
    <table data-slot="table" :class="cn('cn-table', props.class)">
      <slot />
    </table>
  </div>
</template>

src/ui/table/TableBody.vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <tbody data-slot="table-body" :class="cn('cn-table-body', props.class)">
    <slot />
  </tbody>
</template>

src/ui/table/TableCaption.vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <caption data-slot="table-caption" :class="cn('cn-table-caption', props.class)">
    <slot />
  </caption>
</template>

src/ui/table/TableCell.vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <td data-slot="table-cell" :class="cn('cn-table-cell', props.class)">
    <slot />
  </td>
</template>

src/ui/table/TableFooter.vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <tfoot data-slot="table-footer" :class="cn('cn-table-footer', props.class)">
    <slot />
  </tfoot>
</template>

src/ui/table/TableHead.vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <th data-slot="table-head" :class="cn('cn-table-head', props.class)">
    <slot />
  </th>
</template>

src/ui/table/TableHeader.vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <thead data-slot="table-header" :class="cn('cn-table-header', props.class)">
    <slot />
  </thead>
</template>

src/ui/table/TableRow.vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"

const props = defineProps<{
  class?: HTMLAttributes["class"]
}>()
</script>

<template>
  <tr data-slot="table-row" :class="cn('cn-table-row has-aria-expanded:bg-muted/50', props.class)">
    <slot />
  </tr>
</template>

src/ui/table/index.ts

export { default as Table } from "./Table.vue"
export { default as TableHeader } from "./TableHeader.vue"
export { default as TableBody } from "./TableBody.vue"
export { default as TableFooter } from "./TableFooter.vue"
export { default as TableRow } from "./TableRow.vue"
export { default as TableHead } from "./TableHead.vue"
export { default as TableCell } from "./TableCell.vue"
export { default as TableCaption } from "./TableCaption.vue"

Установка

npx shadcn-vue@latest add https://revueui.rootapi.dev/r/table.json

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

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