COMPONENTS/INPUTS

Native select.

A simple choice with native behavior.

In practice

Uses the operating system picker. Supports name, required, multiple, disabled and native options.

Installation

Install Coal once. Components and TypeScript declarations are included. React 19 and React DOM 19 are peer dependencies.

Terminal · local package
npm install http://localhost:3100/downloads/chlohal-coal-ui-0.5.0.tgz

This installs the local package. It is not yet published on npm. See installation for stylesheet setup and integration.

Usage

example.tsx
"use client";
import * as React from "react";
import "@chlohal/coal-ui/styles.css";
import { Label, NativeSelect } from "@chlohal/coal-ui";
export default function Example() {
    const id = React.useId();
    return (<div>
          <Label htmlFor={id}>Choose a format</Label>
          <NativeSelect id={id} defaultValue="svg">
            <option value="svg">SVG vector</option>
            <option value="png">PNG image</option>
            <option value="pdf">PDF document</option>
          </NativeSelect>
        </div>);
}

Source

The original Coal implementation. Use the package export to integrate it.

packages/react/src/native-select.tsx
import * as React from "react";
import { cn } from "./internal.js";
export type NativeSelectProps = React.ComponentPropsWithRef<"select">;
export function NativeSelect({ className, ...props }: NativeSelectProps) {
  return <select className={cn("coal-native-select", className)} {...props} />;
}

Accessibility checklist

  • Provide an accessible name for controls, including icon-only buttons.
  • Check keyboard navigation, visible focus and disabled states in your application.
  • Do not rely on color alone to communicate status.