Card Title
Card Title primitive
Install
npx ui8kit add card-titlePulls in: kit-text, 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 card-titlecompose/CardTitle.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- CardTitle: Text. -->
<script lang="ts">
import type { ComponentProps, Snippet } from "svelte";
import Prim from "../kit/ui/text/Text.svelte";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
let { as, class: className, children, ...rest }: Omit<ComponentProps<typeof Prim>, "tag"> & { as?: string | number; class?: string; children?: Snippet } = $props();
const cls = $derived(cn("font-semibold leading-none", className));
</script>
<Prim tag={(as && Number(as) >= 1 && Number(as) <= 6 ? `h${as}` : "h3") as never} class={cls} {...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 card-titlecompose/card-title.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Text as Prim } from "../kit/ui/text/text";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type CardTitleProps = Omit<ComponentProps<typeof Prim>, "tag"> & { as?: number | string; className?: string };
/** CardTitle: Text. */
export function CardTitle({ as, className, ...rest }: CardTitleProps) {
return <Prim tag={(as && Number(as) >= 1 && Number(as) <= 6 ? `h${as}` : "h3") as never} className={cn("font-semibold leading-none", className)} {...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 card-titlecompose/CardTitle.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- CardTitle: Text. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/text/Text.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
defineOptions({ name: "CardTitle", inheritAttrs: false });
const props = defineProps<{ as?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn("font-semibold leading-none", attrs.class as string | undefined));
const tagValue = computed(() => (props.as && Number(props.as) >= 1 && Number(props.as) <= 6 ? `h${props.as}` : "h3"));
</script>
<template>
<Prim :tag="tagValue as never" :class="cls" 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 card-titlecompose/card-title.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 { Text as Prim } from "../kit/ui/text/text.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type CardTitleProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className"> & { as?: number | string; class?: string; className?: string };
/** CardTitle: Text. */
export function CardTitle(props: CardTitleProps) {
const [local, rest] = splitProps(props, ["as", "class", "className"]);
return <Prim tag={(local.as && Number(local.as) >= 1 && Number(local.as) <= 6 ? `h${local.as}` : "h3") as never} class={cn("font-semibold leading-none", local.class ?? local.className)} {...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 card-titlecompose/card-title.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/text"
// CardTitleProps: CardTitle: Text.
type CardTitleProps struct {
// As — heading level 1..6 (h1..h6), else h3
As string
text.TextProps
}
func cardTitleInner(p CardTitleProps) text.TextProps {
in := p.TextProps
in.Class = Join("font-semibold leading-none", p.TextProps.Class)
in.Tag = Heading(p.As, "h3")
return in
}
// CardTitle renders Text with the composition classes.
templ CardTitle(p CardTitleProps) {
@text.Text(cardTitleInner(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 card-titlecompose/CardTitle.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# CardTitle: Text. Params: as, class, attrs + the params of Text. #}
{% include 'ui/text/Text.html.twig' with compose_props('CardTitle', _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 card-titlecompose/CardTitle.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* CardTitle: Text. *}
{parameters
string $class = '',
string $tag = '',
array $attrs = [],
string $children = '',
$as = null,
}
{include '../ui/text/Text.latte', ...\CodegenX\Compose\Latte\Compose::props('CardTitle', ['class' => $class, 'tag' => $tag, 'attrs' => $attrs, 'children' => $children, 'as' => $as])}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 card-titlecompose/card-title.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
CardTitle: Text. Props (p): As, Class, Attrs + the props of Text. -#}
{%- with p = compose_props('CardTitle', p) %}{% include 'ui/text/text.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.