UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

HextaUI/Native select

Inputs & forms
1 of 5
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

5 versions·3 librariesCompare all selects →

  • Native select
  • Native Select
  • 8bitcn
  • Select
  • Select

Native select

The browser's own select, styled to match Input, with a quiet placeholder, Field support and the OS picker on every device.

npx shadcn@latest add https://hextaui.com/r/native-select.json
Open in v0 Docs Repo
Library
HextaUI
License
MIT
Stack
React · Tailwind CSS · animated · base-ui
Packages
@base-ui/react@tabler/icons-reactclass-variance-authoritycnshadcntw-animate-css
Also adds
input, motion, number-flow, use-autosize, use-composed-ref, use-invalid-shake, use-merged-ref, label
Size
87 lines
Demo
From HextaUI

Code

components/ui/native-select.tsx

"use client"

import * as React from "react"
import { Input as InputPrimitive } from "@base-ui/react/input"
import { IconSelector } from "@tabler/icons-react"
import { cn } from "cn"

import { useComposedRef } from "@/hooks/use-composed-ref"
import { useInvalidShake } from "@/hooks/use-invalid-shake"
import { inputVariants } from "@/components/ui/input"

type NativeSelectSize = "sm" | "default" | "lg"

type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> & {
  size?: NativeSelectSize
  htmlSize?: number
  shake?: boolean
}

function NativeSelect({
  className,
  size = "default",
  htmlSize,
  shake = true,
  ref,
  ...props
}: NativeSelectProps) {
  const [selectRef, setRef] = useComposedRef<HTMLSelectElement>(ref)
  useInvalidShake(selectRef, shake)

  return (
    <div
      data-slot="native-select-wrapper"
      data-size={size}
      className={cn(
        "group/native-select relative w-fit min-w-0 has-[select:disabled]:opacity-50",
        className
      )}
    >
      <InputPrimitive
        data-slot="native-select"
        data-size={size}
        className={cn(
          inputVariants({ size }),
          "cursor-pointer appearance-none truncate pe-8 disabled:opacity-100 has-[option[value='']:checked]:text-muted-foreground dark:scheme-dark pointer-coarse:pe-9 [&_optgroup]:bg-[Canvas] [&_optgroup]:text-[CanvasText] [&_option]:bg-[Canvas] [&_option]:text-[CanvasText]"
        )}
        render={<select ref={setRef} size={htmlSize} />}
        {...(props as InputPrimitive.Props)}
      />
      <IconSelector
        aria-hidden="true"
        data-slot="native-select-icon"
        className="pointer-events-none absolute end-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground transition-colors duration-150 group-has-[select:focus-visible]/native-select:text-foreground motion-reduce:transition-none pointer-coarse:end-3 [@media(hover:hover)]:group-hover/native-select:not-group-has-[select:disabled]/native-select:text-foreground"
      />
    </div>
  )
}

function NativeSelectOption({
  className,
  ...props
}: React.ComponentProps<"option">) {
  return (
    <option
      data-slot="native-select-option"
      className={cn("bg-[Canvas] text-[CanvasText]", className)}
      {...props}
    />
  )
}

function NativeSelectOptGroup({
  className,
  ...props
}: React.ComponentProps<"optgroup">) {
  return (
    <optgroup
      data-slot="native-select-optgroup"
      className={cn("bg-[Canvas] text-[CanvasText]", className)}
      {...props}
    />
  )
}

export { NativeSelect, NativeSelectOptGroup, NativeSelectOption }
export type { NativeSelectProps, NativeSelectSize }

More like this

Combobox

shadcn/ui·Inputs & forms

Command

shadcn/ui·Overlays

Questionnaire

HextaUI·Inputs & forms

Command

HextaUI·Overlays

Label

HextaUI·Inputs & forms

Textarea

shadcn/ui·Text effects

Menubar

HextaUI·Overlays

Bento Grid

Magic UI·Cards

Github Inline Comments

Eldora UI·Other

Resizable

HextaUI·Data display

Collapsible

HextaUI·Data display

File Tree

Magic UI·Data display

Navigation Menu

shadcn/ui·Overlays

Menubar

shadcn/ui·Overlays

Features 1

SmoothUI·Cards