Grid
Grid primitive
Install
npx ui8kit add gridPulls 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 gridcompose/Grid.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Grid: Box + recipe grid. -->
<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 { "cols": v_cols, tag, class: className, children, ...rest }: Omit<ComponentProps<typeof Prim>, "tag"> & { "cols"?: string | number; tag?: string | number; class?: string; children?: Snippet } = $props();
const cls = $derived(cn(rc("grid", { "cols": v_cols }), className));
</script>
<Prim tag={(tag ?? "div") 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 gridcompose/grid.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 GridProps = Omit<ComponentProps<typeof Prim>, "tag" | "cols"> & { "cols"?: string | number; tag?: string; className?: string };
/** Grid: Box + recipe grid. */
export function Grid({ "cols": v_cols, tag, className, ...rest }: GridProps) {
return <Prim tag={(tag ?? "div") as never} className={cn(rc("grid", { "cols": v_cols }), 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 gridcompose/Grid.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Grid: Box + recipe grid. -->
<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: "Grid", inheritAttrs: false });
const props = defineProps<{ "cols"?: string | number; tag?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn(rc("grid", { "cols": props["cols"] }), attrs.class as string | undefined));
const tagValue = computed(() => (props.tag ?? "div"));
</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 gridcompose/grid.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 GridProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "cols"> & { "cols"?: string | number; tag?: string; class?: string; className?: string };
/** Grid: Box + recipe grid. */
export function Grid(props: GridProps) {
const [local, rest] = splitProps(props, ["cols", "tag", "class", "className"]);
return <Prim tag={(local.tag ?? "div") as never} class={cn(rc("grid", { "cols": local["cols"] }), 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 gridcompose/grid.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"
// GridProps: Grid: Box + recipe grid.
type GridProps struct {
Cols string
box.BoxProps
}
func gridInner(p GridProps) box.BoxProps {
in := p.BoxProps
in.Class = Join(Rc("grid", map[string]string{"cols": p.Cols}), p.BoxProps.Class)
in.Tag = Or(in.Tag, "div")
return in
}
// Grid renders Box with the composition classes.
templ Grid(p GridProps) {
@box.Box(gridInner(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 gridcompose/Grid.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Grid: Box + recipe grid. Params: cols, tag, class, attrs + the params of Box. #}
{% include 'ui/box/Box.html.twig' with compose_props('Grid', _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 gridcompose/Grid.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Grid: Box + recipe grid. *}
{parameters
string $class = '',
string $tag = '',
array $attrs = [],
string $children = '',
$cols = null,
}
{include '../ui/box/Box.latte', ...\CodegenX\Compose\Latte\Compose::props('Grid', ['class' => $class, 'tag' => $tag, 'attrs' => $attrs, 'children' => $children, 'cols' => $cols])}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 gridcompose/grid.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
Grid: Box + recipe grid. Props (p): Cols, Tag, Class, Attrs + the props of Box. -#}
{%- with p = compose_props('Grid', 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.