The Coline design system: accessible React components for Coline Apps, themed live by the host workspace, and for Coline Sites in light and dark. Tailwind v4 stylesheet included. MIT.
| 5 | import { IconCheck, IconChevronDown, IconChevronUp, IconSelector } from "@tabler/icons-react"; |
| 6 |
| 7 | import { liquidMenuSurfaceClasses } from "./liquid-menu-surface"; |
| 8 | import { cn } from "../lib/utils"; |
| 9 |
| 10 | const contentClasses = cn( |
| 11 | "relative z-50 overflow-x-hidden overflow-y-auto p-1", |
| 12 | liquidMenuSurfaceClasses, |
| 13 | ); |
| 14 |
| 15 | // ── Primitives ────────────────────────────────────────────────────────────── |
| 16 |
| 17 | function Select({ |
| 18 | ...props |
| 19 | }: React.ComponentProps<typeof SelectPrimitive.Root>) { |
| 20 | return <SelectPrimitive.Root data-slot="select" {...props} />; |
| 21 | } |
| 22 |
| 23 | function SelectGroup({ |
| 24 | className, |
| 25 | ...props |
| 26 | }: React.ComponentProps<typeof SelectPrimitive.Group>) { |
| 27 | return ( |
| 28 | <SelectPrimitive.Group |
| 29 | data-slot="select-group" |
| 30 | className={cn("scroll-my-1", className)} |
| 31 | {...props} |
| 32 | /> |
| 33 | ); |
| 34 | } |
| 35 |
| 36 | function SelectValue({ |
| 37 | ...props |
| 38 | }: React.ComponentProps<typeof SelectPrimitive.Value>) { |
| 39 | return <SelectPrimitive.Value data-slot="select-value" {...props} />; |
| 40 | } |
| 41 |
| 42 | function SelectTrigger({ |
| 43 | className, |
| 44 | size = "default", |
| 45 | children, |
| 46 | ...props |
| 47 | }: React.ComponentProps<typeof SelectPrimitive.Trigger> & { |
| 48 | size?: "sm" | "default"; |
| 49 | }) { |
| 50 | return ( |
| 51 | <SelectPrimitive.Trigger |
| 52 | data-slot="select-trigger" |
| 53 | data-size={size} |
| 54 | className={cn( |
| 55 | "flex w-fit items-center justify-between gap-1.5 rounded-4xl border border-input bg-input/30 px-3 py-2 text-sm whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform] duration-150 ease-out motion-safe:active:scale-[0.98] focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", |
| 56 | className, |
| 57 | )} |
| 58 | {...props} |
| 59 | > |
| 60 | {children} |
| 61 | <SelectPrimitive.Icon asChild> |
| 62 | <IconSelector className="pointer-events-none size-4 text-muted-foreground" /> |
| 63 | </SelectPrimitive.Icon> |
| 64 | </SelectPrimitive.Trigger> |
| 65 | ); |
| 66 | } |
| 67 |
| 68 | function SelectContent({ |
| 69 | className, |
| 70 | children, |
| 71 | position = "item-aligned", |
| 72 | align = "center", |
| 73 | ...props |
| 74 | }: React.ComponentProps<typeof SelectPrimitive.Content>) { |
| 75 | return ( |
| 76 | <SelectPrimitive.Portal> |
| 77 | <SelectPrimitive.Content |
| 78 | data-slot="select-content" |
| 79 | data-align-trigger={position === "item-aligned"} |
| 80 | className={cn( |
| 81 | contentClasses, |
| 82 | "max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) transform-gpu will-change-[opacity,transform] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] data-[state=closed]:overflow-hidden data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", |
| 83 | position === "popper" && |
| 84 | "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", |
| 85 | className, |
| 86 | )} |
| 87 | position={position} |
| 88 | align={align} |
| 89 | {...props} |
| 90 | > |
| 91 | <SelectScrollUpButton /> |
| 92 | <SelectPrimitive.Viewport |
| 93 | data-position={position} |
| 94 | className={cn( |
| 95 | "data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)", |
| 96 | )} |
| 97 | > |
| 98 | {children} |
| 99 | </SelectPrimitive.Viewport> |
| 100 | <SelectScrollDownButton /> |
| 101 | </SelectPrimitive.Content> |
| 102 | </SelectPrimitive.Portal> |
| 103 | ); |
| 104 | } |
| 105 |
| 106 | function SelectLabel({ |
| 107 | className, |
| 108 | ...props |
| 109 | }: React.ComponentProps<typeof SelectPrimitive.Label>) { |
| 110 | return ( |
| 111 | <SelectPrimitive.Label |
| 112 | data-slot="select-label" |
| 113 | className={cn("px-2.5 pt-2 pb-1 text-xs font-medium text-muted-foreground/60", className)} |
| 114 | {...props} |
| 115 | /> |
| 116 | ); |
| 117 | } |
| 118 |
| 119 | function SelectItem({ |
| 120 | className, |
| 121 | children, |
| 122 | ...props |
| 123 | }: React.ComponentProps<typeof SelectPrimitive.Item>) { |
| 124 | return ( |
| 125 | <SelectPrimitive.Item |
| 126 | data-slot="select-item" |
| 127 | className={cn( |
| 128 | "relative flex w-full cursor-default items-center gap-2 rounded-lg py-1.5 pr-8 pl-2.5 text-sm font-medium leading-5 outline-hidden select-none transition-colors duration-100 ease-out focus:bg-black/[0.045] focus:text-accent-foreground dark:focus:bg-white/[0.08] not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg]:text-muted-foreground/75 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", |
| 129 | className, |
| 130 | )} |
| 131 | {...props} |
| 132 | > |
| 133 | <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center"> |
| 134 | <SelectPrimitive.ItemIndicator> |
| 135 | <IconCheck className="pointer-events-none" /> |
| 136 | </SelectPrimitive.ItemIndicator> |
| 137 | </span> |
| 138 | <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText> |
| 139 | </SelectPrimitive.Item> |
| 140 | ); |
| 141 | } |
| 142 |
| 143 | function SelectSeparator({ |
| 144 | className, |
| 145 | ...props |
| 146 | }: React.ComponentProps<typeof SelectPrimitive.Separator>) { |
| 147 | return ( |
| 148 | <SelectPrimitive.Separator |
| 149 | data-slot="select-separator" |
| 150 | className={cn("-mx-1 my-1 h-px bg-border/50", className)} |
| 151 | {...props} |
| 152 | /> |
| 153 | ); |
| 154 | } |
| 155 |
| 156 | function SelectScrollUpButton({ |
| 157 | className, |
| 158 | ...props |
| 159 | }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) { |
| 160 | return ( |
| 161 | <SelectPrimitive.ScrollUpButton |
| 162 | data-slot="select-scroll-up-button" |
| 163 | className={cn( |
| 164 | "z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", |
| 165 | className, |
| 166 | )} |
| 167 | {...props} |
| 168 | > |
| 169 | <IconChevronUp /> |
| 170 | </SelectPrimitive.ScrollUpButton> |
| 171 | ); |
| 172 | } |
| 173 |
| 174 | function SelectScrollDownButton({ |
| 175 | className, |
| 176 | ...props |
| 177 | }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) { |
| 178 | return ( |
| 179 | <SelectPrimitive.ScrollDownButton |
| 180 | data-slot="select-scroll-down-button" |
| 181 | className={cn( |
| 182 | "z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", |
| 183 | className, |
| 184 | )} |
| 185 | {...props} |
| 186 | > |
| 187 | <IconChevronDown /> |
| 188 | </SelectPrimitive.ScrollDownButton> |
| 189 | ); |
| 190 | } |
| 191 |
| 192 | export { |
| 193 | Select, |
| 194 | SelectContent, |
| 195 | SelectGroup, |
| 196 | SelectItem, |
| 197 | SelectLabel, |
| 198 | SelectScrollDownButton, |
| 199 | SelectScrollUpButton, |
| 200 | SelectSeparator, |
| 201 | SelectTrigger, |
| 202 | SelectValue, |
| 203 | }; |
| 204 |