Skip to content
ui8kit

primitive / primitives

List Item

List Item primitive

Install

npx ui8kit add list-item

Pulls in: kit-box, recipes, utils

Preview

default
  • 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-cdn
    npx ui8kit add list-item
    compose/ListItem.svelte
    <!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
    <!-- ListItem: Box <li>. -->
    <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 { class: className, children, ...rest }: Omit<ComponentProps<typeof Prim>, "tag"> & { class?: string; children?: Snippet } = $props();
      const cls = $derived(cn(className));
    </script>
    
    <Prim tag={"li" as never} class={cls} {...rest}>{@render children?.()}</Prim>
    

    Svelte registry item (JSON)

    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-cdn
    npx ui8kit add list-item
    compose/list-item.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 ListItemProps = Omit<ComponentProps<typeof Prim>, "tag"> & { className?: string };
    
    /** ListItem: Box <li>. */
    export function ListItem({ className, ...rest }: ListItemProps) {
      return <Prim tag={"li" as never} className={cn(className)} {...rest} />;
    }
    

    React registry item (JSON)

    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-cdn
    npx ui8kit add list-item
    compose/ListItem.vue
    <!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
    <!-- ListItem: Box <li>. -->
    <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: "ListItem", inheritAttrs: false });
    const props = defineProps<{  }>();
    const attrs = useAttrs();
    const rest = computed(() => {
      const { class: _class, ...r } = attrs;
      return r;
    });
    const cls = computed(() => cn(attrs.class as string | undefined));
    const tagValue = computed(() => "li");
    </script>
    
    <template>
      <Prim :tag="tagValue as never" :class="cls" v-bind="rest"><slot /></Prim>
    </template>
    

    Vue registry item (JSON)

    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-cdn
    npx ui8kit add list-item
    compose/list-item.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 ListItemProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className"> & { class?: string; className?: string };
    
    /** ListItem: Box <li>. */
    export function ListItem(props: ListItemProps) {
      const [local, rest] = splitProps(props, ["class", "className"]);
      return <Prim tag={"li" as never} class={cn(local.class ?? local.className)} {...rest} />;
    }
    

    Solid registry item (JSON)

    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-cdn
    npx ui8kit add list-item
    compose/list-item.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"
    
    // ListItemProps: ListItem: Box <li>.
    type ListItemProps struct {
    	box.BoxProps
    }
    
    func listItemInner(p ListItemProps) box.BoxProps {
    	in := p.BoxProps
    	in.Class = Join(p.BoxProps.Class)
    	in.Tag = "li"
    	return in
    }
    
    // ListItem renders Box with the composition classes.
    templ ListItem(p ListItemProps) {
    	@box.Box(listItemInner(p)) {
    		{ children... }
    	}
    }
    

    templ registry item (JSON)

    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-cdn
    npx ui8kit add list-item
    compose/ListItem.html.twig
    {# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
    {# ListItem: Box <li>. Params: class, attrs + the params of Box. #}
    {% include 'ui/box/Box.html.twig' with compose_props('ListItem', _context) only %}

    Twig registry item (JSON)

    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-cdn
    npx ui8kit add list-item
    compose/ListItem.latte
    {* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
    {* ListItem: Box <li>. *}
    {parameters
      string $class = '',
      string $tag = '',
      array $attrs = [],
      string $children = '',
    }
    {include '../ui/box/Box.latte', ...\CodegenX\Compose\Latte\Compose::props('ListItem', ['class' => $class, 'tag' => $tag, 'attrs' => $attrs, 'children' => $children])}

    Latte registry item (JSON)

    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-cdn
    npx ui8kit add list-item
    compose/list-item.html.j2
    {#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
        ListItem: Box <li>. Props (p): Class, Attrs + the props of Box. -#}
    {%- with p = compose_props('ListItem', p) %}{% include 'ui/box/box.html.j2' %}{% endwith %}

    Jinja2 registry item (JSON)

    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.