Select
Select primitive
Install
npx ui8kit add selectPulls in: kit-select, 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 selectcompose/Select.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Select: Select + recipe select. -->
<script lang="ts">
import type { ComponentProps, Snippet } from "svelte";
import Prim from "../kit/ui/select/Select.svelte";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
let { "size": v_size, "variant": v_variant, "state": v_state, class: className, children, ...rest }: ComponentProps<typeof Prim> & { "size"?: string | number; "variant"?: string | number; "state"?: string | number; class?: string; children?: Snippet } = $props();
const cls = $derived(cn(rc("select", { "size": v_size, "variant": v_variant, "state": v_state }), className));
</script>
<Prim class={cls} aria-invalid={v_state === "error" ? "true" : undefined} {...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 selectcompose/select.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Select as Prim } from "../kit/ui/select/select";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type SelectProps = Omit<ComponentProps<typeof Prim>, "tag" | "size" | "variant" | "state"> & { "size"?: string | number; "variant"?: string | number; "state"?: string | number; className?: string };
/** Select: Select + recipe select. */
export function Select({ "size": v_size, "variant": v_variant, "state": v_state, className, ...rest }: SelectProps) {
return <Prim className={cn(rc("select", { "size": v_size, "variant": v_variant, "state": v_state }), className)} aria-invalid={v_state === "error" ? "true" : undefined} {...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 selectcompose/Select.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Select: Select + recipe select. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/select/Select.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
defineOptions({ name: "Select", inheritAttrs: false });
const props = defineProps<{ "size"?: string | number; "variant"?: string | number; "state"?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn(rc("select", { "size": props["size"], "variant": props["variant"], "state": props["state"] }), attrs.class as string | undefined));
const tagValue = computed(() => "");
</script>
<template>
<Prim :class="cls" :aria-invalid="props.state === 'error' ? 'true' : undefined" 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 selectcompose/select.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 { Select as Prim } from "../kit/ui/select/select.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type SelectProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "size" | "variant" | "state"> & { "size"?: string | number; "variant"?: string | number; "state"?: string | number; class?: string; className?: string };
/** Select: Select + recipe select. */
export function Select(props: SelectProps) {
const [local, rest] = splitProps(props, ["size", "variant", "state", "class", "className"]);
return <Prim class={cn(rc("select", { "size": local["size"], "variant": local["variant"], "state": local["state"] }), local.class ?? local.className)} aria-invalid={local["state"] === "error" ? "true" : undefined} {...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 selectcompose/select.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/select"
// SelectProps: Select: Select + recipe select.
type SelectProps struct {
Size string
Variant string
State string
selectfield.SelectProps
}
func selectInner(p SelectProps) selectfield.SelectProps {
in := p.SelectProps
in.Class = Join(Rc("select", map[string]string{"size": p.Size, "variant": p.Variant, "state": p.State}), p.SelectProps.Class)
if p.State == "error" {
in.AriaInvalid = Or(in.AriaInvalid, "true")
}
return in
}
// Select renders Select with the composition classes.
templ Select(p SelectProps) {
@selectfield.Select(selectInner(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 selectcompose/Select.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Select: Select + recipe select. Params: size, variant, state, class, attrs + the params of Select. #}
{% include 'ui/select/Select.html.twig' with compose_props('Select', _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 selectcompose/Select.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Select: Select + recipe select. *}
{parameters
string $class = '',
?string $id = null,
?string $name = null,
string $value = '',
bool $multiple = false,
bool $required = false,
bool $disabled = false,
array $options = [],
?string $ariaInvalid = null,
?string $ariaDescribedBy = null,
array $attrs = [],
string $children = '',
$size = null,
$variant = null,
$state = null,
}
{include '../ui/select/Select.latte', ...\CodegenX\Compose\Latte\Compose::props('Select', ['class' => $class, 'id' => $id, 'name' => $name, 'value' => $value, 'multiple' => $multiple, 'required' => $required, 'disabled' => $disabled, 'options' => $options, 'ariaInvalid' => $ariaInvalid, 'ariaDescribedBy' => $ariaDescribedBy, 'attrs' => $attrs, 'children' => $children, 'size' => $size, 'variant' => $variant, 'state' => $state])}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 selectcompose/select.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
Select: Select + recipe select. Props (p): Size, Variant, State, Class, Attrs + the props of Select. -#}
{%- with p = compose_props('Select', p) %}{% include 'ui/select/select.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.
Select renders option children from Options, then manual children.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | selected option value |
| multiple | boolean | - | |
| required | boolean | - | |
| disabled | boolean | - | |
| options | items | - |