native-select
shadcn-solidjs/native-selectFreeComponent
shadcn-solidjs publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn-solidjs on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-solidjs.com/r/native-select.jsonSource
1import { cn } from "~/lib/utils.ts";2import IconChevronDown from "~icons/lucide/chevron-down";34import type { Component, ComponentProps } from "solid-js";56import { splitProps } from "solid-js";78// `size` on a native select is the number of visible rows; the design system9// uses it for the control height instead, so the native attribute is omitted10// exactly like upstream does.11type NativeSelectProps =12 & Omit<ComponentProps<"select">, "size">13 & { size?: "sm" | "default" };1415const NativeSelect: Component<NativeSelectProps> = (props) => {16 const [local, others] = splitProps(props, ["class", "size"]);17 return (18 <div19 class={cn(20 "group/native-select relative w-fit has-[select:disabled]:opacity-50",21 local.class,22 )}23 data-slot="native-select-wrapper"24 data-size={local.size ?? "default"}25 >26 <select27 data-slot="native-select"28 data-size={local.size ?? "default"}29 class="h-8 w-full min-w-0 appearance-none rounded-lg border border-input bg-transparent py-1 pr-8 pl-2.5 text-sm transition-colors select-none placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5 outline-none disabled:pointer-events-none disabled:cursor-not-allowed"30 {...others}31 />32 <IconChevronDown33 class="top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground pointer-events-none absolute select-none"34 aria-hidden="true"35 data-slot="native-select-icon"36 />37 </div>38 );39};4041const NativeSelectOption: Component<ComponentProps<"option">> = (props) => {42 const [local, others] = splitProps(props, ["class"]);43 return (44 <option45 data-slot="native-select-option"46 class={cn("bg-[Canvas] text-[CanvasText]", local.class)}47 {...others}48 />49 );50};5152const NativeSelectOptGroup: Component<ComponentProps<"optgroup">> = (props) => {53 const [local, others] = splitProps(props, ["class"]);54 return (55 <optgroup56 data-slot="native-select-optgroup"57 class={cn("bg-[Canvas] text-[CanvasText]", local.class)}58 {...others}59 />60 );61};6263// … truncated
More from shadcn-solidjs
All 85 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn-solidjs | Components | Free | 1 dep | |
| alertalert | shadcn-solidjs | Components | Free | 2 deps | |
| alert-dialogalert-dialog | shadcn-solidjs | Components | Free | 2 deps | |
| aspect-ratioaspect-ratio | shadcn-solidjs | Components | Free | no deps | |
| attachmentattachment | shadcn-solidjs | Components | Free | 2 deps | |
| avataravatar | shadcn-solidjs | Components | Free | 1 dep | |
| badgebadge | shadcn-solidjs | Components | Free | 2 deps | |
| breadcrumbbreadcrumb | shadcn-solidjs | Components | Free | 1 dep |
