Card
Card primitive
Install
npx ui8kit add cardPulls in: kit-box, recipes, utils
Preview
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-cdnnpx ui8kit add cardcompose/Card.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Card: Box <div> + recipe card. -->
<script lang="ts">
import type { ComponentProps, Snippet } from "svelte";
import Prim from "../kit/ui/box/Box.svelte";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
let { "variant": v_variant, class: className, children, ...rest }: Omit<ComponentProps<typeof Prim>, "tag"> & { "variant"?: string | number; class?: string; children?: Snippet } = $props();
const cls = $derived(cn(rc("card", { "variant": v_variant }), className));
</script>
<Prim tag={"div" as never} class={cls} data-slot="card" {...rest}>{@render children?.()}</Prim>
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-cdnnpx ui8kit add cardcompose/card.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Box as Prim } from "../kit/ui/box/box";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type CardProps = Omit<ComponentProps<typeof Prim>, "tag" | "variant"> & { "variant"?: string | number; className?: string };
/** Card: Box <div> + recipe card. */
export function Card({ "variant": v_variant, className, ...rest }: CardProps) {
return <Prim tag={"div" as never} className={cn(rc("card", { "variant": v_variant }), className)} data-slot="card" {...rest} />;
}
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-cdnnpx ui8kit add cardcompose/Card.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Card: Box <div> + recipe card. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/box/Box.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
defineOptions({ name: "Card", inheritAttrs: false });
const props = defineProps<{ "variant"?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn(rc("card", { "variant": props["variant"] }), attrs.class as string | undefined));
const tagValue = computed(() => "div");
</script>
<template>
<Prim :tag="tagValue as never" :class="cls" data-slot="card" v-bind="rest"><slot /></Prim>
</template>
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-cdnnpx ui8kit add cardcompose/card.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 { Box as Prim } from "../kit/ui/box/box.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type CardProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "variant"> & { "variant"?: string | number; class?: string; className?: string };
/** Card: Box <div> + recipe card. */
export function Card(props: CardProps) {
const [local, rest] = splitProps(props, ["variant", "class", "className"]);
return <Prim tag={"div" as never} class={cn(rc("card", { "variant": local["variant"] }), local.class ?? local.className)} data-slot="card" {...rest} />;
}
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-cdnnpx ui8kit add cardcompose/card.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/box"
// CardProps: Card: Box <div> + recipe card.
type CardProps struct {
Variant string
box.BoxProps
}
func cardInner(p CardProps) box.BoxProps {
in := p.BoxProps
in.Class = Join(Rc("card", map[string]string{"variant": p.Variant}), p.BoxProps.Class)
in.Tag = "div"
in.Attrs = WithAttrs(in.Attrs, map[string]string{"data-slot": "card"})
return in
}
// Card renders Box with the composition classes.
templ Card(p CardProps) {
@box.Box(cardInner(p)) {
{ children... }
}
}
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-cdnnpx ui8kit add cardcompose/Card.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Card: Box <div> + recipe card. Params: variant, class, attrs + the params of Box. #}
{% include 'ui/box/Box.html.twig' with compose_props('Card', _context) only %}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-cdnnpx ui8kit add cardcompose/Card.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Card: Box <div> + recipe card. *}
{parameters
string $class = '',
string $tag = '',
array $attrs = [],
string $children = '',
$variant = null,
}
{include '../ui/box/Box.latte', ...\CodegenX\Compose\Latte\Compose::props('Card', ['class' => $class, 'tag' => $tag, 'attrs' => $attrs, 'children' => $children, 'variant' => $variant])}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-cdnnpx ui8kit add cardcompose/card.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
Card: Box <div> + recipe card. Props (p): Variant, Class, Attrs + the props of Box. -#}
{%- with p = compose_props('Card', p) %}{% include 'ui/box/box.html.j2' %}{% endwith %}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.
No props.