Select (React Select)
blok/select-reactFreeComponent
A feature-rich select component built with React Select, supporting search, multi-select, and custom styling with Blok theming.
Install it
npx shadcn@latest add https://blok.sitecore.com/r/select-react.jsonSource
1"use client";23import { Badge } from "@/components/ui/badge";4import { Icon } from "@/lib/icon";5import { mdiCheck, mdiChevronDown, mdiClose } from "@mdi/js";6import * as React from "react";7import ReactSelect, {8 type Props as ReactSelectProps,9 type GroupBase,10 type StylesConfig,11 type ClassNamesConfig,12 components,13 type DropdownIndicatorProps,14 type ClearIndicatorProps,15 type MultiValueRemoveProps,16 type MultiValueGenericProps,17 type OptionProps,18} from "react-select";1920import { cn } from "@/lib/utils";2122export type SelectReactOption = {23 value: string;24 label: string;25 description?: string;26 disabled?: boolean;27 icon?: React.ReactNode;28};2930export type SelectReactProps<31 Option = SelectReactOption,32 IsMulti extends boolean = false,33 Group extends GroupBase<Option> = GroupBase<Option>,34> = Omit<ReactSelectProps<Option, IsMulti, Group>, "classNames" | "styles"> & {35 size?: "sm" | "default";36 className?: string;37};3839// Custom dropdown indicator matching Blok select styling40function DropdownIndicator<41 Option,42 IsMulti extends boolean,43 Group extends GroupBase<Option>,44>(props: DropdownIndicatorProps<Option, IsMulti, Group>) {45 return (46 <components.DropdownIndicator {...props}>47 <Icon path={mdiChevronDown} className="size-5 opacity-50" />48 </components.DropdownIndicator>49 );50}5152// Custom clear indicator matching Blok styling53function ClearIndicator<54 Option,55 IsMulti extends boolean,56 Group extends GroupBase<Option>,57>(props: ClearIndicatorProps<Option, IsMulti, Group>) {58 return (59 <components.ClearIndicator {...props}>60 <Icon path={mdiClose} className="size-4 opacity-50 hover:opacity-100" />61 </components.ClearIndicator>62 );63}6465// Custom multi-value container using Badge component66function MultiValueContainer<67 Option,68 IsMulti extends boolean,69 Group extends GroupBase<Option>,70>(props: MultiValueGenericProps<Option, IsMulti, Group>) {71 return (72 <Badge size="md" colorScheme="neutral" className="gap-1 pr-0.5">73 {props.children}74 </Badge>75 );76}7778// Custom multi-value remove button79function MultiValueRemove<80 Option,81 IsMulti extends boolean,82 Group extends GroupBase<Option>,83>(props: MultiValueRemoveProps<Option, IsMulti, Group>) {84 return (85 <components.MultiValueRemove {...props}>86 <Icon path={mdiClose} className="size-3 opacity-60 hover:opacity-100" />87 </components.MultiValueRemove>88 );89}9091// Custom option component with checkmark for selected items92// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from blok
All 72 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | blok | Components | Free | 2 deps · 2 files | |
| Action baraction-bar | blok | Components | Free | 1 dep · 2 files | |
| Alertalert | blok | Components | Free | 2 deps · 2 files | |
| Alert dialogalert-dialog | blok | Components | Free | 2 deps | |
| Aspect ratioaspect-ratio | blok | Components | Free | 1 dep | |
| Avataravatar | blok | Components | Free | 1 dep | |
| Badgebadge | blok | Components | Free | 2 deps | |
| All componentsblok-components | blok | Components | Free | no deps |
