Select
optics/selectFreeComponent
Displays a list of options for the user to pick from.
See it running
Open the demo on optics
optics.agusmayol.com.ar/components/selectInstall it
npx shadcn@latest add https://optics.agusmayol.com.ar/r/select.jsonSource
1"use client";23import * as React from "react";4import { Select as SelectPrimitive } from "@base-ui/react/select";56import { cn } from "@/lib/utils";7import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react";8import { buttonVariants } from "@/registry/optics/button";910const Select = SelectPrimitive.Root;1112function SelectGroup({ className = "", ...props }) {13 return (14 <SelectPrimitive.Group15 data-slot="select-group"16 className={cn("scroll-my-1 p-1", className)}17 {...props}18 />19 );20}2122function SelectValue({ className = "", ...props }) {23 return (24 <SelectPrimitive.Value25 data-slot="select-value"26 className={cn("flex flex-1 text-left", className)}27 {...props}28 />29 );30}3132function SelectTrigger({33 className = "",34 size = "default",35 variant = "raised",36 children = null,37 ...props38}) {39 return (40 <SelectPrimitive.Trigger41 data-slot="select-trigger"42 data-size={size}43 className={cn(44 "border-input data-[placeholder]:text-muted-foreground bg-input/20 dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-md border px-2 py-1.5 text-xs/relaxed transition-colors focus-visible:ring-[2px] aria-invalid:ring-[2px] data-[size=default]:h-7 data-[size=sm]:h-6 *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-3.5 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",45 className,46 variant &&47 buttonVariants({48 variant,49 animation: "colors",50 }),51 )}52 {...props}53 >54 {children}55 <SelectPrimitive.Icon56 render={57 <ChevronDownIcon className="text-muted-foreground size-3.5 pointer-events-none" />58 }59 />60 </SelectPrimitive.Trigger>61 );62}6364function SelectContent({65 className = "",66 children = null,67 side = "bottom",68 sideOffset = 4,69 align = "center",70 alignOffset = 0,71 alignItemWithTrigger = false,72 ...props73}) {74 return (75 <SelectPrimitive.Portal>76 <SelectPrimitive.Positioner77 side={side}78 sideOffset={sideOffset}79 align={align}80 alignOffset={alignOffset}81 alignItemWithTrigger={alignItemWithTrigger}82 collisionPadding={8}83// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from optics
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | optics | Components | Free | 5 deps | |
| Alertalert | optics | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | optics | Components | Free | 4 deps | |
| Aspect Ratioaspect-ratio | optics | Components | Free | 2 deps | |
| Auto Heightauto-height | optics | Components | Free | 3 deps | |
| Avataravatar | optics | Components | Free | 3 deps | |
| Badgebadge | optics | Components | Free | 4 deps | |
| Breadcrumbbreadcrumb | optics | Components | Free | 4 deps |
