FUNSTACK UI

HomeWhyGetting startedConceptsComponentsRoadmap
GitHub

FUNSTACK UI is in beta. Part of the FUNSTACK family with FUNSTACK Router and FUNSTACK Static, which build this site.

Introduction

  • Why FUNSTACK UI
  • Overview
  • Getting started

Concepts

  • Action props
  • Pending & optimistic state
  • Transitions & ViewTransition
  • Suspense
  • Browser-owned state
  • Server Components

Guides

  • Replacing the element (render)
  • Direction and locales
  • Experimental features
  • Next.js App Router
  • React Router framework mode
  • Content Security Policy
  • Using with AI agents

Components

  • Buttons
    • Button
    • Toggle
    • ToggleGroup
    • Toolbar
  • Disclosure
    • Tabs
    • Accordion
    • Collapsible
    • NavigationMenu
  • Overlays
    • Tooltip
    • HoverCard
    • Popover
    • Dialog
    • AlertDialog
    • Drawer
    • Menu
    • Context menu (Menu)
    • Menubar (Menu)
    • Toast
  • Forms
    • Field and Form
    • Checkbox
    • CheckboxGroup
    • RadioGroup
    • Switch
    • Select
    • Combobox
    • MultiSelect
    • Slider
    • NumberField
    • OTPField
    • TextField
  • Output
    • Progress
    • Meter
    • Avatar
  • Layout
    • Separator
    • Scroll areas (recipe)

Resources

  • Roadmap & changelog
  • GitHub ↗

Direction and locales

FUNSTACK UI has no DirectionProvider and no LocaleProvider. Direction comes from the page, the way the browser reads it; a locale is a plain prop on the Root of each component that formats numbers.

Direction

dir is the only switch. Set it where the platform expects it: <html dir="rtl">, a container, or a part itself (every part passes native attributes through, so <Tabs.List dir="rtl"> works). Each component reads the computed CSS direction of the relevant element (the table below) when a key is pressed or a gesture starts, so nothing is needed at render and Server Components and the server HTML are unaffected.

// <html lang="ar" dir="rtl"> in your document, then no setup:
<Tabs.Root defaultValue="a">
  <Tabs.List>…</Tabs.List> {/* ArrowLeft moves to the next tab */}
</Tabs.Root>
  • Why no provider. A provider would be a second source of truth next to dir, the attribute the browser already uses for layout, logical properties, :dir() and anchor positioning. Libraries that have one ask you to set both, and when the two disagree the arrow keys and the layout point different ways. Reading the CSS cannot disagree with the layout, and a page with <html dir="rtl"> needs no setup at all.
  • Direction islands work. An RTL block inside an LTR page (a quoted Arabic form, a Hebrew sidebar), or the reverse, is handled per component, because each reads its own element. Nothing has to be nested to match the markup.
  • Placement of popups follows direction in CSS: side="inline-start" / "inline-end" and align="start" / "end" use anchor-positioning keywords that resolve against the popup's direction. Drawer's side takes "inline-start" / "inline-end" too.
  • A locale never sets the direction: locale="ar" on a NumberField changes its digits and separators, not its layout.

What mirrors

Only ArrowLeft and ArrowRight in a horizontal orientation swap. ArrowUp / ArrowDown, Home / End, PageUp / PageDown and every vertical orientation do the same under RTL as under LTR. writing-mode is not read.

ComponentWhat follows directionRead from
TabsArrowLeft / ArrowRight between tabs (horizontal list)the List
ToggleGroup, ToolbarArrowLeft / ArrowRight between items (horizontal)the Root
MenubarArrowLeft / ArrowRight between Triggers, and from an item of an open menu to the next or previous menuthe Menubar
SliderArrowLeft / ArrowRight follow the mirrored track (Right decreases); the value under the pointerthe thumb's input; the Track
Menuthe arrow that opens and closes a submenu (the inline-end one); the open key of a Trigger in a vertical Toolbar; which edge of a menu opened at a point sits at the pointer; the wheel hand-off of a horizontal scrollerthe popup or its parent popup; the Trigger; the scroller
Combobox multiplethe inline-start arrow from the input to the chips, and arrows between chipsthe input; the chip
Drawerwhich way an inline-start / inline-end drawer swipes closedthe dialog
Tooltip, Popover, HoverCard, Menu, Select, Combobox, MultiSelectlogical sides and alignment; data-side / data-align report where the popup isCSS anchor positioning
RadioGrouparrows between radios (native; not in Safari, below)the browser
OTPFieldnothing: the Root is ltr by default (below)–
Accordion, NumberFieldnothing: vertical keys only–

Engine differences

  • RadioGroup in Safari, by design. Radio arrows are the browser's own, and WebKit neither mirrors ArrowLeft / ArrowRight under RTL nor wraps at the ends: Right and Down always go to the next radio in document order. A FUNSTACK radio group behaves like every native radio group in Safari; the library adds no key handler (RadioGroup). Slider is the exception, because there the value moved against the drawn track.
  • Firefox misplaces popups in a direction island. When a popup's parent box has another direction than the root element (an RTL block in an LTR page, or the reverse), Firefox mirrors the inline offset of its anchored position, physical sides included, so the popup lands away from its trigger (#89, Mozilla bug 2019601). Chromium and Safari place it correctly, a page whose <html dir> matches is unaffected, and the library ships no workaround.

OTPField is left to right

A one-time code is read left to right in every locale, so OTPField.Root renders dir="ltr" unless you pass dir: inside an RTL page Slot 0 stays the leftmost box and ArrowLeft moves to the previous character. The label and the messages outside the Root follow the page. Without the attribute the boxes would mirror while the input's text would not, and the engines disagree on the arrow keys there. See OTPField.

Locales

Components that format or parse numbers take a locale prop on their Root: NumberField, Progress and Meter. The type is string | readonly string[], what the Intl constructors take (a list is a preference order). The parts get the formatter from the Root.

  • The default is the runtime's locale, on the server and in the browser. That suits a client-only app.
  • Pass it when the page is server-rendered. The server's locale and the browser's can differ, and the formatted text would then not match at hydration. NumberField warns in development when <html lang> names another language and no locale was given.
  • The library never reads navigator.language and never derives the locale from lang.

Why there is no LocaleProvider

Progress.Root and Meter.Root have no "use client" directive, so a Server Component renders them once, on the server. A context cannot reach them there, so a provider would silently not apply to them. And an app that localises already has a locale source, its i18n library; a second provider would have to be kept in step with it. The question is reopened by the first date or time component.

Recipe: the locale from your i18n library

Wrap the Root once in a client component that reads the locale from your i18n library, and use the wrapper everywhere:

"use client";
import { NumberField } from "@funstack/ui/number-field";
import type { ComponentProps } from "react";
import { useLocale } from "./i18n"; // your i18n library's hook

export function NumberFieldRoot(props: ComponentProps<typeof NumberField.Root>) {
  const locale = useLocale();
  return <NumberField.Root locale={locale} {...props} />;
}

Recipe: from a Server Component

locale is plain data, so a Server Component passes it directly. Progress and Meter then format on the server, with nothing to mismatch:

import { Progress } from "@funstack/ui/progress";
import { getLocale } from "./i18n/server"; // however your server knows the request's locale

export async function UploadStatus({ done }: { done: number }) {
  const locale = await getLocale(); // for example "ar-EG" or ["de-CH", "de"]
  return (
    <Progress.Root value={done} locale={locale} aria-label="Upload">
      <Progress.Value />
      <Progress.Track><Progress.Indicator /></Progress.Track>
    </Progress.Root>
  );
}

Built-in strings

A few parts have an English default text, each with its own override; there is no strings provider either.

ComponentDefaultOverride
Combobox"No results", "1 result", "N results"; "Japan removed" with multipleannounce, announceRemoved on the Root
Toast"Notifications (F8)", the Viewport's namearia-label on Toast.Viewport
NumberField"Increase" / "Decrease", the first word of the buttons' names (the label follows: "Increase Quantity")aria-label on Increment / Decrement

Not formatted by the library

Slider's aria-valuetext and Combobox filtering are yours: format and compare with Intl in your own function.