# Accordion (/docs/components/accordion) ## Usage [#usage] Click any question to reveal its answer. Use `defaultValue` to specify items expanded by default; each `AccordionItem` has its own `value`. ```tsx "use client"; import { Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger, } from "@/components/ui/hacline/components/accordion"; export const Example = () => ( How do I invite collaborators? Send invites from the Members page in project settings. Where are archived projects? Switch to "Archived" in the project list to view them. ); ``` ### Expanding Multiple Items [#expanding-multiple-items] Enable `multiple` to keep several panels open at once, using a controlled array to expand and collapse all items together. ```tsx "use client"; import { useState } from "react"; import { Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger, } from "@/components/ui/hacline/components/accordion"; import { Button } from "@/components/ui/hacline/components/button"; const sections = [ { content: "Three review rounds completed.", id: "review", label: "Review progress", }, { content: "Artifacts will be packaged on Friday.", id: "delivery", label: "Delivery schedule", }, ]; export const Example = () => { const [open, setOpen] = useState(["review"]); return (
{sections.map(({ content, id, label }) => ( {label} {content} ))}
); }; ```
## Parts [#parts] ## Props [#props] ### AccordionOptions The options `accordion` takes. A component takes them as props on its root. | Prop | Type | Description | | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `value?` | `T[] \| undefined` | The open items' values. Pass it to control the accordion. | | `defaultValue?` | `T[] \| undefined` | The items open at first, when uncontrolled. Default: `[]` | | `onValueChange?` | `((value: T[], details: ChangeDetails) => void) \| undefined` | Runs when items want to open or close. `details.reason` says why, and `details.cancel()` stops it. | | `multiple?` | `boolean \| undefined` | Whether several items can be open at once. Otherwise opening one closes the others. Default: `false` | | `collapsible?` | `boolean \| undefined` | Whether the open item can close when only one may be open. With `false`, one item always stays open and its trigger reports it can't be pressed. Default: `true` | | `disabled?` | `boolean \| undefined` | Stops every item from opening or closing. Triggers stay focusable. Default: `false` | | `keepMounted?` | `boolean \| undefined` | Whether closed panels stay in the page, hidden. Default: `false` | | `hiddenUntilFound?` | `boolean \| undefined` | Keeps closed panels in the page as `hidden="until-found"`, so the browser's find in page can match their text and open them. Default: `false` | | `controller?` | `{ getValue: () => T[]; setValue: (value: T[], options?: AccordionChangeOptions) => boolean; isOpen: (value: T) => boolean; open: (value: T, options?: AccordionChangeOptions) => boolean; close: (value: T, options?: AccordionChangeOptions) => boolean; toggle: (value: T, options?: AccordionChangeOptions) => boolean; openAll: (options?: AccordionChangeOptions) => boolean; closeAll: (options?: AccordionChangeOptions) => boolean; focus: (value?: T \| undefined) => void; } \| undefined` | Opens and closes items from anywhere. Create one with `createAccordionController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/accordion). # AlertDialog (/docs/components/alert-dialog) ## Usage [#usage] "Keep draft" and "Confirm clear" each update the demo state. A close button's `value` is passed as `returnValue` to the open state callback. ```tsx "use client"; import { useState } from "react"; import { AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/hacline/components/alert-dialog"; export const Example = () => { const [status, setStatus] = useState("Draft saved"); return (
Discard draft Clear current draft? The draft in this example will be cleared.
setStatus("Draft kept")} value="cancel" > Keep draft setStatus("Draft cleared")} data-agent-confirm="Clear sample draft" data-variant="danger" value="confirm" > Confirm clear
{status}
); }; ```
### Async Confirmation [#async-confirmation] Return a Promise from the confirm button's `action`. The button displays a pending state while archiving, and the dialog closes once the operation completes. ```tsx "use client"; import { useState } from "react"; import { AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/hacline/components/alert-dialog"; const ARCHIVE_DELAY = 700; export const Example = () => { const [archived, setArchived] = useState(false); return ( {archived ? "Archived" : "Archive sample record"} Archive this record? You can still find it in history after archiving.
Not now { // oxlint-disable-next-line promise/avoid-new -- Browser timers use a callback. await new Promise((resolve) => { setTimeout(resolve, ARCHIVE_DELAY); }); setArchived(true); }} value="confirm" > {({ pending }) => (pending ? "Archiving…" : "Confirm archive")}
); }; ```
## Parts [#parts] ## Props [#props] ### AlertDialogOptions The options `alertDialog` takes. A component takes them as props on its root. | Prop | Type | Description | | ----------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `container?` | `DocumentFragment \| Element \| null \| undefined` | Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent. | | `open?` | `boolean \| undefined` | Whether the dialog is open. Pass it to control the dialog. | | `defaultOpen?` | `boolean \| undefined` | Whether the dialog starts open, when uncontrolled. Focus moves into it once it's on the page. Default: `false` | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the dialog has finished opening or closing, after any animation. | | `dismissible?` | `boolean \| undefined` | Whether Escape, an outside press and Android's back gesture can close the dialog. Close parts, triggers and the controller always can. Pass `false` while a form has unsaved changes, and ask in `onDismissAttempt`. Default: `true` | | `onDismissAttempt?` | `((details: DialogDismissAttemptDetails) => void) \| undefined` | Runs when a dismissal was refused, because `dismissible` is false, an outside press doesn't close it, or a Close part's action is running. Ask "Discard changes?" here. | | `persistentElements?` | `(string \| Element)[] \| (() => Element[]) \| undefined` | Elements that stay usable while the dialog makes the page inert, like a chat launcher or a password manager's button. Elements, CSS selectors, or a function that returns elements, read when the dialog opens. Presses on them never close it. | | `pendingAnnouncement?` | `string \| undefined` | What screen readers hear once a Close part's action has been running for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing. Default: `"Loading"` | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | | `onOpenChange?` | `((open: boolean, details: DialogOpenChangeDetails) => void) \| undefined` | Runs when the alert dialog wants to open or close. `details.reason` says why, `details.cancel()` stops it, and `details.returnValue` is the `value` of the Close part that closed it. | | `onPayloadChange?` | `((payload: unknown, details: ChangeDetails) => void) \| undefined` | Runs when a trigger or a controller with another payload opens the alert dialog, before `onOpenChange`, or a controller's `open({ payload })` gives the open one another payload. `details.cancel()` keeps the previous payload. | | `controller?` | `PopupController \| undefined` | Opens, closes and inspects the alert dialog from anywhere. Create one with `createAlertDialogController()` or `createConfirm()`. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/alert-dialog). # Autocomplete (/docs/components/autocomplete) ## Usage [#usage] Typing "Design" shows matching tags, while new terms can be kept directly as entered. When `items` is provided, an empty `AutocompleteList` renders the current suggestions. ```tsx "use client"; import { Autocomplete, AutocompleteContent, AutocompleteEmpty, AutocompleteInput, AutocompleteLabel, AutocompleteList, } from "@/components/ui/hacline/components/autocomplete"; const tags = [ "Design review", "Design system", "Project plan", "Release notes", ]; export const Example = () => (
Document tag Use your typed tag directly
); ```
### Controlled Input and Clearing [#controlled-input-and-clearing] Synchronize application state with `value` and clear the input with `AutocompleteClear`. This example matches only cities starting with the entered text. ```tsx "use client"; import { useState } from "react"; import { Autocomplete, AutocompleteClear, AutocompleteContent, AutocompleteInput, AutocompleteLabel, AutocompleteList, } from "@/components/ui/hacline/components/autocomplete"; export const Example = () => { const [value, setValue] = useState("Seattle"); return (
Shipping city
City: {value || "Not set"}
); }; ```
## Parts [#parts] ## Props [#props] ### AutocompleteOptions The options `autocomplete` takes. A component takes them as props on its root. | Prop | Type | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `container?` | `DocumentFragment \| Element \| null \| undefined` | Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent. | | `value?` | `string \| undefined` | The text. Pass it to control it. | | `defaultValue?` | `string \| undefined` | The text at first, when uncontrolled. A form reset returns to it. | | `onValueChange?` | `((value: string, details: AutocompleteValueChangeDetails) => void) \| undefined` | Runs when the text wants to change: typing, choosing a suggestion, a Clear part, a form reset or a controller. `details.cancel()` keeps it as it was. | | `open?` | `boolean \| undefined` | Whether the suggestions are open. Pass it to control them. | | `defaultOpen?` | `boolean \| undefined` | Whether the suggestions start open, when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: ChangeDetails) => void) \| undefined` | Runs when the suggestions want to open or close. `details.reason` says why, and `details.cancel()` stops it. | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the suggestions have finished opening or closing, after any animation. | | `onSubmit?` | `((value: string, details: AutocompleteSubmitDetails) => void) \| undefined` | Runs with the text when Enter is pressed with no suggestion highlighted, or after choosing one with `submitOnSelect`. The surrounding form submits next, unless the event's `preventDefault()` is called. | | `items?` | `ListData \| undefined` | The suggestions as data. Renders them for you, and filters them without rendering every one. | | `emptyItems?` | `ListData \| undefined` | Suggestions shown instead of `items` while the field is empty, like recent searches, with `openOnFocus`. Groups work, like `{ type: "group", label: "Recent", items }`. Needs `items`. | | `filter?` | `SearchFilter \| undefined` | How typing narrows the suggestions: `"contains"`, `"startsWith"`, `"fuzzy"`, a function of the item and the text, or `false` to keep every one, for results a server already filtered. Default: `"contains"` | | `inlineComplete?` | `boolean \| undefined` | Whether typing completes the text with the first suggestion that starts with it, with the rest selected after the caret: ArrowRight or End accepts it, Backspace and Escape take it back out, and arrow keys fill in the suggestion they highlight. Default: `false` | | `autoHighlight?` | `boolean \| undefined` | Whether the first suggestion is highlighted while typing, so Enter chooses it. Default: `false` | | `openOnFocus?` | `boolean \| undefined` | Whether the suggestions open when the field gets focus, like recent searches, even before anything is typed. Default: `false` | | `submitOnSelect?` | `boolean \| undefined` | Whether choosing a suggestion submits, like a search box: `onSubmit` runs, then the form submits. Default: `false` | | `status?` | `AsyncOptionsStatus \| undefined` | Whether results are loading or failed, for the empty and status parts. Sets `aria-busy` on the list while loading. Default: `"idle"` | | `onHighlight?` | `((value: string \| null, details: ListHighlightDetails) => void) \| undefined` | Runs when the highlight moves, with the suggestion's index among the visible ones, so a virtualized list can scroll to it. | | `onLoadMore?` | `(() => void) \| undefined` | Runs when the highlight or scrolling reaches the last suggestion, so the next page can load, like `createAsyncOptions`'s `loadMore`. Not again for the same suggestions, unless the last load failed. | | `announcement?` | `((change: ListAnnouncement) => string \| null \| undefined) \| undefined` | What screen readers hear after typing pauses, when no `AutocompleteStatus` is rendered. Return null for nothing. Default: `"3 results", "No results" or "Loading"` | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last suggestion to the first. Default: `true` | | `modal?` | `"pointer" \| boolean \| undefined` | `false`: the page stays usable while the suggestions are open. `"pointer"`: an outside press only closes them. `true`: also locks scroll and makes the rest of the page inert. Default: `false, or true while it presents as a sheet` | | `presentation?` | `PresentationSetting<"popover"> \| undefined` | How the suggestions present. `"sheet"` slides them up from the bottom of the screen with the field in its header, where they can be swiped away, and `"auto"` does that on small touch screens. A tap that opens a sheet leaves the keyboard closed until the field in the header is tapped. Decided each time they open; the server renders `"popover"` for `"auto"`. Default: `"popover"` | | `disabled?` | `boolean \| undefined` | Disables the field like a native input: it can't be focused or changed, and its text isn't submitted. | | `readOnly?` | `boolean \| undefined` | Keeps the field focusable and its text submitted, but stops changes. | | `required?` | `boolean \| undefined` | Blocks form submission while the field is empty, with the browser's own message. | | `name?` | `string \| undefined` | The name the text submits under. | | `form?` | `string \| undefined` | The id of a form to belong to, when the field isn't inside that form. | | `controller?` | `{ isOpen: () => boolean; setOpen: (open: boolean, options?: AutocompleteChangeOptions) => boolean; open: (options?: AutocompleteChangeOptions & { signal?: AbortSignal; }) => Promise>; close: (options?: AutocompleteChangeOptions) => boolean; toggle: (options?: AutocompleteChangeOptions) => boolean; getValue: () => string; setValue: (value: string, options?: AutocompleteChangeOptions) => boolean; clear: (options?: AutocompleteChangeOptions) => boolean; getHighlighted: () => string \| null; highlight: (value: string \| null) => boolean; focus: () => void; } \| undefined` | Opens, closes, reads and sets the autocomplete from anywhere. Create one with `createAutocompleteController()`. | | `dismissible?` | `boolean \| undefined` | Whether Escape, an outside press, focus or the window leaving, Android's back gesture and a sheet's swipe can close it. Triggers, Close parts and the controller always can. Pass `false` while it holds unsaved work, and ask in `onDismissAttempt`. Default: `true` | | `onDismissAttempt?` | `((details: { reason: "back"; event?: Event \| undefined; } \| { reason: "escape-key"; event?: KeyboardEvent \| undefined; } \| { reason: "outside-press"; event?: MouseEvent \| undefined; } \| { reason: "swipe"; event?: PointerEvent \| TouchEvent \| undefined; }) => void) \| undefined` | Runs when `dismissible` refused a dismissal made on purpose: Escape, an outside press, back or a swipe. Focus or the window leaving is refused without it. Ask "Discard changes?" here. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/autocomplete). # Avatar (/docs/components/avatar) ## Usage [#usage] Provide each avatar with an accessible name. `AvatarImage` is shown once the image loads, and `AvatarFallback` appears when no image is available. This example uses a local docs asset that you can replace with your own. ```tsx "use client"; import { Avatar, AvatarFallback, AvatarImage, } from "@/components/ui/hacline/components/avatar"; /* oxlint-disable jsx-a11y/prefer-tag-over-role -- The wrapper names both the photo and its text fallback. */ export const Example = () => (
LK MT
); ```
### Stacked Collaborator Avatars [#stacked-collaborator-avatars] Place each avatar inside a member list. Even when displaying only initials, accessible names distinguish every collaborator. ```tsx "use client"; import { Avatar, AvatarFallback, } from "@/components/ui/hacline/components/avatar"; const team = [ { initials: "AL", name: "Alice Lin" }, { initials: "NZ", name: "Noah Zhou" }, { initials: "MC", name: "Maya Chen" }, ]; /* oxlint-disable jsx-a11y/prefer-tag-over-role -- The initials are a text alternative to a photo. */ export const Example = () => (
    {team.map(({ initials, name }) => (
  • {initials}
  • ))}
); ```
## Parts [#parts] ## Props [#props] ### AvatarOptions The options `avatar` takes. A component takes them as props on its root. | Prop | Type | Description | | ------------------------ | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `onLoadingStatusChange?` | `((status: AvatarLoadingStatus, details: ChangeDetails) => void) \| undefined` | Runs when the image's loading status changes: `"loading"` when it gets a source, `"loaded"`, `"error"`, and `"idle"` when it leaves the page. `details.reason` says why, and `details.event` is the image's `load` or `error` event, or undefined when the status was known at once, like for a cached image. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/avatar). # Button (/docs/components/button) ## Import [#import] ```tsx import { Button } from "@/components/ui/hacline/components/button"; ``` ## Variants [#variants] Switch the visual hierarchy of the button with `variant`. Defaults to `primary`. ```tsx import { Button } from "@/components/ui/hacline/components/button"; export function ButtonVariants() { return (
); } ```
## Sizes [#sizes] Adjust the button size using `size`, supporting `sm`, `md`, `lg`, and icon sizes `icon-sm`, `icon`, and `icon-lg`. Always provide an `aria-label` when rendering an icon-only button. ```tsx import { Button } from "@/components/ui/hacline/components/button"; import { PlusIcon } from "lucide-react"; export function ButtonSizes() { return (
); } ```
## Async Loading State [#async-loading-state] When `onClick` returns a `Promise`, the button automatically enters the `data-pending` state, retains focus, blocks duplicate clicks, and announces `pendingAnnouncement` to screen readers if the operation exceeds 1 second. Use `data-show="idle"` and `data-show="pending"` to swap icons or content automatically. ```tsx "use client"; import { Button } from "@/components/ui/hacline/components/button"; import { ArrowDownToLineIcon, LoaderCircleIcon } from "lucide-react"; export function ButtonPending() { return ( ); } ``` ## Disabled and Focusable State [#disabled-and-focusable-state] Setting `disabled` blocks activation and removes the button from the Tab order. Combine with `focusableWhenDisabled` to use `aria-disabled` and keep keyboard focusability, making it easy to pair with helper text or a Tooltip explaining why the action is unavailable. ```tsx import { Button } from "@/components/ui/hacline/components/button"; export function ButtonDisabled() { return (
); } ```
## Render as Link [#render-as-link] Use the `render` prop to render the button as an `` or router link component (such as Next.js `Link`), preserving link semantics and disabled interception behavior. ```tsx import { Button } from "@/components/ui/hacline/components/button"; export function ButtonLink() { return ( Build log

build completed in 2.1s

); }; ``` ## Parts [#parts] ## Props [#props] ### CollapsibleOptions The options `collapsible` takes. A component takes them as props on its root. | Prop | Type | Description | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | `open?` | `boolean \| undefined` | Whether the panel is open. Pass it to control the collapsible. | | `defaultOpen?` | `boolean \| undefined` | Whether the panel is open at first, when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: ChangeDetails) => void) \| undefined` | Runs when the panel wants to open or close. `details.reason` says why, and `details.cancel()` stops it. | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the panel has finished opening or closing, after any animation. | | `disabled?` | `boolean \| undefined` | Stops the trigger from opening or closing the panel. The trigger stays focusable. Default: `false` | | `controller?` | `{ isOpen: () => boolean; setOpen: (open: boolean, options?: CollapsibleChangeOptions) => boolean; open: (options?: CollapsibleChangeOptions) => boolean; close: (options?: CollapsibleChangeOptions) => boolean; toggle: (options?: CollapsibleChangeOptions) => boolean; focus: () => void; } \| undefined` | Opens and closes the panel from anywhere. Create one with `createCollapsibleController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/collapsible). # ColorPicker (/docs/components/color-picker) ## Usage [#usage] Drag the color area and hue slider, or type a CSS color and press Enter. This example edits colors in HSV while `format="hex"` determines the output format. ```tsx "use client"; import { ColorPicker, ColorPickerArea, ColorPickerAreaThumb, ColorPickerInput, ColorPickerSlider, ColorPickerSliderThumb, ColorPickerSwatch, ColorPickerSwatches, ColorPickerSwatchItem, } from "@/components/ui/hacline/components/color-picker"; const colors = [ { color: "#446bb0", label: "Ocean blue" }, { color: "#297754", label: "Pine green" }, { color: "#b35c2b", label: "Terracotta" }, ]; export const Example = () => (
{colors.map(({ color, label }) => ( ))}
); ```
### Adjusting Opacity [#adjusting-opacity] Set a slider's `channel` to `alpha`, and inspect the alpha-enabled CSS representation in the color input. ```tsx "use client"; import { ColorPicker, ColorPickerInput, ColorPickerSlider, ColorPickerSliderThumb, ColorPickerSwatch, } from "@/components/ui/hacline/components/color-picker"; export const Example = () => (
); ```
## Parts [#parts] ## Props [#props] ### ColorPickerOptions The options `colorPicker` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `value?` | `string \| undefined` | The value, as a CSS color, like `"#0ea5e9"` or `"oklch(0.62 0.19 259)"`. Pass it to control the picker. | | `defaultValue?` | `string \| undefined` | The value at first, when uncontrolled. A form reset returns to it. Default: `black` | | `onValueChange?` | `((value: string, details: ColorPickerValueChangeDetails) => void) \| undefined` | Runs while the value changes: on every step of a drag or a key. `details.color` is the color, and `details.cancel()` stops it. | | `onValueCommit?` | `((value: string, details: ColorPickerValueCommitDetails) => void) \| undefined` | Runs once an interaction that changed the value ends: the pointer lifts, a key is pressed, a swatch is picked. For saving. | | `space?` | `ColorPickerSpace \| undefined` | The space the parts edit in, which decides their channels: `"hsv"` has hue, saturation and brightness, `"hsl"` hue, saturation and lightness, `"srgb"` red, green and blue, `"oklch"` lightness, chroma and hue. Default: `"hsv"` | | `format?` | `ColorFormat \| undefined` | How the value is written: `"hex"`, or a space in its CSS syntax, like `"oklch"`. Default: `` "hex" for `"hsv"`, which CSS can't write, and the space otherwise `` | | `gamut?` | `false \| ColorGamut \| undefined` | The colors the value can hold. A drag can go past the edge, and the value is the closest color inside it; once the drag ends, the picker moves there too. `"p3"` allows wide-gamut screens' colors, and `false` any color. Default: `"srgb"` | | `disabled?` | `boolean \| undefined` | Disables every part: they can't be focused or changed, and the value isn't submitted. | | `readOnly?` | `boolean \| undefined` | Keeps the parts focusable and the value submitted, but stops changes. | | `required?` | `boolean \| undefined` | Marks it required, with `data-required`. A color picker always has a value, so it never blocks a form. | | `name?` | `string \| undefined` | The name the value submits under. Without one, the picker submits nothing. | | `form?` | `string \| undefined` | The id of a form to belong to, when it isn't inside that form. | | `controller?` | `{ getValue: () => string; setValue: (value: string, options?: ColorPickerChangeOptions) => boolean; focus: () => void; } \| undefined` | Sets the value from anywhere. Create one with `createColorPickerController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/color-picker). # Combobox (/docs/components/combobox) ## Usage [#usage] Type a keyword in "Team", navigate with the arrow keys, and press Enter to select. Each dropdown item uses `value` for the submitted value and `label` to display the team name. ```tsx "use client"; import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxLabel, ComboboxList, } from "@/components/ui/hacline/components/combobox"; const teams = [ { label: "Interaction Design", value: "design" }, { label: "Frontend Engineering", value: "frontend" }, { label: "Site Operations", value: "ops" }, ]; export const Example = () => (
Team No matching teams
); ```
### Multiple Selection and Chip Removal [#multiple-selection-and-chip-removal] Enable `multiple` and render selected chips with `ComboboxValue`. Each chip's remove button stays synchronized with the selection state. ```tsx "use client"; import { Combobox, ComboboxChip, ComboboxChipRemove, ComboboxChips, ComboboxContent, ComboboxInput, ComboboxLabel, ComboboxList, ComboboxValue, } from "@/components/ui/hacline/components/combobox"; const labels = ["Frontend", "Docs", "Accessibility"]; export const Example = () => (
Task labels {({ value }) => (Array.isArray(value) ? value : []).map((entry: string) => ( {entry} )) }
); ```
## Parts [#parts] ## Props [#props] ### ComboboxOptions The options `combobox` takes. A component takes them as props on its root. `multiple` picks the shape of the value, and `Multiple` true requires it. | Prop | Type | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `container?` | `DocumentFragment \| Element \| null \| undefined` | Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent. | | `query?` | `string \| undefined` | The input's text, which filters the list. Pass it to control it. Choosing an item sets it to the item's label, or empties it with `multiple`. | | `defaultQuery?` | `string \| undefined` | The input's text at first, when uncontrolled. Defaults to the selected item's label. | | `onQueryChange?` | `((query: string, details: TextChangeDetails) => void) \| undefined` | Runs when the input's text wants to change: typing, choosing an item, or closing with text that wasn't chosen. While an input method composes, `details.composing` is `true`; search once it's `false`. | | `open?` | `boolean \| undefined` | Whether the list is open. Pass it to control it. | | `defaultOpen?` | `boolean \| undefined` | Whether the list starts open, when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: ChangeDetails) => void) \| undefined` | Runs when the list wants to open or close. `details.reason` says why, and `details.cancel()` stops it. | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the list has finished opening or closing, after any animation. | | `maxSelected?` | `number \| undefined` | With `multiple`, how many items can be selected. Once reached, the other items are disabled. | | `items?` | `ListData \| undefined` | The items as data. Renders the list for you, and filters it without rendering every item. | | `emptyItems?` | `ListData \| undefined` | Items shown instead of `items` while the input is empty, like recent choices or suggestions. Groups work, like `{ type: "group", label: "Recent", items }`. Needs `items`. | | `filter?` | `ListFilter \| undefined` | How typing narrows the list: `"contains"`, `"startsWith"`, a function of the item and the text, whose numeric result also sorts data items, or `false` to keep every item, for results a server already filtered. Default: `"contains"` | | `itemToValue?` | `((value: T) => string) \| undefined` | The string an item's value submits as and is identified by, for object values. Strings pass through, and objects use their `value` or `id`. | | `itemToLabel?` | `((value: T) => string) \| undefined` | The text a value shows, for values whose item isn't rendered, like async results. | | `isItemEqualToValue?` | `((itemValue: T, value: T) => boolean) \| undefined` | Whether an item's value is the selected value, for object values that aren't the same object. | | `autoHighlight?` | `"always" \| "selected" \| boolean \| undefined` | Whether the first matching item is highlighted while typing, so Enter chooses it. `"always"` also highlights the selected item, or the first, when the list opens, so arrows move from there. `"selected"` highlights only the selected item when the list opens, and nothing when none is. Default: `false` | | `keepQuery?` | `boolean \| undefined` | With `multiple`, whether the input keeps its text after an item is chosen. Default: `false` | | `pendingAnnouncement?` | `string \| undefined` | What screen readers hear once the Create part's `onCreate` has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing. Default: `"Loading"` | | `allowCustomValue?` | `boolean \| undefined` | Whether text that matches no item becomes the value, when Enter is pressed with nothing highlighted, or, without `multiple`, when the list closes. The value is the text itself. Default: `false` | | `status?` | `AsyncOptionsStatus \| undefined` | Whether results are loading or failed, for the status and empty parts. Sets `aria-busy` on the list while loading. Default: `"idle"` | | `onHighlight?` | `((value: T \| null, details: ListHighlightDetails) => void) \| undefined` | Runs when the highlight moves, with the item's index among the visible items, so a virtualized list can scroll to it. | | `onLoadMore?` | `(() => void) \| undefined` | Runs when the highlight or scrolling reaches the last item, so the next page can load, like `createAsyncOptions`'s `loadMore`. Not again for the same items, unless the last load failed. | | `announcement?` | `((change: ListAnnouncement) => string \| null \| undefined) \| undefined` | What screen readers hear after typing pauses, when no `ComboboxStatus` is rendered, and when a chip is removed. Return null for nothing. Default: `"3 results", "No results", "Loading", or "France removed"` | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last item to the first. Default: `true` | | `modal?` | `"pointer" \| boolean \| undefined` | `false`: the page stays usable while the list is open. `"pointer"`: an outside press only closes the list. `true`: also locks scroll and makes the rest of the page inert. Default: `false, or true while it presents as a sheet` | | `presentation?` | `PresentationSetting<"popover"> \| undefined` | How the list presents. `"sheet"` slides it up from the bottom of the screen with the input in its header, where it can be swiped away, and `"auto"` does that on small touch screens. A tap that opens a sheet leaves the keyboard closed until the input in the header is tapped. Decided each time it opens; the server renders `"popover"` for `"auto"`. Default: `"popover"` | | `disabled?` | `boolean \| undefined` | Disables the combobox like a native input: it can't be focused or changed, and the value isn't submitted. | | `readOnly?` | `boolean \| undefined` | Keeps the combobox focusable and its value submitted, but stops changes. | | `required?` | `boolean \| undefined` | Blocks form submission until a value is selected, with the browser's own message. | | `name?` | `string \| undefined` | The name the value submits under. Without one, the combobox submits nothing. | | `form?` | `string \| undefined` | The id of a form to belong to, when the combobox isn't inside that form. | | `controller?` | `{ isOpen: () => boolean; setOpen: (open: boolean, options?: ComboboxChangeOptions) => boolean; open: (options?: ComboboxChangeOptions & { signal?: AbortSignal; }) => Promise>; close: (options?: ComboboxChangeOptions) => boolean; toggle: (options?: ComboboxChangeOptions) => boolean; getValue: () => any; setValue: (value: any, options?: ComboboxChangeOptions) => boolean; clear: (options?: ComboboxChangeOptions) => boolean; getQuery: () => string; setQuery: (query: string, options?: ComboboxChangeOptions) => boolean; getHighlighted: () => any; highlight: (value: any) => boolean; focus: () => void; } \| undefined` | Opens, closes, reads and sets the combobox from anywhere. Create one with `createComboboxController()`. | | `dismissible?` | `boolean \| undefined` | Whether Escape, an outside press, focus or the window leaving, Android's back gesture and a sheet's swipe can close it. Triggers, Close parts and the controller always can. Pass `false` while it holds unsaved work, and ask in `onDismissAttempt`. Default: `true` | | `onDismissAttempt?` | `((details: { reason: "back"; event?: Event \| undefined; } \| { reason: "escape-key"; event?: KeyboardEvent \| undefined; } \| { reason: "outside-press"; event?: MouseEvent \| undefined; } \| { reason: "swipe"; event?: PointerEvent \| TouchEvent \| undefined; }) => void) \| undefined` | Runs when `dismissible` refused a dismissal made on purpose: Escape, an outside press, back or a swipe. Focus or the window leaving is refused without it. Ask "Discard changes?" here. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | | `multiple?` | `boolean \| undefined` | Whether several items can be selected. The value is then a list, the list stays open as items toggle, and the input empties after each choice. Whether several items can be selected. Default: `false` | | `value?` | `T \| T[] \| ItemsOf \| null \| undefined` | The selected value. Pass it to control the combobox. `null` selects nothing. The selected values. Pass it to control the combobox. The selected value, or values with `multiple`. Pass it to control the combobox. | | `defaultValue?` | `T \| T[] \| ItemsOf \| null \| undefined` | The value selected at first, when uncontrolled. A form reset returns to it. The values selected at first, when uncontrolled. A form reset returns to them. The value or values selected at first, when uncontrolled. A form reset returns to it. | | `onValueChange?` | `((value: NoInfer \| null, details: ChangeDetails) => void) \| ((value: T[], details: ChangeDetails) => void) \| ((value: NoInfer[] \| NoInfer \| null, details: ChangeDetails) => void) \| undefined` | Runs when a user, a form reset or a controller wants to change the value. `details.reason` says why, and `details.cancel()` stops it. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/combobox). # Command (/docs/components/command) ## Usage [#usage] Type a command keyword, then press Enter or click a result. Selected actions are passed to your application via `onAction`, and commands can be organized into groups. ```tsx "use client"; import { useState } from "react"; import { Command, CommandEmpty, CommandGroup, CommandGroupLabel, CommandInput, CommandItem, CommandList, } from "@/components/ui/hacline/components/command"; export const Example = () => { const [action, setAction] = useState("Waiting for a command"); return (
No matching commands Workspace New draft Copy link Open activity log {action}
); }; ```
### Switching Between Command Pages [#switching-between-command-pages] Open the export format page first, then select Markdown or HTML. Press Backspace while the search input is empty to return to the previous page. ```tsx "use client"; import { useState } from "react"; import { Command, CommandInput, CommandItem, CommandList, CommandPage, } from "@/components/ui/hacline/components/command"; export const Example = () => { const [format, setFormat] = useState("Markdown"); return (
Choose export format Markdown HTML Export format: {format}
); }; ```
## Parts [#parts] ## Props [#props] ### CommandOptions The options `command` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `value?` | `string \| null \| undefined` | The highlighted command's value. Pass it to control the highlight. `null` highlights nothing. | | `defaultValue?` | `string \| null \| undefined` | The command highlighted at first, when uncontrolled. Without it, the first command is, with `autoHighlight`. | | `onValueChange?` | `((value: string \| null, details: CommandValueChangeDetails) => void) \| undefined` | Runs when the highlight moves: arrow keys, the pointer, typing, a page change or a controller. `details.index` says where the command is, for virtualized lists. | | `query?` | `string \| undefined` | The search text, which filters the commands. Pass it to control it. | | `defaultQuery?` | `string \| undefined` | The search text at first, when uncontrolled. | | `onQueryChange?` | `((query: string, details: TextChangeDetails) => void) \| undefined` | Runs when the search text wants to change: typing, opening a page, going back, or a controller. | | `pages?` | `string[] \| undefined` | The stack of open pages, from the first page opened to the current one. Pass it to control it. | | `defaultPages?` | `string[] \| undefined` | The pages open at first, when uncontrolled. Default: `[]` | | `onPagesChange?` | `((pages: string[], details: ChangeDetails) => void) \| undefined` | Runs when a page opens or Backspace or Escape goes back. | | `onAction?` | `((value: string, details: CommandActionDetails) => unknown) \| undefined` | Runs when a command runs, with its value: Enter, a click, or its shortcut. Return a Promise to mark the command pending until it settles: it gets `data-pending`, `aria-busy` and `aria-disabled`, and running it again waits. A rejection puts the reason in its `error` state until the next run. | | `pendingAnnouncement?` | `string \| undefined` | What screen readers hear once a command has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing. Default: `"Loading"` | | `items?` | `CommandData \| undefined` | The commands as data. Renders them for you, ranked as the user types, with pages for commands that have `items`. | | `emptyItems?` | `CommandData \| undefined` | Commands shown instead of `items` on the first page while the search is empty, like recent or suggested ones. Groups work, like `{ type: "group", label: "Suggestions", items }`. Needs `items`. | | `filter?` | `SearchFilter \| undefined` | How typing narrows the list: `"fuzzy"` keeps commands with the text's letters in order, best matches first; `"contains"` and `"startsWith"` match the text itself. A function returns a score (0 hides) or a boolean. `false` keeps every command, for results a server already filtered. Composed commands keep their order, and data commands are ranked by score. Default: `"fuzzy"` | | `autoHighlight?` | `boolean \| undefined` | Whether the first command is highlighted while nothing else is, and the best match as the user types, so Enter runs it. Default: `true` | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last command to the first. Default: `true` | | `status?` | `AsyncOptionsStatus \| undefined` | Whether results are loading or failed, for the empty and status parts. Sets `aria-busy` on the list while loading. Default: `"idle"` | | `onLoadMore?` | `(() => void) \| undefined` | Runs when the highlight or scrolling reaches the last command, so the next page can load, like `createAsyncOptions`'s `loadMore`. Not again for the same commands, unless the last load failed. | | `announcement?` | `((change: ListAnnouncement) => string \| null \| undefined) \| undefined` | What screen readers hear after typing pauses, when no `CommandStatus` is rendered. Return null for nothing. Default: `"3 results", "No results" or "Loading"` | | `controller?` | `{ getValue: () => string \| null; setValue: (value: string \| null, options?: CommandChangeOptions) => boolean; getQuery: () => string; setQuery: (query: string, options?: CommandChangeOptions) => boolean; getPages: () => string[]; setPages: (pages: string[], options?: CommandChangeOptions) => boolean; push: (page: string, options?: CommandChangeOptions) => boolean; pop: (options?: CommandChangeOptions) => boolean; run: (value?: string) => void; focus: () => void; } \| undefined` | Reads and drives the list from anywhere. Create one with `createCommandController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/command). # ConfirmButton (/docs/components/confirm-button) ## Import [#import] ```tsx import { ConfirmButton } from "@/components/ui/hacline/components/confirm-button"; ``` ## Expand Mode (Default) [#expand-mode-default] Clicking the trigger smoothly morphs the button in-place into `[ Confirm | Cancel ]` with zero gaze jump. Focus automatically moves to the Cancel button by default (`initialFocus="cancel"`), supports `ArrowLeft` / `ArrowRight` roving navigation, and disarms on `Escape` or outside press. ```tsx import { ConfirmButton } from "@/components/ui/hacline/components/confirm-button"; import { Trash2Icon } from "lucide-react"; export function ConfirmButtonExpand() { return ( deleteProject()} variant="outline" > ); } ``` ## Hold-to-Confirm Mode [#hold-to-confirm-mode] Set `mode="hold"` to charge an in-button progress bar over `holdDuration` (defaults to `1500ms`). Works with mouse, touch, pen, and keyboard (`Space` or `Enter`), and cancels smoothly on early release, pointer drift, `Escape`, or blur. ```tsx import { ConfirmButton } from "@/components/ui/hacline/components/confirm-button"; import { RotateCcwIcon } from "lucide-react"; export function ConfirmButtonHold() { return ( resetWorkspace()} variant="danger" > ); } ``` ## Async Loading State [#async-loading-state] When `onConfirm` returns a `Promise`, the button automatically enters `data-pending`, sets `aria-busy="true"`, blocks duplicate submissions and `Escape` dismissal until settled, and collapses back to idle on resolution. If the `Promise` rejects, it clears `data-pending` while staying armed so the user can retry or cancel. ```tsx import { ConfirmButton } from "@/components/ui/hacline/components/confirm-button"; import { LoaderCircleIcon, Trash2Icon } from "lucide-react"; export function ConfirmButtonAsync() { return ( { await deleteRecord(); }} pendingAnnouncement="Deleting record" pendingLabel={ <> ); } ``` ## Sizes [#sizes] Adjust the button and expanded capsule height with `size` (`sm`, `md`, `lg`). ```tsx import { ConfirmButton } from "@/components/ui/hacline/components/confirm-button"; export function ConfirmButtonSizes() { return (
Small Default Large
); } ```
## Props [#props] ### ConfirmButtonOwnProps | Prop | Type | Description | | ------------------------ | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `mode?` | `ConfirmButtonMode \| undefined` | Confirmation interaction mode: `"expand"` morphs in-place into Confirm/Cancel actions; `"hold"` charges a progress bar over `holdDuration`. Default: `"expand"` | | `variant?` | `ConfirmButtonVariant \| undefined` | Visual style variant of the idle trigger button (and the hold button in `"hold"` mode). Default: `"outline"` | | `confirmVariant?` | `ConfirmButtonVariant \| undefined` | Visual style variant of the confirm button in `"expand"` mode. Default: `"danger"` | | `cancelVariant?` | `ConfirmButtonVariant \| undefined` | Visual style variant of the cancel button in `"expand"` mode. Default: `"ghost"` | | `size?` | `"lg" \| "md" \| "sm" \| undefined` | Size of the button and its expanded action capsule. Default: `"md"` | | `confirmLabel?` | `ReactNode` | Label displayed on the confirm button when expanded. Default: `"Confirm"` | | `cancelLabel?` | `ReactNode` | Label displayed on the cancel button when expanded. Default: `"Cancel"` | | `holdingLabel?` | `ReactNode` | Optional label displayed while charging in `"hold"` mode. | | `pendingLabel?` | `ReactNode` | Optional label displayed while an async `onConfirm` Promise is pending. | | `actionsLabel?` | `string \| undefined` | Accessible label for the expanded action group (`role="group"`). Default: `"Confirmation actions"` | | `holdDuration?` | `number \| undefined` | Duration in milliseconds to hold before confirming in `"hold"` mode. Default: `1500` | | `holdTolerance?` | `number \| undefined` | Pointer movement tolerance in pixels before a hold gesture is canceled. Default: `10` | | `timeout?` | `number \| undefined` | Optional auto-disarm timeout in milliseconds for `"expand"` mode. Set to `0` to disable. Default: `0` | | `initialFocus?` | `ConfirmButtonInitialFocus \| undefined` | Which action button receives focus when expanding in `"expand"` mode. Default: `"cancel"` | | `closeOnOutsidePress?` | `boolean \| undefined` | Whether clicking outside disarms `"expand"` mode. Default: `true` | | `armed?` | `boolean \| undefined` | Controlled armed state in `"expand"` mode. | | `defaultArmed?` | `boolean \| undefined` | Initial armed state when uncontrolled in `"expand"` mode. Default: `false` | | `onArmedChange?` | `((armed: boolean, details: ChangeDetails) => void) \| undefined` | Called when the armed state changes in `"expand"` mode. | | `onConfirm?` | `(() => unknown) \| undefined` | Action handler executed upon confirmation. Returning a `Promise` automatically enters `data-pending` and blocks duplicate triggers until it settles. | | `onCancel?` | `((details: ConfirmButtonCancelDetails) => void) \| undefined` | Called when confirmation is canceled (Cancel click, Escape, outside press, timeout, or early hold release). | | `disabled?` | `boolean \| undefined` | Whether the button is disabled. Default: `false` | | `focusableWhenDisabled?` | `boolean \| undefined` | Whether to keep keyboard focus while disabled via `aria-disabled`. Default: `false` | | `pendingAnnouncement?` | `string \| undefined` | Message announced to screen readers when an async confirmation stays pending for more than 1 second; pass an empty string to silence. Default: `"Loading"` | | `armedAnnouncement?` | `string \| undefined` | Optional message announced to screen readers when entering the armed state. | | `controller?` | `ConfirmButtonController \| undefined` | Imperative controller created with `createConfirmButtonController()`. | | `className?` | `string \| ((state: ConfirmButtonState) => string \| undefined) \| undefined` | Custom class name for the root container, as a string or a function of `ConfirmButtonState`. | | `children?` | `ReactNode` | Idle button content. | ## Keyboard Interactions [#keyboard-interactions] | Key | Behavior | | --- | --- | | `Enter` / `Space` | In `expand` mode, arms the button and focuses `initialFocus`. In `hold` mode, hold to charge confirmation. | | `ArrowLeft` / `ArrowRight` | Moves focus between the Confirm and Cancel actions while armed. | | `Escape` | Disarms `expand` mode and restores focus to the trigger, or cancels an active hold gesture. | ## Data Attributes [#data-attributes] | Attribute | Description | | --- | --- | | `data-slot="confirm-button"` | Root container element | | `data-mode="expand" \| "hold"` | Current confirmation mode | | `data-armed` | Present while expanded in `expand` mode | | `data-holding` | Present while pressing in `hold` mode | | `data-held` | Present once `holdDuration` has elapsed | | `data-pending` | Present while an async `onConfirm` Promise is pending | | `data-disabled` | Present when disabled | # DataTable (/docs/components/data-table) ## Import [#import] ```tsx import { DataTable, DataTableColumnHeader, createDataTableColumnHelper, createSelectionColumn, } from "@/components/ui/hacline/components/data-table"; ``` ## Zero-Boilerplate Mode [#zero-boilerplate-mode] Omit `children` to automatically assemble the toolbar, selection bar, table content, and pagination bar from high-level props. Use `createDataTableColumnHelper()` for feature-gated TanStack Table v9 column inference. ```tsx import { Button } from "@/components/ui/hacline/components/button"; import { DataTable, DataTableColumnHeader, createDataTableColumnHelper, createSelectionColumn, } from "@/components/ui/hacline/components/data-table"; const columnHelper = createDataTableColumnHelper(); const columns = [ createSelectionColumn(), ...columnHelper.columns([ columnHelper.accessor("name", { header: ({ column }) => ( ), meta: { label: "Member" }, }), columnHelper.accessor("department", { header: ({ column }) => ( ), }), columnHelper.accessor("monthlyUsage", { header: ({ column }) => ( ), meta: { align: "right", label: "Requests" }, }), ]), ]; export function MembersTable({ data }: { data: Member[] }) { return ( row.id} searchable selectionActions={(rows) => ( )} showViewOptions /> ); } ``` ## Composable Layout & Faceted Filters [#composable-layout--faceted-filters] Pass explicit children (`DataTableToolbar`, `DataTableSearch`, `DataTableFacetedFilter`, `DataTableViewOptions`, `DataTableSelectionBar`, `DataTableContent`, `DataTablePagination`) for full layout control. Pair `DataTableFacetedFilter` with the built-in `filterFn: "inArray"`. ```tsx import { Button } from "@/components/ui/hacline/components/button"; import { DataTable, DataTableContent, DataTableEmpty, DataTableFacetedFilter, DataTablePagination, DataTableSearch, DataTableSelectionBar, DataTableToolbar, DataTableViewOptions, } from "@/components/ui/hacline/components/data-table"; export function ComposableTable({ columns, data }) { return (
{(selectedRows) => ( )} } />
); } ```
## Row Actions Column [#row-actions-column] Use `createActionsColumn()` (or `DataTableRowActions` inside custom cells) for per-row actions. Set `maxInline={0}` for a compact `⋯` dropdown menu, or `maxInline >= 1` to keep primary actions inline while automatically folding remaining items into the overflow menu. Per-row `hidden` / `disabled` predicates, `destructive` styling, and redundant separator cleanup are handled automatically. ```tsx import { DataTable, createActionsColumn, } from "@/components/ui/hacline/components/data-table"; const columns = [ ...baseColumns, createActionsColumn({ maxInline: 1, actions: (row) => [ { label: "Edit", onSelect: (r) => editMember(r.original) }, { label: "Copy email", shortcut: "⌘C", onSelect: (r) => copy(r.original.email), }, { type: "separator" }, { label: "Remove", destructive: true, disabled: row.original.role === "Admin", onSelect: (r) => removeMember(r.original.id), }, ], }), ]; ``` ## Expandable Rows & Tree Sub-Rows [#expandable-rows--tree-sub-rows] Combine `createExpandColumn()` with `getSubRows` for indented hierarchical trees, or `renderSubComponent` for inline row detail panels. ```tsx import { DataTable, createExpandColumn, } from "@/components/ui/hacline/components/data-table"; const columns = [ createExpandColumn({ showExpandAll: true }), ...baseColumns, ]; // Tree hierarchy row.id} getSubRows={(row) => row.subRows} />; // Inline detail panel row.id} renderSubComponent={({ row }) =>
{row.original.notes}
} />; ```
## Logical Column Pinning & Resizing [#logical-column-pinning--resizing] TanStack Table v9 uses logical `start` / `end` pinning regions (`inset-inline-start` / `inset-inline-end`) for automatic LTR and RTL support. Enable `enableColumnResizing` to drag column dividers or double-click a divider to reset width; use `DataTableColumnHeader` with `mode="menu"` to pin or hide columns interactively. ```tsx ``` ## Virtualized Large Datasets [#virtualized-large-datasets] Set `virtualized` and `maxHeight` to render 10,000+ rows smoothly using `@tanstack/react-virtual` v3 (configured with `useFlushSync: false` for React 19 compatibility). ```tsx ``` ## Server-Side (Manual) Mode & Loading States [#server-side-manual-mode--loading-states] Enable `manualSorting`, `manualFiltering`, and `manualPagination` alongside controlled state props and `rowCount`. When `loading` is true, empty tables render aligned skeleton rows while populated tables display a non-blocking top progress bar. ```tsx ``` ## Props [#props] ### DataTableOwnProps | Prop | Type | Description | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `columns` | `DataTableColumnDefList` | TanStack Table v9 column definitions (recommended via `createDataTableColumnHelper()`). | | `data` | `readonly TData[]` | Array of row data records to display. | | `table?` | `DataTableInstance \| undefined` | Optional externally created TanStack Table v9 instance. When provided, `DataTable` uses it directly instead of creating an internal `useTable` instance. | | `getRowId?` | `((originalRow: TData, index: number, parent?: DataTableRow) => string) \| undefined` | Custom row identifier resolver used for selection, expansion, and React keys. | | `getSubRows?` | `((originalRow: TData, index: number) => TData[] \| undefined) \| undefined` | Returns nested child rows for hierarchical / tree table rendering. | | `getRowCanExpand?` | `((row: DataTableRow) => boolean) \| undefined` | Custom predicate deciding whether a row can be expanded (defaults to `true` when `renderSubComponent` is provided, or `row.subRows.length > 0`). | | `density?` | `DataTableDensity \| undefined` | Row density preset controlling vertical cell padding and font rhythm. Default: `"default"` | | `striped?` | `boolean \| undefined` | Applies alternating subtle background striping to body rows. Default: `false` | | `bordered?` | `boolean \| undefined` | Renders vertical cell borders in addition to horizontal row dividers. Default: `false` | | `stickyHeader?` | `boolean \| undefined` | Keeps the table header fixed at the top while scrolling vertically. Default: `false` | | `loading?` | `boolean \| undefined` | Displays skeleton rows when data is empty, or a non-blocking top progress bar while refreshing existing data. Default: `false` | | `enableSorting?` | `boolean \| undefined` | Enables column sorting. Default: `true` | | `enableMultiSort?` | `boolean \| undefined` | Enables multi-column sorting (Shift+click). Default: `true` | | `enableFiltering?` | `boolean \| undefined` | Enables client/server filtering. Default: `true` | | `enableColumnFilters?` | `boolean \| undefined` | Enables per-column filters. Default: `true` | | `enableGlobalFilter?` | `boolean \| undefined` | Enables global search filtering across filterable columns. Default: `true` | | `enablePagination?` | `boolean \| undefined` | Enables pagination slicing and renders `DataTablePagination` in zero-boilerplate mode. Default: `false` | | `enableRowSelection?` | `boolean \| ((row: DataTableRow) => boolean) \| undefined` | Enables row selection. Can also be a predicate per row. Default: `true` | | `enableMultiRowSelection?` | `boolean \| ((row: DataTableRow) => boolean) \| undefined` | Enables selecting multiple rows at once. Set to `false` for single-row radio-like selection. Default: `true` | | `enableExpanding?` | `boolean \| undefined` | Enables row expansion and tree sub-rows. Default: `true` | | `enableHiding?` | `boolean \| undefined` | Enables hiding/showing columns via `DataTableViewOptions`. Default: `true` | | `enableColumnPinning?` | `boolean \| undefined` | Enables logical start/end column pinning (`columnPinning`). Default: `true` | | `enableColumnResizing?` | `boolean \| undefined` | Enables interactive drag-to-resize column headers. Default: `false` | | `columnResizeMode?` | `ColumnResizeMode \| undefined` | When column sizing updates are committed during drag (`"onChange"` or `"onEnd"`). Default: `"onChange"` | | `manualSorting?` | `boolean \| undefined` | Disables client-side sorting so you can sort on the server via `onSortingChange`. Default: `false` | | `manualFiltering?` | `boolean \| undefined` | Disables client-side filtering so you can filter on the server via `onColumnFiltersChange` / `onGlobalFilterChange`. Default: `false` | | `manualPagination?` | `boolean \| undefined` | Disables client-side pagination slicing so you can paginate on the server via `onPaginationChange`. Default: `false` | | `rowCount?` | `number \| undefined` | Total number of records on the server when `manualPagination` is enabled. | | `pageCount?` | `number \| undefined` | Total number of pages on the server when `manualPagination` is enabled. | | `sorting?` | `SortingState \| undefined` | Controlled sorting state. | | `defaultSorting?` | `SortingState \| undefined` | Initial uncontrolled sorting state. | | `onSortingChange?` | `OnChangeFn \| undefined` | Callback fired when sorting state changes. | | `columnFilters?` | `ColumnFiltersState \| undefined` | Controlled column filters state. | | `defaultColumnFilters?` | `ColumnFiltersState \| undefined` | Initial uncontrolled column filters state. | | `onColumnFiltersChange?` | `OnChangeFn \| undefined` | Callback fired when column filters change. | | `globalFilter?` | `string \| undefined` | Controlled global filter query string. | | `defaultGlobalFilter?` | `string \| undefined` | Initial uncontrolled global filter query string. | | `onGlobalFilterChange?` | `OnChangeFn \| undefined` | Callback fired when global filter changes. | | `columnVisibility?` | `ColumnVisibilityState \| undefined` | Controlled column visibility state. | | `defaultColumnVisibility?` | `ColumnVisibilityState \| undefined` | Initial uncontrolled column visibility state. | | `onColumnVisibilityChange?` | `OnChangeFn \| undefined` | Callback fired when column visibility changes. | | `rowSelection?` | `RowSelectionState \| undefined` | Controlled row selection state (`Record`). | | `defaultRowSelection?` | `RowSelectionState \| undefined` | Initial uncontrolled row selection state. | | `onRowSelectionChange?` | `OnChangeFn \| undefined` | Callback fired when row selection changes. | | `pagination?` | `PaginationState \| undefined` | Controlled pagination state (`pageIndex` is 0-indexed). | | `defaultPagination?` | `PaginationState \| undefined` | Initial uncontrolled pagination state. | | `onPaginationChange?` | `OnChangeFn \| undefined` | Callback fired when pagination state changes. | | `expanded?` | `ExpandedState \| undefined` | Controlled expanded rows state. | | `defaultExpanded?` | `ExpandedState \| undefined` | Initial uncontrolled expanded rows state. | | `onExpandedChange?` | `OnChangeFn \| undefined` | Callback fired when expanded rows change. | | `columnPinning?` | `ColumnPinningState \| undefined` | Controlled logical column pinning state (`{ start: string[]; end: string[] }`). | | `defaultColumnPinning?` | `ColumnPinningState \| undefined` | Initial uncontrolled logical column pinning state. | | `onColumnPinningChange?` | `OnChangeFn \| undefined` | Callback fired when column pinning changes. | | `columnSizing?` | `ColumnSizingState \| undefined` | Controlled column sizing state (`Record`). | | `defaultColumnSizing?` | `ColumnSizingState \| undefined` | Initial uncontrolled column sizing state. | | `onColumnSizingChange?` | `OnChangeFn \| undefined` | Callback fired when column sizing changes. | | `virtualized?` | `boolean \| undefined` | Enables `@tanstack/react-virtual` v3 row virtualization for large datasets (10,000+ rows). Default: `false` | | `estimateRowHeight?` | `number \| undefined` | Estimated height in pixels for each virtualized row (defaults to 36 / 44 / 52 based on `density`). | | `overscan?` | `number \| undefined` | Number of extra rows rendered above and below the scroll viewport when `virtualized` is true. Default: `8` | | `maxHeight?` | `string \| number \| undefined` | Maximum height of the scrollable table container (required or defaults to `480px` when `virtualized` is true). | | `searchable?` | `string \| boolean \| undefined` | Zero-boilerplate shortcut: renders `DataTableSearch` in the auto-generated toolbar. Pass `true` for global search, or a column ID string to filter that column. Default: `false` | | `searchPlaceholder?` | `string \| undefined` | Placeholder override for the auto-generated search input when `searchable` is enabled. | | `showViewOptions?` | `boolean \| undefined` | Zero-boilerplate shortcut: renders `DataTableViewOptions` in the auto-generated toolbar. Default: `false` | | `pageSizeOptions?` | `readonly number[] \| undefined` | Available page size choices for `DataTablePagination`. Default: `[10, 20, 50, 100]` | | `toolbar?` | `ReactNode` | Extra toolbar content rendered on the right side in zero-boilerplate mode. | | `selectionActions?` | `((selectedRows: DataTableRow[]) => ReactNode) \| undefined` | Zero-boilerplate shortcut: renders `DataTableSelectionBar` with custom bulk actions when rows are selected. | | `empty?` | `ReactNode` | Custom empty state element displayed when the table has zero rows. | | `renderSubComponent?` | `((props: { row: DataTableRow; }) => ReactNode) \| undefined` | Detail panel renderer shown directly below an expanded row (`row.getIsExpanded()`). | | `onRowClick?` | `((row: DataTableRow, event: MouseEvent) => void) \| undefined` | Row click handler. Automatically ignores clicks originating from interactive descendants (`button`, `a`, `input`, `[role="checkbox"]`). | | `getRowClassName?` | `((row: DataTableRow) => string \| undefined) \| undefined` | Optional per-row class name resolver. | | `labels?` | `Partial \| undefined` | Localization overrides for all built-in UI copy and ARIA labels. | | `tableOptions?` | `Partial) => () => RowModel; facetedRowModel: (table: Table, columnId: string) => () => RowModel; facetedUniqueValues: (table: Table, columnId: string) => () => Map; filterFns: { arrIncludes: CreatedFilterFn; arrIncludesAll: CreatedFilterFn; arrHas: CreatedFilterFn; arrIncludesSome: CreatedFilterFn; between: CreatedFilterFn; betweenInclusive: CreatedFilterFn; empty: CreatedFilterFn; endsWith: CreatedFilterFn; equals: CreatedFilterFn; equalsString: CreatedFilterFn; equalsStringSensitive: CreatedFilterFn; inDateRange: CreatedFilterFn; inNumberRange: CreatedFilterFn; includesString: CreatedFilterFn; includesStringSensitive: CreatedFilterFn; notEmpty: CreatedFilterFn; startsWith: CreatedFilterFn; weakEquals: CreatedFilterFn; inArray: CreatedFilterFn; }; filteredRowModel: (table: Table) => () => RowModel; globalFilteringFeature: TableFeature; paginatedRowModel: (table: Table) => () => RowModel; rowExpandingFeature: TableFeature; rowPaginationFeature: TableFeature; rowSelectionFeature: TableFeature; rowSortingFeature: TableFeature; sortFns: { alphanumeric: CreatedSortFn; alphanumericCaseSensitive: CreatedSortFn; basic: CreatedSortFn; datetime: CreatedSortFn; text: CreatedSortFn; textCaseSensitive: CreatedSortFn; }; sortedRowModel: (table: Table) => () => RowModel; }, TData>, "columns" \| "data" \| "features" \| "state">> \| undefined` | Escape hatch to forward any additional TanStack Table v9 `useTable` options. | | `children?` | `ReactNode` | Composable children (`DataTableToolbar`, `DataTableSelectionBar`, `DataTableContent`, `DataTablePagination`, etc.). Omit for zero-boilerplate rendering. | | `className?` | `string \| undefined` | Custom class name for the root `DataTable` container. | ## Data Attributes [#data-attributes] | Attribute | Description | | --- | --- | | `data-slot="data-table"` | Root container element | | `data-slot="data-table-toolbar"` | Toolbar layout container | | `data-slot="data-table-selection-bar"` | Bulk selection action bar | | `data-slot="data-table-content"` | Scrollable table container (`data-virtualized`, `data-loading`) | | `data-slot="data-table-pagination"` | Pagination & page-size footer bar | | `data-slot="table"` | Semantic `` primitive (`data-density`, `data-striped`, `data-bordered`, `data-sticky-header`) | | `data-pinned="start" \| "end"` | Logical pinned column cells (`data-last-pinned-start`, `data-first-pinned-end`) | | `data-resizing` | Present on a column header and resize handle during drag | | `data-selected` | Present on selected body rows | | `data-expanded` | Present on expanded body rows and disclosure triggers | # DateInput (/docs/components/date-input) ## Usage [#usage] Edit the year, month, or day segment with digits or arrow keys, or paste a complete date into any segment. Once all fields are filled, an ISO-formatted value is emitted. ```tsx "use client"; import { useState } from "react"; import { DateInput } from "@/components/ui/hacline/components/date-input"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; export const Example = () => { const [date, setDate] = useState("2026-12-15"); return ( Project start date ISO date: {date ?? "Incomplete"} ); }; ``` ### Locale Segment Order and Bounds [#locale-segment-order-and-bounds] UK dates (`en-GB`) follow day, month, year order while keeping the submitted value in ISO format. Use `min` and `max` to constrain the valid expense date range. ```tsx "use client"; import { DateInput } from "@/components/ui/hacline/components/date-input"; import { Field, FieldDescription, FieldLabel, } from "@/components/ui/hacline/components/field"; export const Example = () => ( Expense date Choose a date in December 2026. ); ``` ### Variants, Sizes & Clearable Addons [#variants-sizes--clearable-addons] Customize appearance with `variant` (`"default"` / `"filled"`), `size` (`"sm"` / `"md"` / `"lg"`), leading `prefix` icons, `clearable` reset buttons, and `granularity="minute"` for date-and-time editing. ```tsx "use client"; import { DateInput } from "@/components/ui/hacline/components/date-input"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; const CalendarIcon = () => ( ); export const Example = () => (
Release date (prefix + clearable) } /> Invoice date (filled + small) Meeting date & time (large)
); ```
## Parts [#parts] Pass a custom `children` render function when you need full segment layout control. ## Props [#props] ### DateInputOwnProps | Prop | Type | Description | | ---------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | | `variant?` | `"default" \| "filled" \| null \| undefined` | Visual style variant of the date input. Default: `"default"` | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size of the date input. Default: `"md"` | | `prefix?` | `ReactNode` | Leading prefix content (such as a calendar icon) rendered inside the container when `children` is omitted. | | `suffix?` | `ReactNode` | Trailing suffix content rendered inside the container when `children` is omitted. | | `clearable?` | `boolean \| undefined` | Displays a clear button when any segment has a value (when `children` is omitted). Default: `false` | | `clearLabel?` | `string \| undefined` | Accessible label for the built-in clear button. Default: `"Clear date"` | | `value?` | `string \| null \| undefined` | Controlled ISO date value (for example `"2026-12-15"` or `"2026-12-15T14:30"`), or `null`. | | `defaultValue?` | `string \| null \| undefined` | Initial ISO date value when uncontrolled. | | `onValueChange?` | `((value: string \| null, details: ChangeDetails) => void) \| undefined` | Callback fired when the complete date value changes or becomes incomplete (`null`). | | `locale?` | `string \| undefined` | Locale used to determine segment order and separators (for example `"en-US"`, `"en-GB"`, `"zh-CN"`). | | `granularity?` | `DateInputGranularity \| undefined` | Smallest editable unit (`"day"` for date-only, or `"hour"` / `"minute"` / `"second"` to include time). Default: `"day"` | | `hourCycle?` | `HourCycle \| undefined` | 12-hour or 24-hour clock when time segments are shown. | | `min?` | `string \| undefined` | Earliest allowed ISO date (values earlier than `min` are marked invalid). | | `max?` | `string \| undefined` | Latest allowed ISO date (values later than `max` are marked invalid). | | `unavailable?` | `DateMatchers \| undefined` | Dates that cannot be selected (ISO dates, ranges, weekdays, or predicate). | | `disabled?` | `boolean \| undefined` | Disables all date segments. Default: `false` | | `readOnly?` | `boolean \| undefined` | Makes the date input read-only while remaining focusable. Default: `false` | | `required?` | `boolean \| undefined` | Marks the date input as required for form validation. Default: `false` | | `name?` | `string \| undefined` | Form field name for the hidden ISO date input. | | `className?` | `string \| ((state: DateInputState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `DateInputState`. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/date-input). # DatePicker (/docs/components/date-picker) ## Usage [#usage] Omit `children` for a unified input shell with an inline calendar icon trigger, optional `clearable` reset button, format `hint`, and anchored calendar popover. ```tsx "use client"; import { DatePicker } from "@/components/ui/hacline/components/date-picker"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; export const Example = () => ( Delivery deadline ); ``` ### Selecting Start and End Dates [#selecting-start-and-end-dates] Set `mode="range"` to render start and end inputs inside one shared container with an inline calendar trigger; the popover closes once both endpoints are chosen. ```tsx "use client"; import { DatePicker } from "@/components/ui/hacline/components/date-picker"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; export const Example = () => ( Leave dates ); ``` ### Variants & Sizes [#variants--sizes] Customize appearance with `variant` (`"default"` / `"filled"`) and `size` (`"sm"` / `"md"` / `"lg"`). ```tsx "use client"; import { DatePicker } from "@/components/ui/hacline/components/date-picker"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; export const Example = () => (
Billing date (filled + small) Launch date (large)
); ```
## Parts [#parts] Pass custom `children` when you need full layout control over the input, trigger, presets, or calendar popup. ## Props [#props] ### DatePickerOwnProps | Prop | Type | Description | | ----------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | | `variant?` | `"default" \| "filled" \| null \| undefined` | Visual style variant of the unified input shell when `children` is omitted. Default: `"default"` | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size of the unified input shell when `children` is omitted. Default: `"md"` | | `placeholder?` | `string \| undefined` | Placeholder text for the date input (or start input in `mode="range"`) when `children` is omitted. | | `endPlaceholder?` | `string \| undefined` | Placeholder text for the end date input in `mode="range"` when `children` is omitted. | | `inputLabel?` | `string \| undefined` | Accessible label for the date input (or start input in `mode="range"`) when `children` is omitted. | | `endInputLabel?` | `string \| undefined` | Accessible label for the end date input in `mode="range"` when `children` is omitted. | | `triggerLabel?` | `string \| undefined` | Accessible label for the inline calendar trigger button when `children` is omitted. | | `clearable?` | `boolean \| undefined` | Displays an inline clear button inside the input shell when a value is selected (when `children` is omitted). Default: `false` | | `clearLabel?` | `string \| undefined` | Accessible label for the inline clear button. Default: `"Clear date"` | | `hint?` | `ReactNode` | Format hint rendered below the input shell when `children` is omitted. Pass `true` for the locale format hint, or a custom node. | | `prefix?` | `ReactNode` | Leading prefix content rendered inside the unified input shell when `children` is omitted. | | `align?` | `Align \| undefined` | Horizontal alignment of the calendar popover relative to the input shell. Default: `"start"` | | `sideOffset?` | `number \| undefined` | Distance in pixels between the input shell and the calendar popover. Default: `6` | | `mode?` | `DatePickerMode \| undefined` | Selection mode (`"single"`, `"multiple"`, or `"range"`). Default: `"single"` | | `value?` | `DatePickerValue \| undefined` | Controlled ISO date value (or `[start, end]` tuple in `mode="range"`). | | `defaultValue?` | `DatePickerValue \| undefined` | Initial ISO date value when uncontrolled. | | `onValueChange?` | `((value: DatePickerValue, details: ChangeDetails) => void) \| undefined` | Callback fired whenever the selected date value changes. | | `locale?` | `string \| undefined` | Locale used to parse and format displayed dates (for example `"en-US"`, `"en-GB"`, `"zh-CN"`). | | `min?` | `string \| undefined` | Earliest selectable ISO date. | | `max?` | `string \| undefined` | Latest selectable ISO date. | | `disabled?` | `boolean \| undefined` | Disables the date picker input and calendar trigger. Default: `false` | | `readOnly?` | `boolean \| undefined` | Makes the date picker read-only. Default: `false` | | `name?` | `string \| undefined` | Form field name for the hidden ISO date input. | | `className?` | `string \| ((state: DatePickerState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `DatePickerState`. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/date-picker). # Dialog (/docs/components/dialog) ## Imports [#imports] ```tsx import { Dialog, DialogBackdrop, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/hacline/components/dialog"; ``` ## Basic Usage [#basic-usage] Compose `DialogTrigger` and `DialogClose` with `render={ Controlled mode Open and close state is controlled externally. }> Close ); } ``` ## Props [#props] ### Dialog [#dialog] ### DialogOwnProps | Prop | Type | Description | | ---------------------- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `open?` | `boolean \| undefined` | Controlled open state. | | `defaultOpen?` | `boolean \| undefined` | Default open state when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: DialogOpenChangeDetails) => void) \| undefined` | Callback fired when the open state changes; call `details.cancel()` to prevent closing. | | `presentation?` | `PresentationSetting<"dialog"> \| undefined` | Presentation mode: `"dialog"`, `"sheet"` (bottom drawer supporting swipe-down dismissal), or `"auto"` (switches to a sheet on small touch screens). Default: `"dialog"` | | `modal?` | `"trap-focus" \| boolean \| undefined` | Modal behavior: `true` locks the background, `"trap-focus"` traps focus only, and `false` is non-modal. Default: `true` | | `dismissible?` | `boolean \| undefined` | Whether Escape, outside presses, or gestures can close the dialog; set to `false` to prevent accidental dismissal on unsaved forms or destructive confirmations. Default: `true` | | `onDismissAttempt?` | `((details: DialogDismissAttemptDetails) => void) \| undefined` | Callback fired when a dismissal attempt is blocked (such as when `dismissible={false}`). | | `closeOnOutsidePress?` | `boolean \| undefined` | Whether pressing the backdrop or outside the dialog closes it. Default: `true` | | `controller?` | `PopupController \| undefined` | External controller instance for opening the dialog programmatically or from outside triggers. | | `container?` | `DocumentFragment \| Element \| null \| undefined` | Mount container for the dialog; renders in the top layer by default. | ### DialogBackdrop [#dialogbackdrop] ### DialogBackdropOwnProps | Prop | Type | Description | | ------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | | `variant?` | `"blur" \| "dim" \| "transparent" \| null \| undefined` | Visual style variant of the backdrop: `dim` (translucent dark), `blur` (frosted blur), or `transparent`. Default: `"dim"` | | `className?` | `string \| ((state: DialogBackdropState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `DialogBackdropState`. | ### DialogContent [#dialogcontent] ### DialogContentOwnProps | Prop | Type | Description | | --------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | | `size?` | `"full" \| "lg" \| "md" \| "sm" \| "xl" \| null \| undefined` | Width and fullscreen size preset for the dialog content. Default: `"md"` | | `placement?` | `"bottom" \| "center" \| "top" \| null \| undefined` | Viewport placement of the dialog: `center`, `top`, or `bottom`. Default: `"center"` | | `initialFocus?` | `DialogInitialFocus \| undefined` | Target element, selector, or `"content"` to focus when the dialog opens. | | `finalFocus?` | `PopupFocusTarget \| undefined` | Target element or selector to return focus to after closing; defaults to the trigger. | | `keepMounted?` | `boolean \| undefined` | Whether to keep the dialog mounted in the DOM when closed. Default: `false` | | `className?` | `string \| ((state: DialogContentState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `DialogContentState`. | ## Data Attributes [#data-attributes] | Attribute | Description | | --- | --- | | `data-slot="dialog-backdrop"` / `"dialog-content"` | Element identifiers for backdrop and content | | `data-open` / `data-closed` | Dialog open or closed state | | `data-presentation="dialog" \| "sheet"` | Actual active presentation mode | | `data-starting-style` / `data-ending-style` | Entering first-frame and exiting transition markers | # Drawer (/docs/components/drawer) ## Usage [#usage] Open the delivery details, then dismiss via the close button, Escape, or dragging downward. Specify the screen edge with `side` and configure stop positions with `snapPoints`. ```tsx "use client"; import { Drawer, DrawerBackdrop, DrawerClose, DrawerContent, DrawerDescription, DrawerHandle, DrawerTitle, DrawerTrigger, } from "@/components/ui/hacline/components/drawer"; export const Example = () => ( Open delivery details Delivery details Packages arrive on weekdays between 09:00 and 18:00. Close delivery details ); ``` ### Opening from the Right [#opening-from-the-right] Set `side="right"` to display side panel details. Focus management and closing with Escape remain supported. ```tsx "use client"; import { Drawer, DrawerBackdrop, DrawerClose, DrawerContent, DrawerDescription, DrawerTitle, DrawerTrigger, } from "@/components/ui/hacline/components/drawer"; export const Example = () => ( View members Project members Review users and permissions in this project.
Alice Lin
Maintainer
Noah Zhou
Viewer
Close members
); ```
## Parts [#parts] ## Props [#props] ### DrawerOptions The options `drawer` takes. A component takes them as props on its root. | Prop | Type | Description | | ----------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `container?` | `DocumentFragment \| Element \| null \| undefined` | Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | | `open?` | `boolean \| undefined` | Whether the dialog is open. Pass it to control the dialog. | | `defaultOpen?` | `boolean \| undefined` | Whether the dialog starts open, when uncontrolled. Focus moves into it once it's on the page. Default: `false` | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the dialog has finished opening or closing, after any animation. | | `dismissible?` | `boolean \| undefined` | Whether Escape, an outside press and Android's back gesture can close the dialog. Close parts, triggers and the controller always can. Pass `false` while a form has unsaved changes, and ask in `onDismissAttempt`. Default: `true` | | `persistentElements?` | `(string \| Element)[] \| (() => Element[]) \| undefined` | Elements that stay usable while the dialog makes the page inert, like a chat launcher or a password manager's button. Elements, CSS selectors, or a function that returns elements, read when the dialog opens. Presses on them never close it. | | `pendingAnnouncement?` | `string \| undefined` | What screen readers hear once a Close part's action has been running for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing. Default: `"Loading"` | | `onOpenChange?` | `((open: boolean, details: DialogOpenChangeDetails) => void) \| undefined` | Runs when the drawer wants to open or close. `details.reason` says why, `"swipe"` included, `details.cancel()` stops it, and `details.returnValue` carries what closed it. | | `onPayloadChange?` | `((payload: unknown, details: ChangeDetails) => void) \| undefined` | Runs when the payload the content shows changes: a trigger with another payload opens the drawer, or takes a non-modal drawer over while it's open, which fires no `onOpenChange`, and so does a controller's `open({ payload })` on the open drawer. `details.cancel()` keeps the previous payload. | | `onDismissAttempt?` | `((details: DrawerDismissAttemptDetails) => void) \| undefined` | Runs when a dismissal was refused because `dismissible` is false, including a swipe. The drawer resists and springs back. Ask "Discard changes?" here. | | `modal?` | `"trap-focus" \| boolean \| undefined` | `true`: the rest of the page is inert and doesn't scroll, focus is trapped, and an outside press only closes the drawer. `"trap-focus"`: traps focus and leaves the page usable. `false`: a drawer beside the page. See `modalAbove` to make it modal only above a snap point. Default: `true` | | `closeOnOutsidePress?` | `boolean \| undefined` | Whether pressing outside the drawer, like on its backdrop, closes it. Default: `true, or false while the drawer isn't modal` | | `controller?` | `DrawerController \| undefined` | Opens, closes and moves the drawer from anywhere, and connects triggers and outlets outside it. Create one with `createDrawerController()`. | | `snapPoints?` | `SnapPoint[] \| undefined` | Where the drawer can rest, from the edge it comes from: a fraction of the screen up to 1, pixels above 1, `"…px"`, `"…rem"`, `"…%"`, or `"content"` for its own size. None can be larger than the drawer, which you size with CSS. Default: `["content"]` | | `snapPoint?` | `SnapPoint \| null \| undefined` | The snap point it rests on. Pass it to control it. | | `defaultSnapPoint?` | `SnapPoint \| undefined` | The snap point it opens at, when uncontrolled. It opens there again each time. Default: `` the first of `snapPoints` `` | | `onSnapPointChange?` | `((snapPoint: SnapPoint, details: ChangeDetails) => void) \| undefined` | Runs when the drawer moves to another snap point. `details.reason` says why: a swipe, the handle, the keyboard, a resize or the controller. | | `side?` | `Side \| undefined` | The edge it comes from. `"start"` and `"end"` follow the writing direction. Default: `"bottom"` | | `modalAbove?` | `SnapPoint \| undefined` | At or below this snap point the page stays usable and undimmed, like Maps: no inert page, no scroll lock, no `aria-modal`, and presses beside the drawer reach the page. Above it, `modal` applies. Changes once the drawer comes to rest. | | `driver?` | `SheetDriverName \| undefined` | How it moves. `"pointer"` follows touch, mouse and pen with a spring fitted to iOS. `"scroll-snap"` uses the browser's own scrolling for bottom drawers. `"auto"` picks scroll snap for a bottom drawer on a touch screen, unless `modalAbove` is set or `expandOnScroll` is false, and the pointer driver otherwise. Default: `"auto"` | | `expandOnScroll?` | `boolean \| undefined` | Whether dragging toward a larger snap point on scrollable content moves the drawer first, until it's at its largest. Default: `true` | | `physics?` | `Partial \| undefined` | Overrides the motion: spring, projection, rubber band and dim. Starts from `sheetPhysics.ios`. | | `themeColor?` | `boolean \| undefined` | Whether `` dims with the backdrop, so Safari's toolbars darken too. Written where motion starts and ends, never per frame. Default: `false` | | `preventEdgeSwipe?` | `boolean \| undefined` | Whether presses on the drawer near the screen's left and right edges are kept from starting iOS Safari's back and forward swipe. Taps right at those edges then don't click. Read when the content mounts. Default: `false` | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/drawer). # Field (/docs/components/field) ## Imports [#imports] ```tsx import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet, } from "@/components/ui/hacline/components/field"; ``` ## Basic Usage [#basic-usage] `Field` automatically wires `id`, `for`, and `aria-describedby` relationships between the inner control, `FieldLabel`, and `FieldDescription`. When the control has `required`, the label automatically displays a required indicator. ```tsx import { Field, FieldDescription, FieldLabel, } from "@/components/ui/hacline/components/field"; import { Input } from "@/components/ui/hacline/components/input"; export function UsernameField() { return ( Username Used as the unique path for your public profile. ); } ``` ### Validation & Error Messages [#validation--error-messages] Combine native HTML validation constraints (`required`, `type="email"`, `pattern`) with the `match` prop on `FieldError` to display custom error messages on failed submission and clear them automatically once input becomes valid. ```tsx
event.preventDefault()}> Work email Please enter your work email. Please enter a valid email address. ```
### Field Grouping (FieldSet) [#field-grouping-fieldset] Use `FieldSet`, `FieldLegend`, and `FieldGroup` to organize related fields and disable them together at the group level with `disabled`. ```tsx
Project basics Project name Deployment region
```
## Props [#props] ### Field [#field] ### FieldOwnProps | Prop | Type | Description | | -------------- | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `name?` | `string \| undefined` | Form submission name inherited by inner controls when they do not specify their own `name`. | | `orientation?` | `"horizontal" \| "vertical" \| null \| undefined` | Layout orientation of the field: `vertical` (stacked) or `horizontal` (inline, suited for switches and checkboxes). Default: `"vertical"` | | `disabled?` | `boolean \| undefined` | Disables the entire field and its inner form controls. Default: `false` | | `invalid?` | `boolean \| undefined` | Manually controls the validation error state (for server errors or form libraries); omit to follow native browser validation. | | `className?` | `string \| ((state: FieldState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `FieldState`. | ### FieldError [#fielderror] ### FieldErrorOwnProps | Prop | Type | Description | | ------------ | -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `match?` | `boolean \| ValidityKey \| undefined` | Validation condition that triggers display: pass a `ValidityKey` (such as `"valueMissing"` or `"typeMismatch"`) for an exact match, or `true` to always show while `invalid`. | | `className?` | `string \| ((state: FieldErrorState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `FieldErrorState`. | # FileInput (/docs/components/file-input) ## Usage [#usage] `` renders a ready-to-use file card with image thumbnails, semantic file icons, file size, and a remove button by default. Format validation errors cleanly with `formatFileRejection`. ```tsx "use client"; import { Upload } from "lucide-react"; import { useState } from "react"; import { FileInput, FileInputDropzone, FileInputList, FileInputTrigger, formatFileRejection, } from "@/components/ui/hacline/components/file-input"; export const Example = () => { const [feedback, setFeedback] = useState(""); return ( { const [first] = rejected; if (first) { setFeedback(formatFileRejection(first)); } }} onValueChange={() => setFeedback("")} > {feedback ? ( {feedback} ) : null} ); }; ``` ### Async Upload Queue (`useFileUpload`) [#async-upload-queue-usefileupload] Pair `FileInput` with `useFileUpload` to manage concurrent uploads, per-file progress bars, cancellation via `AbortController`, and retries. Connect `onValueChange={uploader.syncFiles}` to keep the queue automatically synchronized. ```tsx "use client"; import { useMemo } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { createFileInputController, FileInput, FileInputDropzone, FileInputItem, FileInputItemName, FileInputItemPreview, FileInputItemRemove, FileInputItemSize, FileInputList, FileInputTrigger, } from "@/components/ui/hacline/components/file-input"; import { Progress, ProgressIndicator, ProgressTrack, } from "@/components/ui/hacline/components/progress"; import { useFileUpload } from "@/components/ui/hacline/hooks/use-file-upload"; const UPLOAD_STEPS = [20, 48, 76, 100] as const; const STEP_DELAY_MS = 220; const simulateUpload = ( file: File, { onProgress, signal, }: { onProgress: (percent: number) => void; signal: AbortSignal } ) => // oxlint-disable-next-line promise/avoid-new -- Simulate staged network upload with abort support. new Promise<{ url: string }>((resolve, reject) => { let stepIndex = 0; const handleAbort = () => { reject(new DOMException("Upload aborted", "AbortError")); }; if (signal.aborted) { handleAbort(); return; } signal.addEventListener("abort", handleAbort, { once: true }); const tick = () => { if (signal.aborted) { return; } const next = UPLOAD_STEPS[stepIndex]; stepIndex += 1; if (next !== undefined) { onProgress(next); } if (stepIndex >= UPLOAD_STEPS.length) { signal.removeEventListener("abort", handleAbort); resolve({ url: `/uploads/${file.name}` }); return; } setTimeout(tick, STEP_DELAY_MS); }; setTimeout(tick, STEP_DELAY_MS); }); const createSampleFiles = () => [ new File(["# Release Notes\nAll checks passed."], "release-notes.md", { type: "text/markdown", }), new File(['{ "name": "hacline" }'], "tokens.json", { type: "application/json", }), ]; const statusLabel = (status: string, progress: number) => { if (status === "uploading") { return `${progress}%`; } if (status === "success") { return "Uploaded"; } if (status === "error") { return "Failed"; } if (status === "canceled") { return "Canceled"; } return "Queued"; }; export const Example = () => { const controller = useMemo(() => createFileInputController(), []); const uploader = useFileUpload({ concurrency: 2, upload: simulateUpload, }); return (
{ uploader.syncFiles(files); }} > Drop files or load samples to test concurrent uploads
Browse
{({ file }) => { const entry = uploader.getEntry(file); const status = entry?.status ?? "idle"; const progress = entry?.progress ?? 0; return ( <>
· {statusLabel(status, progress)}
{entry && status === "uploading" ? ( ) : null} {entry && (status === "error" || status === "canceled") ? ( ) : null}
{status === "uploading" ? ( ) : null} ); }}
); }; ```
### Reading Files in a Form [#reading-files-in-a-form] Set `name` and `required` on the component. On form submission, read the `File` objects directly from `FormData`. ```tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { FileInput, FileInputTrigger, } from "@/components/ui/hacline/components/file-input"; export const Example = () => { const [filename, setFilename] = useState(""); const [submitted, setSubmitted] = useState(""); return (
{ const file = data.get("brief"); if (file instanceof File) { setSubmitted(file.name); } }} className="grid w-full max-w-xs gap-2" > setFilename(files[0]?.name ?? "")} required > Choose project brief

{filename || "Supports TXT or Markdown"}

{submitted && ( Loaded {submitted} )} ); }; ```
## Parts [#parts] ## Props [#props] ### FileInputOptions The options `fileInput` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `accept?` | `string \| readonly string[] \| undefined` | The files to accept, like the `accept` attribute: MIME types (`"image/png"`), wildcards (`"image/*"`) and extensions (`".pdf"`), in a comma-separated string or an array. Without it, any file. | | `maxFiles?` | `number \| undefined` | The most files accepted at a time. The first ones that pass the other checks are accepted, and the rest are rejected. | | `maxSize?` | `number \| undefined` | The largest size accepted, in bytes. | | `minSize?` | `number \| undefined` | The smallest size accepted, in bytes. | | `validate?` | `((file: File, batch: { accepted: readonly File[]; }) => string \| null \| undefined \| void) \| undefined` | A check of your own. Return a reason, like `"duplicate"`, to reject the file, or nothing to accept it. `accepted` holds the files of the same choice, drop or paste accepted before this one. | | `value?` | `File[] \| undefined` | The files, to control the file input. | | `defaultValue?` | `File[] \| undefined` | The files at first, when uncontrolled. A form reset returns to them. Default: `[]` | | `onValueChange?` | `((value: File[], details: FileInputValueChangeDetails) => void) \| undefined` | Runs when files are added or removed, with what changed in the details. `details.cancel()` stops it. | | `onReject?` | `((rejected: FileRejection[], details: CommitDetails) => void) \| undefined` | Runs when files fail the checks, after `onValueChange`, with every reason each failed, even when none were accepted. | | `multiple?` | `boolean \| undefined` | Holds more than one file. New files join the ones it has, up to `maxFiles` in all. Without it, a new file replaces the one it has. Default: `false` | | `directory?` | `boolean \| undefined` | Picks a whole folder, with every file inside it. Turns on `multiple`. | | `capture?` | `"environment" \| "user" \| boolean \| undefined` | Opens the camera on phones instead of the files: `"user"` for the front camera, `"environment"` for the back one, or `true` for the default one. | | `name?` | `string \| undefined` | The name the files submit under. Without one, nothing is submitted. | | `form?` | `string \| undefined` | The id of a form to belong to, when it isn't inside that form. | | `required?` | `boolean \| undefined` | Blocks form submission until it holds a file, with the browser's own message. | | `disabled?` | `boolean \| undefined` | Disables it like a native control: the trigger can't be focused or used, drops and pastes are ignored, and nothing is submitted. | | `announcement?` | `((change: FileInputChange) => string \| null \| undefined) \| undefined` | What screen readers hear after a change. Return null for nothing. Default: `"2 files accepted. 1 file rejected.", or "photo.png removed."` | | `controller?` | `{ getValue: () => readonly File[]; setValue: (files: readonly File[], options?: FileInputChangeOptions) => boolean; addFiles: (files: readonly File[] \| FileList, options?: FileInputChangeOptions) => boolean; removeFile: (file: File, options?: FileInputChangeOptions) => boolean; clear: (options?: FileInputChangeOptions) => boolean; open: () => boolean; focus: () => void; isDragging: () => boolean; } \| undefined` | Adds and removes files from anywhere. Create one with `createFileInputController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/file-input). # HoverCard (/docs/components/hover-card) ## Usage [#usage] Hover over or focus "Avatar documentation" to preview its summary, or click the link to open the full documentation page. ```tsx "use client"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/ui/hacline/components/hover-card"; export const Example = () => ( Avatar documentation Avatar

Displays a user or project image, with initials shown while loading.

); ```
### Placement & Arrow [#placement--arrow] Request placement with `side` and `align`, and add `HoverCardArrow` to indicate the anchor point. ```tsx "use client"; import { HoverCard, HoverCardArrow, HoverCardContent, HoverCardTrigger, } from "@/components/ui/hacline/components/hover-card"; export const Example = () => ( View theme tokens

Colors, radii, and shadows

Theme tokens support both light and dark modes.

); ```
## Parts [#parts] ## Props [#props] ### HoverCardOptions The options `hoverCard` takes. A component takes them as props on its root. | Prop | Type | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `container?` | `DocumentFragment \| Element \| null \| undefined` | Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent. | | `open?` | `boolean \| undefined` | Whether the card is open. Pass it to control the card. | | `defaultOpen?` | `boolean \| undefined` | Whether the card starts open, when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: ChangeDetails) => void) \| undefined` | Runs when the card wants to open or close. `details.reason` says why, and `details.cancel()` stops it. | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the card has finished opening or closing, after any animation. | | `onPayloadChange?` | `((payload: unknown, details: ChangeDetails) => void) \| undefined` | Runs when the payload the content shows changes: a trigger with another payload opens the card, or takes the open card over, which fires no `onOpenChange`, and so does a controller's `open({ payload })` on the open card. `details.cancel()` keeps the previous payload. | | `delay?` | `number \| undefined` | Milliseconds the pointer rests on the trigger, or keyboard focus stays on it, before the card opens. Default: `600` | | `closeDelay?` | `number \| undefined` | Milliseconds before the card closes once the pointer leaves the trigger and the card. Default: `300` | | `disabled?` | `boolean \| undefined` | Stops the card from opening. The trigger keeps working as a link. Default: `false` | | `controller?` | `PopupController \| undefined` | Opens, closes and inspects the card from anywhere, and connects triggers outside it. Create one with `createHoverCardController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/hover-card). # ImageCropper (/docs/components/image-cropper) ## Usage [#usage] Drag the selection or resize the bottom-right handle, and adjust zoom or rotation. Current dimensions come from the image pixel coordinates provided by `onCropChange`, and `cropImage` exports the selection as a file. ```tsx "use client"; import { useState } from "react"; import { ImageCropper, ImageCropperGrid, ImageCropperHandle, ImageCropperImage, ImageCropperRotate, ImageCropperSelection, ImageCropperViewport, ImageCropperZoom, } from "@/components/ui/hacline/components/image-cropper"; import type { ImageCrop } from "@/components/ui/hacline/components/image-cropper"; export const Example = () => { const [crop, setCrop] = useState(); return (
Rotate 90°
{crop && ( Crop size: {Math.round(crop.width)} × {Math.round(crop.height)} px )}
); }; ```
### Exporting a Circular Avatar [#exporting-a-circular-avatar] Use `shape="circle"` to display a circular crop selection, then call `cropImage` to generate a PNG with transparent corners. ```tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { cropImage, ImageCropper, ImageCropperImage, ImageCropperSelection, ImageCropperViewport, ImageCropperZoom, } from "@/components/ui/hacline/components/image-cropper"; import type { ImageCrop } from "@/components/ui/hacline/components/image-cropper"; const IMAGE = "/examples/alpine-lake.jpg"; const INITIAL_CROP: ImageCrop = { height: 400, width: 400, x: 280, y: 120 }; export const Example = () => { const [crop, setCrop] = useState(INITIAL_CROP); const [file, setFile] = useState(); return (
{file && ( Generated {file.name}, {Math.round(file.size / 1024)} KB )}
); }; ```
## Parts [#parts] ## Props [#props] ### ImageCropperOptions The options `imageCropper` takes. A component takes them as props on its root. | Prop | Type | Description | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `src?` | `string \| undefined` | The image's URL, like an object URL for a file someone picked. | | `crop?` | `ImageCrop \| undefined` | The crop, in the image's own pixels, from the top left of the image as it shows once turned and flipped, with its `rotation`, `flipX` and `flipY`. Pass it straight to `cropImage`. Pass it to control the cropper. | | `defaultCrop?` | `ImageCrop \| undefined` | The crop at first, when uncontrolled. Default: `` once the image loads, a crop at `aspectRatio` in the middle: four fifths of the largest in a box, the largest in a frame `` | | `onCropChange?` | `((crop: Required, details: ImageCropperCropChangeDetails) => void) \| undefined` | Runs while the crop changes: on every step of a drag, a key or the wheel, and once an image loads. `details.cancel()` stops it. | | `onCropCommit?` | `((crop: Required, details: ImageCropperCropCommitDetails) => void) \| undefined` | Runs once an interaction that changed the crop ends: the pointer lifts, a key is pressed, the wheel pauses. For saving. | | `mode?` | `ImageCropperMode \| undefined` | `"box"` moves and resizes a selection over the whole image. `"frame"` keeps the selection still and as large as it fits, and pans and zooms the image under it, like an avatar editor. Default: `"box"` | | `aspectRatio?` | `number \| undefined` | Keeps the crop's width over its height, like `1` for a square or `16 / 9`. Changing it fits the crop to the new ratio. | | `shape?` | `ImageCropperShape \| undefined` | The selection's shape, as `data-shape`. A circle is still a box to the crop, so pass `shape: "circle"` to `cropImage` too. Default: `"rectangle"` | | `minWidth?` | `number \| undefined` | The narrowest the crop gets, in image pixels. Default: `1` | | `minHeight?` | `number \| undefined` | The shortest the crop gets, in image pixels. Default: `1` | | `maxZoom?` | `number \| undefined` | How far the crop magnifies the image, where 1 is the largest crop the image allows. Default: `10` | | `disabled?` | `boolean \| undefined` | Stops every change: the selection can't be focused, and the buttons and zoom are disabled. | | `controller?` | `{ getCrop: () => Required \| null; setCrop: (crop: ImageCrop, options?: ImageCropperChangeOptions) => boolean; rotate: (direction?: 1 \| -1, options?: ImageCropperChangeOptions) => boolean; flip: (direction?: ImageCropperFlipDirection, options?: ImageCropperChangeOptions) => boolean; getZoom: () => number; setZoom: (zoom: number, options?: ImageCropperChangeOptions) => boolean; focus: () => void; } \| undefined` | Sets the crop from anywhere. Create one with `createImageCropperController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/image-cropper). The lake photo used in the examples is from [Unsplash](https://images.unsplash.com/photo-1470770841072-f978cf4d019e). # Components (/docs/components) # Input (/docs/components/input) ## Imports [#imports] ```tsx import { Input, InputAddon, InputClear, InputGroup, } from "@/components/ui/hacline/components/input"; ``` ## Variants [#variants] Switch between the standard outline (`default`) and filled background (`filled`) styles via `variant`. ```tsx ``` ## Sizes [#sizes] Supports three sizes — `sm`, `md` (default), and `lg` — aligned with `Button` heights. ```tsx ``` ## Input Group & Clear Button [#input-group--clear-button] Wrap `Input`, `InputAddon`, and `InputClear` inside `InputGroup`: borders and focus rings are managed by the outer container, clicking prefix text focuses the input, and the clear button appears automatically when there is content. ```tsx import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; import { Input, InputAddon, InputClear, InputGroup, } from "@/components/ui/hacline/components/input"; import { XIcon } from "lucide-react"; export function WebsiteInput() { return ( Project domain https:// ); } ``` ## Input Filtering [#input-filtering] Call `details.cancel()` inside `onValueChange` to block disallowed input while automatically restoring the previous value and caret position. ```tsx { if (!/^\d*$/.test(value)) { details.cancel(); } }} placeholder="Digits only" /> ``` ## Read-only & Disabled [#read-only--disabled] ```tsx ``` ## Props [#props] ### Input [#input] ### InputOwnProps | Prop | Type | Description | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | | `variant?` | `"default" \| "filled" \| null \| undefined` | Visual style variant of the input: `default` (bordered) or `filled` (subtle background fill). Default: `"default"` | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size of the input. Default: `"md"` | | `value?` | `string \| undefined` | Controlled value. | | `defaultValue?` | `string \| undefined` | Default value when uncontrolled. | | `onValueChange?` | `((value: string, details: ChangeDetails) => void) \| undefined` | Callback fired when the value changes, providing `details.reason` and `details.cancel()` (useful for input filtering). | | `disabled?` | `boolean \| undefined` | Disables the input. Default: `false` | | `readOnly?` | `boolean \| undefined` | Makes the input read-only (focusable, selectable, and submittable, but not editable). Default: `false` | | `required?` | `boolean \| undefined` | Whether the input is required. Default: `false` | | `controller?` | `{ getValue: () => string; setValue: (value: string, options?: ChangeOptions) => boolean; clear: (options?: ChangeOptions) => boolean; focus: () => void; } \| undefined` | External controller instance created via `createInputController()`. | | `className?` | `string \| ((state: InputState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `InputState`. | Also inherits all native `` HTML attributes and `ref`. ### InputGroup [#inputgroup] ### InputGroupOwnProps | Prop | Type | Description | | ------------ | -------------------------------------------------------------------------- | ------------------------------------------------------------------ | | `variant?` | `"default" \| "filled" \| null \| undefined` | Visual style variant of the input group. Default: `"default"` | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size of the input group. Default: `"md"` | | `className?` | `string \| ((state: InputGroupState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `InputGroupState`. | # Label (/docs/components/label) ## Usage [#usage] Click "Device name" to focus the input. Inside a `Field` with helper text or validation messages, use `FieldLabel` to establish complete associations. ```tsx "use client"; import { useId } from "react"; import { Input } from "@/components/ui/hacline/components/input"; import { Label } from "@/components/ui/hacline/components/label"; export const Example = () => { const id = useId(); return (
); }; ```
### Associating with a Switch [#associating-with-a-switch] Associate the label with a switch ID using `htmlFor`. Clicking the label text also toggles the switch. ```tsx "use client"; import { useId } from "react"; import { Label } from "@/components/ui/hacline/components/label"; import { Switch } from "@/components/ui/hacline/components/switch"; export const Example = () => { const id = useId(); return (
); }; ```
## Props [#props] | Prop | Type | Description | | ----------- | ----------------------------------------------------- | ----------- | | `render?` | `RenderProp<{}> \| undefined` | | | `children?` | `((state: {}) => React.ReactNode) \| React.ReactNode` | | | `htmlFor?` | `string \| undefined` | | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/label). # Listbox (/docs/components/listbox) ## Usage [#usage] Click or use the arrow keys and Space to select notification channels. This example uses `multiple`, so the currently selected values are stored in an array. ```tsx "use client"; import { useState } from "react"; import { Listbox, ListboxItem, ListboxItemIndicator, } from "@/components/ui/hacline/components/listbox"; const channels = [ { label: "Email digest", value: "email" }, { label: "In-app notifications", value: "inbox" }, { label: "Desktop push", value: "desktop" }, ]; export const Example = () => { const [value, setValue] = useState(["email"]); return (
{channels.map((channel) => ( {channel.label} ))} {value.length} {value.length === 1 ? "channel" : "channels"} selected
); }; ```
### Rendering Grouped Data Options [#rendering-grouped-data-options] Pass grouped objects into `items`. The listbox generates keyboard-navigable structure using the group labels and option labels. ```tsx "use client"; import { Listbox } from "@/components/ui/hacline/components/listbox"; import type { ListData } from "@/components/ui/hacline/components/listbox"; const categories: ListData = [ { items: [ { label: "Code review", value: "review" }, { label: "Build artifacts", value: "build" }, ], label: "Engineering", type: "group", }, { items: [{ label: "Getting started", value: "guide" }], label: "Documentation", type: "group", }, ]; export const Example = () => ( ); ``` ## Parts [#parts] ## Props [#props] ### ListboxOptions The options `listbox` takes. A component takes them as props on its root. `multiple` picks the shape of the value, and `Multiple` true requires it. | Prop | Type | Description | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `activation?` | `"automatic" \| "manual" \| undefined` | Whether the selection follows focus. `"automatic"`: arrow keys, Home, End and typing select the option they move to, and with `multiple` a press replaces the selection while Ctrl or ⌘ adds to it, like a native multiple select. `"manual"`: keys only move focus, and Space, Enter or a press selects, or toggles with `multiple`. Default: `` "automatic", or "manual" with `multiple` `` | | `deselectable?` | `boolean \| undefined` | Whether pressing the selected item of a single listbox unselects it, so nothing is selected. Default: `false` | | `orientation?` | `"horizontal" \| "vertical" \| undefined` | Which arrow keys move between items. Horizontal lists use Left and Right, swapped in right-to-left text. Default: `"vertical"` | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last item to the first. Shift with an arrow never wraps. Default: `true` | | `virtualFocus?` | `boolean \| undefined` | Keeps focus on the list itself, which points at the highlighted option with `aria-activedescendant`, instead of moving focus onto the options. Default: `false` | | `keepInView?` | `boolean \| undefined` | Whether the list scrolls the option keys move to into view, and the selected option when it first shows. Turn it off when something else scrolls the list, like `bindScrollPicker`. Default: `true` | | `items?` | `ListData \| undefined` | The items as data. Renders them for you, and lets typing find items a virtualized list hasn't rendered. | | `itemToValue?` | `((value: T) => string) \| undefined` | The string an item's value submits as and is identified by, for object values. Strings pass through, and objects use their `value` or `id`. | | `isItemEqualToValue?` | `((itemValue: T, value: T) => boolean) \| undefined` | Whether an item's value is the selected value, for object values that aren't the same object. | | `onHighlight?` | `((value: T \| null, details: ListHighlightDetails) => void) \| undefined` | Runs when focus moves to another item, with its index among the items, so a virtualized list can scroll to it. | | `disabled?` | `boolean \| undefined` | Disables the listbox like a native control: its items can't be focused or chosen, and the value isn't submitted. | | `readOnly?` | `boolean \| undefined` | Keeps the listbox focusable and its value submitted, but stops changes. | | `required?` | `boolean \| undefined` | Blocks form submission until a value is selected, with the browser's own message. | | `name?` | `string \| undefined` | The name the value submits under. Without one, the listbox submits nothing. | | `form?` | `string \| undefined` | The id of a form to belong to, when the listbox isn't inside that form. | | `controller?` | `{ getValue: () => any; setValue: (value: any, options?: ListboxChangeOptions) => boolean; clear: (options?: ListboxChangeOptions) => boolean; selectAll: (options?: ListboxChangeOptions) => boolean; getHighlighted: () => any; highlight: (value: any) => boolean; focus: () => void; } \| undefined` | Reads and sets the listbox from anywhere. Create one with `createListboxController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | | `multiple?` | `boolean \| undefined` | Whether several items can be selected. The value is then a list, Shift selects ranges, and Ctrl or ⌘ with A selects every item. Whether several items can be selected. Default: `false` | | `value?` | `T \| T[] \| ItemsOf \| null \| undefined` | The selected value. Pass it to control the listbox. `null` selects nothing. The selected values. Pass it to control the listbox. The selected value, or values with `multiple`. Pass it to control the listbox. | | `defaultValue?` | `T \| T[] \| ItemsOf \| null \| undefined` | The value selected at first, when uncontrolled. A form reset returns to it. The values selected at first, when uncontrolled. A form reset returns to them. The value or values selected at first, when uncontrolled. A form reset returns to it. | | `onValueChange?` | `((value: NoInfer \| null, details: ChangeDetails) => void) \| ((value: T[], details: ChangeDetails) => void) \| ((value: NoInfer[] \| NoInfer \| null, details: ChangeDetails) => void) \| undefined` | Runs when a user, a form reset or a controller wants to change the value. `details.reason` says why, and `details.cancel()` stops it. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/listbox). # Menu (/docs/components/menu) ## Imports [#imports] ```tsx import { Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuItemIndicator, MenuItems, MenuSeparator, MenuShortcut, MenuTrigger, } from "@/components/ui/hacline/components/menu"; ``` ## Basic Usage [#basic-usage] ```tsx }>Open menu Edit Copy code Delete draft ``` ### Generating Items from Data [#generating-items-from-data] Render option data inside `MenuContent` using `MenuItems`. When an item is selected, `onAction` on the root component receives its value. ```tsx "use client"; import { useState } from "react"; import { Menu, MenuContent, MenuItems, MenuTrigger, } from "@/components/ui/hacline/components/menu"; import type { MenuData } from "@/components/ui/hacline/components/menu"; const items: MenuData = [ { label: "Duplicate as draft", value: "copy" }, { label: "Export Markdown", value: "export" }, ]; const feedback: Record = { copy: "Duplicated as draft", export: "Exported Markdown", }; export const Example = () => { const [action, setAction] = useState("No action taken yet"); return (
setAction(feedback[value])}> Document actions {action}
); }; ```
## Props [#props] ### Menu [#menu] ### MenuOwnProps | Prop | Type | Description | | --------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | `open?` | `boolean \| undefined` | Controlled open state. | | `defaultOpen?` | `boolean \| undefined` | Default open state when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: ChangeDetails) => void) \| undefined` | Callback fired when the open state changes. | | `loop?` | `boolean \| undefined` | Whether arrow key navigation wraps between the first and last items. Default: `true` | | `controller?` | `PopupController \| undefined` | External controller instance. | ### MenuContent [#menucontent] ### MenuContentOwnProps | Prop | Type | Description | | ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------- | | `side?` | `Side \| undefined` | Side of the trigger on which the menu opens. Default: `"bottom"` | | `align?` | `Align \| undefined` | Alignment of the menu relative to the trigger. Default: `"start"` | | `sideOffset?` | `number \| undefined` | Distance from the trigger in pixels. Default: `4` | | `className?` | `string \| ((state: MenuContentState) => string \| undefined) \| undefined` | Custom class name. | # Menubar (/docs/components/menubar) ## Usage [#usage] Focus "File", use the Left and Right arrow keys to switch menus, and press the Down arrow key to open the current menu. Each menu's `onAction` receives the `value` of the executed item. ```tsx "use client"; import { useState } from "react"; import { Menu, MenuContent, MenuItem, MenuTrigger, } from "@/components/ui/hacline/components/menu"; import { Menubar } from "@/components/ui/hacline/components/menubar"; export const Example = () => { const [action, setAction] = useState("No action selected"); return (
File New Export View Outline Reading mode {action}
); }; ```
### Vertical Menubar & Checkbox Items [#vertical-menubar--checkbox-items] Set the menubar to vertical orientation to switch menus with the Up and Down arrow keys. Checkbox items inside a menu preserve their own checked state. ```tsx "use client"; import { Menu, MenuCheckboxItem, MenuContent, MenuItemIndicator, MenuTrigger, } from "@/components/ui/hacline/components/menu"; import { Menubar } from "@/components/ui/hacline/components/menubar"; export const Example = () => ( Editor Word wrap Preview Show guides ); ``` ## Props [#props] ### MenubarOptions The options `menubar` takes. A component takes them as props on its root. | Prop | Type | Description | | -------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `orientation?` | `MenubarOrientation \| undefined` | Which arrow keys move between menus: left and right, or up and down. A vertical menubar opens its menus to the side. Default: `"horizontal"` | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last menu to the first, between triggers and between open menus. Default: `true` | | `disabled?` | `boolean \| undefined` | Stops every menu from opening. Triggers stay focusable with `aria-disabled`, so the menubar keeps its tab stop and stays discoverable. Default: `false` | | `modal?` | `"pointer" \| boolean \| undefined` | The `modal` setting of every menu in the menubar that doesn't set its own. `"pointer"`: an outside press only closes the open menu. `true`: also locks scroll, traps focus and makes the rest of the page inert, except the menubar. `false`: outside presses reach what they hit. Default: `"pointer"` | | `controller?` | `{ focus: () => void; isOpen: () => boolean; close: (options?: ChangeOptions) => boolean; } \| undefined` | Opens, closes and focuses the menubar from anywhere. Create one with `createMenubarController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/menubar). # Meter (/docs/components/meter) ## Usage [#usage] Represent a measured value with `min`, `max`, and `value`, and provide a label with `MeterLabel`. `MeterValue` can display custom units. ```tsx "use client"; import { Meter, MeterIndicator, MeterLabel, MeterTrack, MeterValue, } from "@/components/ui/hacline/components/meter"; export const Example = () => ( Workspace storage 14 / 20 GB ); ``` ### Highlighting Near-Limit Usage [#highlighting-near-limit-usage] Style the indicator bar based on business thresholds and show capacity status in text. ```tsx "use client"; import { Meter, MeterIndicator, MeterLabel, MeterTrack, MeterValue, } from "@/components/ui/hacline/components/meter"; const utilization = 92; export const Example = () => ( Build disk usage = 90 ? "bg-hl-danger" : undefined} />

{utilization >= 90 ? "Near capacity limit" : "Capacity available"}

); ```
## Parts [#parts] ## Props [#props] ### MeterOptions The options `meter` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `min?` | `number \| undefined` | The lowest value. Default: `0` | | `max?` | `number \| undefined` | The highest value. Default: `100` | | `format?` | `NumberFormat \| undefined` | How the value reads, for screen readers and the Value part: `Intl.NumberFormat` options, or a function of the value. A percent style shows where the value sits between `min` and `max`; any other style shows the value itself, like `{ style: "unit", unit: "gigabyte" }`. Default: `{ style: "percent" }` | | `locale?` | `string \| undefined` | The locale the value is formatted in. Defaults to the page's `lang`, or the browser's language without one, once the page is interactive. Server markup uses English until then, so it never disagrees with the client. | | `getValueLabel?` | `((value: number, details: GaugeLabelDetails) => string) \| undefined` | The text screen readers announce for the value, when the formatted value says too little, like "3 of 12 files". It receives the value, null while a progress bar is indeterminate, and details: the `formatted` value, its `percent`, `min` and `max`. | | `value` | `number` | The reading, between `min` and `max`. Outside them, the fill, the percentage and `aria-valuenow` are clamped, while the state keeps the value as given. A meter always has a value, since there's no busy state. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/meter). # NavigationMenu (/docs/components/navigation-menu) ## Usage [#usage] Click "Get started" or "Examples" to expand the corresponding links. Placing `NavigationMenuViewport` next to the list lets menus share a floating container. ```tsx "use client"; import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, } from "@/components/ui/hacline/components/navigation-menu"; export const Example = () => ( Get started Quickstart Design tokens Examples Button Field ); ``` ### Opening Independent Panels on Click [#opening-independent-panels-on-click] Disable hover-to-open so each panel can be positioned independently. Entries without submenus act directly as navigation links. ```tsx "use client"; import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, } from "@/components/ui/hacline/components/navigation-menu"; export const Example = () => ( Resources All components Navigation menu docs Quickstart ); ``` ## Parts [#parts] ## Props [#props] ### NavigationMenuOptions The options `navigationMenu` takes. A component takes them as props on its root. | Prop | Type | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `container?` | `DocumentFragment \| Element \| null \| undefined` | Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent. | | `value?` | `T \| null \| undefined` | The open item's value. Pass it to control the menu. `null` closes every panel. | | `defaultValue?` | `T \| null \| undefined` | The item open at first, when uncontrolled. Default: `null` | | `onValueChange?` | `((value: T \| null, details: ChangeDetails) => void) \| undefined` | Runs when an item wants to open or the open one to close. `details.reason` says why, and `details.cancel()` stops it. | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the menu has finished opening or closing, after any animation. Switching items doesn't count. | | `delay?` | `number \| undefined` | Milliseconds the pointer rests on a trigger before its panel opens. Moving to another trigger while one is open switches at once. Default: `50` | | `closeDelay?` | `number \| undefined` | Milliseconds before the open panel closes once the pointer leaves its trigger and the panel. Default: `50` | | `openOnHover?` | `boolean \| undefined` | Whether resting the pointer on a trigger opens its panel. Pressing a trigger always does, so `false` makes a click-only menu. Default: `true` | | `closeOnSelect?` | `boolean \| undefined` | Whether pressing a link closes the menu, like after a client-side route change. A link's own `closeOnSelect` wins. A press with a modifier key, which opens a new tab, never closes it. Default: `true` | | `orientation?` | `NavigationMenuOrientation \| undefined` | Which arrow keys move between the top-level items, and the side panels open on: below a horizontal menu, beside a vertical one. Default: `"horizontal"` | | `controller?` | `{ getValue: () => T \| null; setValue: (value: T \| null, options?: NavigationMenuChangeOptions) => boolean; isOpen: () => boolean; close: (options?: NavigationMenuChangeOptions) => boolean; focus: (value?: T \| undefined) => void; } \| undefined` | Opens and closes panels from anywhere. Create one with `createNavigationMenuController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/navigation-menu). # NumberInput (/docs/components/number-input) ## Usage [#usage] Omit `children` for a ready-to-use numeric stepper with built-in increment/decrement controls and keyboard arrow support. On commit, the value is clamped and formatted according to `min`, `max`, and `step`. ```tsx "use client"; import { Field, FieldDescription, FieldLabel, } from "@/components/ui/hacline/components/field"; import { NumberInput } from "@/components/ui/hacline/components/number-input"; export const Example = () => ( Reserved seats Reserve between 1 and 20 seats. ); ``` ### Currency Formatting & Stacked Stepper [#currency-formatting--stacked-stepper] Format amounts with `Intl.NumberFormatOptions`, set `step={0.01}` for decimal precision, and switch to `controls="stacked"` for a compact trailing stepper suited to forms. ```tsx "use client"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; import { NumberInput } from "@/components/ui/hacline/components/number-input"; export const Example = () => ( Shipping fee ); ``` ### Layouts, Variants & Addons [#layouts-variants--addons] Configure `controls` (`"sides"`, `"stacked"`, or `"none"`), `variant` (`"default"` or `"filled"`), `size` (`"sm"`, `"md"`, `"lg"`), and inline `prefix` / `suffix` units. ```tsx "use client"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; import { NumberInput } from "@/components/ui/hacline/components/number-input"; export const Example = () => (
Spacing (suffix + stacked) Discount (filled + small) Port (no stepper controls)
); ```
## Parts [#parts] Pass custom `children` to compose lower-level parts directly. ## Props [#props] ### NumberInputOwnProps | Prop | Type | Description | | ----------------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `variant?` | `"default" \| "filled" \| null \| undefined` | Visual style variant of the number input container. Default: `"default"` | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size variant of the number input. Default: `"md"` | | `controls?` | `NumberInputControlsLayout \| undefined` | Stepper button layout used when `children` is omitted: `"sides"` (`-` / `+` flanking buttons), `"stacked"` (compact up/down stepper on the trailing edge), or `"none"` (keyboard/input only). Default: `"sides"` | | `placeholder?` | `string \| undefined` | Placeholder text passed to the built-in `NumberInputControl` when `children` is omitted. | | `prefix?` | `ReactNode` | Leading prefix content (such as an icon or currency symbol) rendered inside the built-in group when `children` is omitted. | | `suffix?` | `ReactNode` | Trailing suffix content (such as a unit like `px` or `%`) rendered inside the built-in group when `children` is omitted. | | `decrementLabel?` | `string \| undefined` | Accessible label for the built-in decrement button when `children` is omitted. Default: `"Decrease"` | | `incrementLabel?` | `string \| undefined` | Accessible label for the built-in increment button when `children` is omitted. Default: `"Increase"` | | `value?` | `number \| null \| undefined` | Controlled numeric value (`null` represents an empty field). | | `defaultValue?` | `number \| null \| undefined` | Initial numeric value when uncontrolled. | | `onValueChange?` | `((value: number \| null, details: ChangeDetails) => void) \| undefined` | Callback fired whenever the numeric value changes. | | `onValueCommit?` | `((value: number \| null, details: CommitDetails) => void) \| undefined` | Callback fired when a value is committed (on blur, Enter, or stepper release). | | `min?` | `number \| undefined` | Minimum allowed value. | | `max?` | `number \| undefined` | Maximum allowed value. | | `step?` | `number \| undefined` | Step increment for buttons and arrow keys. Default: `1` | | `format?` | `Intl.NumberFormatOptions \| undefined` | `Intl.NumberFormatOptions` used to format the displayed value (for example, currency or percent). | | `locale?` | `string \| undefined` | BCP 47 locale used for number parsing and formatting. | | `disabled?` | `boolean \| undefined` | Disables the input and stepper buttons. Default: `false` | | `readOnly?` | `boolean \| undefined` | Makes the numeric value read-only while remaining focusable. Default: `false` | | `required?` | `boolean \| undefined` | Marks the field as required for form validation. Default: `false` | | `name?` | `string \| undefined` | Form field name used for submitting the raw numeric value. | | `className?` | `string \| ((state: NumberInputState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `NumberInputState`. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/number-input). # OTPInput (/docs/components/otp-input) ## Usage [#usage] Omit `children` to automatically generate slots from `maxLength` and optional `groups` (for example, `groups={[3, 3]}` inserts a separator between two 3-digit groups). ```tsx "use client"; import { useState } from "react"; import { OTPInput } from "@/components/ui/hacline/components/otp-input"; export const Example = () => { const [completed, setCompleted] = useState(false); return (
setCompleted(value.length === 6)} pattern="digits" /> {completed ? "Code complete" : "Enter 6 digits"}
); }; ```
### Alphanumeric Invite Code [#alphanumeric-invite-code] Set `pattern="alphanumeric"` and `maxLength={4}` to accept both letters and digits across four slots backed by one native field. ```tsx "use client"; import { OTPInput } from "@/components/ui/hacline/components/otp-input"; export const Example = () => ( ); ``` ### Variants, Sizes & Masking [#variants-sizes--masking] Switch slot styling with `variant` (`"default"` / `"filled"` / `"connected"`), adjust slot dimensions with `size` (`"sm"` / `"md"` / `"lg"`), and hide sensitive PIN digits with `mask`. ```tsx "use client"; import { OTPInput } from "@/components/ui/hacline/components/otp-input"; export const Example = () => (
Connected (3-3)
Filled + Masked PIN
Compact (small)
); ```
## Parts [#parts] Pass custom `children` when you need full layout control. ## Props [#props] ### OTPInputOwnProps | Prop | Type | Description | | ---------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `variant?` | `"connected" \| "default" \| "filled" \| null \| undefined` | Visual style variant of the OTP slots: `"default"` (separate bordered boxes), `"filled"` (soft muted boxes), or `"connected"` (joined segmented group). Default: `"default"` | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size variant of the OTP input slots. Default: `"md"` | | `maxLength?` | `number \| undefined` | Total number of character slots (also controls auto-generated slots when `children` is omitted). Default: `6` | | `groups?` | `readonly number[] \| undefined` | Optional slot grouping sizes used when `children` is omitted (for example, `[3, 3]` renders two groups of 3 slots with a separator between them). | | `separator?` | `ReactNode` | Custom separator rendered between auto-generated groups when `groups` has two or more entries. Default: `"–"` | | `mask?` | `boolean \| undefined` | Masks filled characters as bullets (`•`) when `children` is omitted (useful for PINs or sensitive passcodes). Default: `false` | | `pattern?` | `OTPInputPattern \| undefined` | Allowed character pattern: `"digits"`, `"alphanumeric"`, or a custom `RegExp`. Default: `"digits"` | | `value?` | `string \| undefined` | Controlled passcode string. | | `defaultValue?` | `string \| undefined` | Initial passcode string when uncontrolled. | | `onValueChange?` | `((value: string, details: ChangeDetails) => void) \| undefined` | Callback fired whenever the passcode changes. | | `onValueCommit?` | `((value: string, details: CommitDetails) => void) \| undefined` | Callback fired when every slot is filled with a complete passcode. | | `disabled?` | `boolean \| undefined` | Disables the OTP input. Default: `false` | | `name?` | `string \| undefined` | Form field name for submitting the complete code string. | | `className?` | `string \| ((state: OTPInputState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `OTPInputState`. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/otp-input). # Pagination (/docs/components/pagination) ## Usage [#usage] Click page numbers or previous/next controls. The `PaginationList` render callback yields visible pages and ellipses near the current page, and `onPageChange` loads the next slice. ```tsx "use client"; import { useState } from "react"; import { Pagination, PaginationEllipsis, PaginationItem, PaginationLink, PaginationList, PaginationNext, PaginationPrevious, } from "@/components/ui/hacline/components/pagination"; const PAGE_COUNT = 12; export const Example = () => { const [page, setPage] = useState(1); return (
Results page {page} of {PAGE_COUNT} {({ items }) => ( <> {items.map((item) => ( {typeof item === "number" ? ( ) : ( )} ))} )}
); }; ```
### Paginating from Total Count [#paginating-from-total-count] Provide `total` and `pageSize` to compute page bounds, then jump across ranges with first and last controls. ```tsx "use client"; import { Pagination, PaginationFirst, PaginationItem, PaginationLast, PaginationList, PaginationNext, PaginationPrevious, } from "@/components/ui/hacline/components/pagination"; export const Example = () => ( {({ page, pageCount }) => ( <> First {page} / {pageCount} Last )} ); ``` ## Parts [#parts] ## Props [#props] ### PaginationOptions The options `pagination` takes. A component takes them as props on its root. | Prop | Type | Description | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `page?` | `number \| undefined` | The current page, from 1. Pass it to control the pagination. | | `defaultPage?` | `number \| undefined` | The page it starts on, when uncontrolled. Default: `1` | | `onPageChange?` | `((page: number, details: ChangeDetails) => void) \| undefined` | Runs when the page wants to change: a page link (`"item-press"`), the Previous, Next, First or Last part, or a controller (`"imperative"`). `details.cancel()` keeps the page, and stops a link from navigating. | | `pageCount?` | `number \| undefined` | How many pages there are. Or pass `total` and `pageSize`. | | `total?` | `number \| undefined` | How many items there are, for `pageCount` from `pageSize`. | | `pageSize?` | `number \| undefined` | How many items fit on a page, with `total`. Default: `10` | | `siblings?` | `number \| undefined` | How many pages show on each side of the current one. Default: `1` | | `boundaries?` | `number \| undefined` | How many pages always show at each end. Default: `1` | | `getHref?` | `((page: number) => string) \| undefined` | The URL of a page. With it, parts are links: they navigate, open in a new tab with a modifier key, and work before JavaScript loads. Without it, they're buttons. | | `disabled?` | `boolean \| undefined` | Whether every page and step does nothing, like a step at its end. A controller still pages it. Default: `false` | | `controller?` | `{ getPage: () => number; getPageCount: () => number; setPage: (page: number, options?: PaginationChangeOptions) => boolean; next: (options?: PaginationChangeOptions) => boolean; previous: (options?: PaginationChangeOptions) => boolean; first: (options?: PaginationChangeOptions) => boolean; last: (options?: PaginationChangeOptions) => boolean; } \| undefined` | Pages it from anywhere. Create one with `createPaginationController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/pagination). # PasswordInput (/docs/components/password-input) ## Usage [#usage] Omit `children` for a ready-to-use password field with an automatic icon toggle. Configure browser autofill hints via `autoComplete`. ```tsx "use client"; import { Lock } from "lucide-react"; import { Field, FieldDescription, FieldLabel, } from "@/components/ui/hacline/components/field"; import { PasswordInput } from "@/components/ui/hacline/components/password-input"; export const Example = () => ( Password ); ``` ### Form Validation [#form-validation] Pass `required`, `pattern`, and `inputTitle` directly to `PasswordInput` for native form validation. ```tsx "use client"; import { Check, Circle, KeyRound } from "lucide-react"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { Field, FieldDescription, FieldError, FieldLabel, } from "@/components/ui/hacline/components/field"; import { PasswordInput } from "@/components/ui/hacline/components/password-input"; const UPPERCASE_RE = /[A-Z]/u; const NUMBER_RE = /\d/u; const SYMBOL_RE = /[^A-Za-z0-9]/u; const PASSWORD_RULES = [ { id: "length", label: "At least 8 characters", test: (v: string) => v.length >= 8, }, { id: "upper", label: "One uppercase letter", test: (v: string) => UPPERCASE_RE.test(v), }, { id: "number", label: "One number", test: (v: string) => NUMBER_RE.test(v) }, { id: "symbol", label: "One special character", test: (v: string) => SYMBOL_RE.test(v), }, ] as const; const STRENGTH_META = [ { color: "bg-hl-border", label: "Enter a password", text: "text-hl-fg-muted", }, { color: "bg-hl-danger", label: "Weak", text: "text-hl-danger" }, { color: "bg-hl-warning", label: "Fair", text: "text-hl-warning" }, { color: "bg-hl-info", label: "Good", text: "text-hl-info" }, { color: "bg-hl-success", label: "Strong", text: "text-hl-success" }, ] as const; export const Example = () => { const [value, setValue] = useState(""); const [error, setError] = useState(""); const [submitted, setSubmitted] = useState(false); const results = PASSWORD_RULES.map((rule) => ({ ...rule, passed: rule.test(value), })); const score = results.filter((rule) => rule.passed).length; const strength = STRENGTH_META[score] ?? STRENGTH_META[0]; const isComplete = score === PASSWORD_RULES.length; const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); if (!isComplete) { setSubmitted(false); setError("Please satisfy all password requirements before saving."); return; } setError(""); setSubmitted(true); }; return (
Create password { setValue(next); setSubmitted(false); if (error) { setError(""); } }} placeholder="e.g. Hacline@2026" prefix={
Strength {strength.label}
    {results.map((rule) => (
  • {rule.passed ? (
  • ))}
{submitted ? ( Password meets all requirements ) : null}
); }; ```
### Variants, Sizes & Prefix [#variants-sizes--prefix] Customize appearance with `variant` (`"default"` / `"filled"`), `size` (`"sm"` / `"md"` / `"lg"`), leading `prefix` icons, or `showToggle={false}`. ```tsx "use client"; import { Lock, ShieldCheck } from "lucide-react"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; import { PasswordInput } from "@/components/ui/hacline/components/password-input"; export const Example = () => (
Default Filled
Small Medium Large
Invalid Disabled No toggle
); ```
## Parts [#parts] Pass custom `children` when you need full control over inner parts. ## Props [#props] ### PasswordInputOwnProps | Prop | Type | Description | | ------------------ | ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | `variant?` | `"default" \| "filled" \| null \| undefined` | Visual style variant of the password input. Default: `"default"` | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size variant of the password input. Default: `"md"` | | `placeholder?` | `string \| undefined` | Placeholder text passed to the built-in `PasswordInputControl` when `children` is omitted. | | `prefix?` | `ReactNode` | Leading prefix content (such as a lock icon) rendered inside the container when `children` is omitted. | | `showToggle?` | `boolean \| undefined` | Whether to render the built-in visibility toggle button when `children` is omitted. Default: `true` | | `toggleLabel?` | `string \| undefined` | Accessible name for the built-in visibility toggle button (`aria-pressed` communicates the current visible state). Default: `"Show password"` | | `pattern?` | `string \| undefined` | Native regex pattern forwarded to the built-in `PasswordInputControl` when `children` is omitted. | | `minLength?` | `number \| undefined` | Minimum character length forwarded to the built-in `PasswordInputControl` when `children` is omitted. | | `maxLength?` | `number \| undefined` | Maximum character length forwarded to the built-in `PasswordInputControl` when `children` is omitted. | | `inputTitle?` | `string \| undefined` | Validation hint forwarded to the built-in `PasswordInputControl` when `children` is omitted. | | `value?` | `string \| undefined` | Controlled password value. | | `defaultValue?` | `string \| undefined` | Initial password value when uncontrolled. | | `onValueChange?` | `((value: string, details: ChangeDetails) => void) \| undefined` | Callback fired whenever the password value changes. | | `visible?` | `boolean \| undefined` | Controlled visibility state (`true` reveals plaintext). | | `defaultVisible?` | `boolean \| undefined` | Initial visibility state when uncontrolled. Default: `false` | | `onVisibleChange?` | `((visible: boolean, details: ChangeDetails) => void) \| undefined` | Callback fired when password visibility toggles. | | `autoComplete?` | `"current-password" \| "new-password" \| "off" \| (string & {}) \| undefined` | Browser autofill hint (such as `"current-password"` or `"new-password"`). | | `disabled?` | `boolean \| undefined` | Disables the input and toggle button. Default: `false` | | `readOnly?` | `boolean \| undefined` | Makes the input read-only while remaining focusable. Default: `false` | | `required?` | `boolean \| undefined` | Marks the password field as required for form validation. Default: `false` | | `name?` | `string \| undefined` | Form field name. | | `className?` | `string \| ((state: PasswordInputState) => string \| undefined) \| undefined` | Custom class name, as a string or a function of `PasswordInputState`. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/password-input). # Popover (/docs/components/popover) ## Import [#import] ```tsx import { Popover, PopoverArrow, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, } from "@/components/ui/hacline/components/popover"; ``` ## Basic Usage [#basic-usage] ```tsx }> Customize Canvas Canvas Size Configure the default width and height for the preview stage. }>Done ``` ### Editing and Saving Inside a Popover [#editing-and-saving-inside-a-popover] Update the project name and apply. The form controls open state through the root component and restores the prior value on cancel. ```tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; import { Input } from "@/components/ui/hacline/components/input"; import { Popover, PopoverClose, PopoverContent, PopoverTitle, PopoverTrigger, } from "@/components/ui/hacline/components/popover"; export const Example = () => { const [name, setName] = useState("Research notes"); const [open, setOpen] = useState(false); return (
}> Edit display name Rename project
{ setName(String(data.get("title"))); setOpen(false); }} className="mt-3 grid gap-3" > New display name
}> Cancel
Display name: {name}
); }; ```
## Props [#props] ### Popover [#popover] ### PopoverOwnProps | Prop | Type | Description | | --------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | | `open?` | `boolean \| undefined` | Controlled open state of the popover. | | `defaultOpen?` | `boolean \| undefined` | Default open state of the popover when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: ChangeDetails) => void) \| undefined` | Runs when the open state changes. | | `modal?` | `"trap-focus" \| boolean \| undefined` | Whether the popover is modal (locking background interaction or focus). Default: `false` | | `controller?` | `PopupController \| undefined` | External controller instance. | ### PopoverContent [#popovercontent] ### PopoverContentOwnProps | Prop | Type | Description | | ------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | `side?` | `Side \| undefined` | Preferred side to open on; flips automatically when there isn't room. Default: `"bottom"` | | `align?` | `Align \| undefined` | Alignment relative to the anchor. Default: `"center"` | | `sideOffset?` | `number \| undefined` | Gap between the popover and its trigger, in pixels. Default: `6` | | `className?` | `string \| ((state: PopoverContentState) => string \| undefined) \| undefined` | Custom class name as a string or a function of `PopoverContentState`. | # Preferences (/docs/components/preferences) ## Usage [#usage] Buttons update the layout preference created with `createPreference`. `Preferences` writes `data-layout`, which example styles use to adjust list columns. ```tsx "use client"; import { useMemo } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { createPreference, Preferences, usePreference, } from "@/components/ui/hacline/components/preferences"; export const Example = () => { const layout = useMemo( () => createPreference({ attribute: "data-layout", defaultValue: "list", values: ["list", "grid"], }), [] ); const { value } = usePreference(layout); return (
  • Requirements
  • Deliverables
); }; ```
### Scoped Theme & System Sync [#scoped-theme--system-sync] Manage `system`, `light`, and `dark` preferences via `createColorScheme` so `data-color-scheme` styles only this region. ```tsx "use client"; import { useMemo } from "react"; import { createColorScheme, Preferences, usePreference, } from "@/components/ui/hacline/components/preferences"; import { SegmentedControl, SegmentedControlIndicator, SegmentedControlItem, } from "@/components/ui/hacline/components/segmented-control"; export const Example = () => { const theme = useMemo( () => createColorScheme({ defaultValue: "system" }), [] ); const { value } = usePreference(theme); return (
{ if (next) { theme.set(next); } }} value={value} > System Light Dark
This theme applies only to this preview.
); }; ```
## Props [#props] | Prop | Type | Description | | ------------- | --------------------------- | ------------------------------------------------------------------------ | | `nonce?` | `string \| undefined` | The nonce your Content Security Policy gives inline scripts. | | `preferences` | `readonly PreferenceLike[]` | The preferences to show, from `createPreference` or `createColorScheme`. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/preferences). # Progress (/docs/components/progress) ## Usage [#usage] Advance by 25% per click and reset once complete. Pass `value={null}` when total progress cannot be determined yet. ```tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, } from "@/components/ui/hacline/components/progress"; const STEP = 25; const TOTAL = 100; export const Example = () => { const [value, setValue] = useState(25); return (
Generating report
); }; ```
### Waiting for Total Size [#waiting-for-total-size] Starts with `value={null}` and switches to a determinate percentage once totals arrive. ```tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, } from "@/components/ui/hacline/components/progress"; export const Example = () => { const [measured, setMeasured] = useState(false); return (
Loading import job {measured ? "35%" : "Counting items..."}
); }; ```
## Parts [#parts] ## Props [#props] ### ProgressOptions The options `progress` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `min?` | `number \| undefined` | The lowest value. Default: `0` | | `max?` | `number \| undefined` | The highest value. Default: `100` | | `format?` | `NumberFormat \| undefined` | How the value reads, for screen readers and the Value part: `Intl.NumberFormat` options, or a function of the value. A percent style shows where the value sits between `min` and `max`; any other style shows the value itself, like `{ style: "unit", unit: "gigabyte" }`. Default: `{ style: "percent" }` | | `locale?` | `string \| undefined` | The locale the value is formatted in. Defaults to the page's `lang`, or the browser's language without one, once the page is interactive. Server markup uses English until then, so it never disagrees with the client. | | `getValueLabel?` | `((value: number \| null, details: GaugeLabelDetails) => string) \| undefined` | The text screen readers announce for the value, when the formatted value says too little, like "3 of 12 files". It receives the value, null while a progress bar is indeterminate, and details: the `formatted` value, its `percent`, `min` and `max`. | | `value?` | `number \| null \| undefined` | How far the task has come, between `min` and `max`. Null means it's under way but how far is unknown, and the bar is indeterminate. Default: `null` | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/progress). # Radio (/docs/components/radio) ## Usage [#usage] Click a label or press arrow keys while focused to change digest cadence. The group's `name` sets the submitted form field name. ```tsx "use client"; import { useId } from "react"; import { Label } from "@/components/ui/hacline/components/label"; import { Radio, RadioGroup, RadioIndicator, } from "@/components/ui/hacline/components/radio"; export const Example = () => { const id = useId(); const weekly = `${id}-weekly`; const monthly = `${id}-monthly`; return (
); }; ```
### Skipping Disabled Options [#skipping-disabled-options] Disabled release channels stay visible while arrow-key navigation skips directly across enabled choices. ```tsx "use client"; import { Radio, RadioGroup, RadioIndicator, } from "@/components/ui/hacline/components/radio"; export const Example = () => ( ); ``` ## Parts [#parts] ## Props [#props] ### RadioGroupOptions The options `radioGroup` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | | `value?` | `T \| null \| undefined` | The checked radio's value. Pass it to control the group. `null` checks nothing. | | `defaultValue?` | `T \| null \| undefined` | The radio checked at first, when uncontrolled. A form reset returns to it. | | `onValueChange?` | `((value: T \| null, details: ChangeDetails) => void) \| undefined` | Runs when a user or a form reset wants to change the value. `details.reason` says why, and `details.cancel()` stops it. | | `disabled?` | `boolean \| undefined` | Disables every radio like native ones: they can't be focused or changed, and the value isn't submitted. | | `readOnly?` | `boolean \| undefined` | Keeps the items focusable and the value submitted, but stops changes. | | `required?` | `boolean \| undefined` | Blocks form submission until an item is checked, with the browser's own message. | | `name?` | `string \| undefined` | The name the value submits under. Without one, the group submits nothing. | | `form?` | `string \| undefined` | The id of a form to belong to, when the group isn't inside that form. | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last item to the first. Default: `true` | | `controller?` | `{ getValue: () => T \| null; setValue: (value: T \| null, details?: Details) => boolean; focus: () => void; } \| undefined` | Checks radios from anywhere. Create one with `createRadioGroupController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/radio). # Rating (/docs/components/rating) ## Usage [#usage] Hover to preview values. This example uses `step={0.5}`, and also supports arrow-key focus movement with Space to select. ```tsx "use client"; import { useState } from "react"; import { Rating } from "@/components/ui/hacline/components/rating"; export const Example = () => { const [value, setValue] = useState(3.5); return (
`${score} ${score === 1 ? "star" : "stars"}`} max={5} onValueChange={setValue} step={0.5} value={value} /> {value === null ? "Not rated yet" : `Rating ${value} / 5`}
); }; ```
### Read-Only Average Display [#read-only-average-display] Set `readOnly` to present an aggregate average score that prevents edits. ```tsx "use client"; import { Rating } from "@/components/ui/hacline/components/rating"; export const Example = () => (

4.2 / 5 from 18 reviews

); ```
## Parts [#parts] ## Props [#props] ### RatingOptions The options `rating` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `value?` | `number \| null \| undefined` | The score. Pass it to control the rating. `null` means no score yet. | | `defaultValue?` | `number \| null \| undefined` | The score at first, when uncontrolled. A form reset returns to it. | | `onValueChange?` | `((value: number \| null, details: ChangeDetails) => void) \| undefined` | Runs when a user or a form reset wants to change the score. `details.reason` says why, and `details.cancel()` stops it. | | `max?` | `number \| undefined` | How many stars there are. Default: `5` | | `step?` | `number \| undefined` | The smallest change, as a fraction of a star: `0.5` makes half stars, each half its own radio. Default: `1` | | `deselectable?` | `boolean \| undefined` | Lets a press on the checked star clear the score. | | `disabled?` | `boolean \| undefined` | Disables every star: they can't be focused or changed, and the score isn't submitted. | | `readOnly?` | `boolean \| undefined` | Shows the score as an image, named by `getValueLabel`, that can't be changed. Any score shows, like an average of 4.2. | | `required?` | `boolean \| undefined` | Blocks form submission until there's a score, with the browser's own message. | | `name?` | `string \| undefined` | The name the score submits under. Without one, the rating submits nothing. | | `form?` | `string \| undefined` | The id of a form to belong to, when the rating isn't inside that form. | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last star to the first. Default: `false` | | `getValueLabel?` | `((value: number, max: number) => string) \| undefined` | Names a score, for each star's radio and for a read-only rating. Default: `` (value) => value === 1 ? "1 star" : `${value} stars` `` | | `controller?` | `{ getValue: () => number \| null; setValue: (value: number \| null, details?: RatingChangeOptions) => boolean; focus: () => void; } \| undefined` | Sets the score from anywhere. Create one with `createRatingController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/rating). # Resizable (/docs/components/resizable) ## Usage [#usage] Drag the handle or use Left/Right arrow keys when focused. Both `defaultSize` and `minSize` are defined as percentages. ```tsx "use client"; import { Resizable, ResizableHandle, ResizablePanel, } from "@/components/ui/hacline/components/resizable"; export const Example = () => ( Files

requirements.md

Editor

Draft the agenda for the next meeting.

); ```
### Vertical Panels [#vertical-panels] Switch orientation to vertical so dragging or Up/Down arrow keys resize the top and bottom regions. ```tsx "use client"; import { Resizable, ResizableHandle, ResizablePanel, } from "@/components/ui/hacline/components/resizable"; export const Example = () => ( Document preview Render log

Document rendered successfully.

); ```
## Parts [#parts] ## Props [#props] ### ResizableOptions The options `resizable` takes. A component takes them as props on its root. | Prop | Type | Description | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `layout?` | `number[] \| undefined` | Each panel's size in percent, in panel order, like `[25, 75]`. Pass it to control the group. | | `defaultLayout?` | `number[] \| undefined` | The layout at first, when uncontrolled. Panels' own `defaultSize` is what a server renders, so prefer that with server rendering. | | `onLayoutChange?` | `((layout: number[], details: ResizableLayoutChangeDetails) => void) \| undefined` | Runs while the layout changes: on every frame of a drag and every key. `details.cancel()` keeps the layout. | | `onLayoutCommit?` | `((layout: number[], details: ResizableLayoutCommitDetails) => void) \| undefined` | Runs once an interaction that changed the layout ends: the pointer lifts, the key comes up, or a panel collapses. For saving. | | `orientation?` | `"horizontal" \| "vertical" \| undefined` | The direction panels are laid out in. Horizontal panels sit side by side, vertical ones stack. Default: `"horizontal"` | | `disabled?` | `boolean \| undefined` | Stops every handle: no drags, no keys, and handles leave the tab order. | | `step?` | `number \| undefined` | How far an arrow key moves a handle, in percent. Default: `1` | | `largeStep?` | `number \| undefined` | How far Shift with an arrow key moves a handle, in percent. Default: `10` | | `autoSaveId?` | `string \| undefined` | Saves the layout when an interaction completes and restores it on the next visit, under this key. Give panels an `id` so it survives changes elsewhere on the page. | | `storage?` | `ResizableStorage \| undefined` | Where `autoSaveId` saves: anything with `getItem` and `setItem`, like a cookie store a server can read. Default: `localStorage` | | `controller?` | `{ getLayout: () => number[]; setLayout: (layout: number[], options?: ResizableChangeOptions) => boolean; collapse: (panel: string \| number, options?: ResizableChangeOptions) => boolean; expand: (panel: string \| number, options?: ResizableChangeOptions) => boolean; resize: (panel: string \| number, size: ResizableSize, options?: ResizableChangeOptions) => boolean; isCollapsed: (panel: string \| number) => boolean; } \| undefined` | Resizes the group from anywhere. Create one with `createResizableController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/resizable). # Rich Text Editor (/docs/components/rich-text-editor) ## Install [#install] pnpm dlx shadcn@latest add https://hacline.huanan-caoo.workers.dev/r/rich-text-editor.json With `@hacline/ui`, use the `@hacline/ui/rich-text-editor` entry and load `@hacline/ui/tokens.css`. ## Editing and saving media [#editing-and-saving-media] Select text to format it, type `/` at the start of a paragraph to insert a block, or drag a block by its handle. Insert an image or video, save the document, and reopen it to see the stored media. This demo saves in your browser. ```tsx "use client"; import { useEffect, useRef, useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import type { JSONContent, RichTextEditorLocale, } from "@/components/ui/hacline/components/rich-text-editor"; import { RichTextEditor } from "@/components/ui/hacline/components/rich-text-editor"; const labels = { en: { empty: "There is no saved document yet.", failed: "Could not save the document. Your draft is still open.", intro: "Edit this paragraph or insert an image or video.", label: "Editable draft", opened: "Saved document reopened.", reopen: "Reopen saved document", save: "Save document", saved: "Document and media saved in this browser.", title: "Project notes", }, ja: { empty: "保存済みの文書はありません。", failed: "文書を保存できませんでした。下書きはそのまま編集できます。", intro: "この段落を編集するか、画像や動画を挿入してください。", label: "編集中の下書き", opened: "保存済みの文書を開きました。", reopen: "保存済みの文書を開く", save: "文書を保存", saved: "文書とメディアをこのブラウザーに保存しました。", title: "プロジェクトノート", }, zh: { empty: "还没有已保存的文档。", failed: "文档保存失败,草稿仍可继续编辑。", intro: "编辑这段文字,或插入图片和视频。", label: "正在编辑的草稿", opened: "已重新打开保存的文档。", reopen: "重新打开已保存文档", save: "保存文档", saved: "文档与媒体已保存到此浏览器。", title: "项目笔记", }, }; const imageTypes = ["image/png", "image/jpeg", "image/webp"]; const videoTypes = ["video/mp4", "video/webm"]; const maxFileBytes = 1024 * 1024; const storeDemoMedia = (file: File) => { const { promise, resolve, reject } = Promise.withResolvers(); const reader = new FileReader(); reader.addEventListener( "load", () => { if (typeof reader.result === "string") { resolve(reader.result); } else { reject(new Error("Expected a media URL")); } }, { once: true } ); reader.addEventListener("error", () => reject(reader.error), { once: true }); reader.readAsDataURL(file); return promise; }; const withSavedMedia = async ( value: JSONContent, files: ReadonlyMap ): Promise => { const uploads = new Map>(); const replace = async (node: JSONContent): Promise => { const source: unknown = node.attrs?.src; if ( (node.type === "image" || node.type === "video") && typeof source === "string" ) { const file = files.get(source); if (file) { const saved = uploads.get(source) ?? storeDemoMedia(file); uploads.set(source, saved); return { ...node, attrs: { ...node.attrs, src: await saved } }; } } if (node.content) { return { ...node, content: await Promise.all(node.content.map(replace)) }; } return node; }; return await replace(value); }; const releasePreviews = (previews: Map) => { for (const url of previews.keys()) { URL.revokeObjectURL(url); } previews.clear(); }; export const RichTextEditorMediaDemo = ({ locale = "en", }: { locale?: RichTextEditorLocale; }) => { const text = labels[locale]; const storageKey = `hacline:rich-text-editor:demo:${locale}`; const [value, setValue] = useState(() => ({ type: "doc", content: [ { type: "heading", attrs: { level: 2 }, content: [{ type: "text", text: text.title }], }, { type: "paragraph", content: [{ type: "text", text: text.intro }] }, { type: "paragraph" }, ], })); const [saving, setSaving] = useState(false); const [status, setStatus] = useState(""); const [session, setSession] = useState(0); const files = useRef(new Map()); useEffect(() => { const previews = files.current; return () => releasePreviews(previews); }, []); const preview = (file: File) => { const url = URL.createObjectURL(file); files.current.set(url, file); return url; }; const openDocument = (document: JSONContent) => { releasePreviews(files.current); setValue(document); // A saved document starts a new session because undo may refer to released URLs. setSession((current) => current + 1); }; const save = async () => { setSaving(true); try { // This demo stores media in the browser. An app can upload each File here. const document = await withSavedMedia(value, files.current); localStorage.setItem(storageKey, JSON.stringify(document)); openDocument(document); setStatus(text.saved); } catch { setStatus(text.failed); } setSaving(false); }; const reopen = () => { const saved = localStorage.getItem(storageKey); if (saved === null) { setStatus(text.empty); return; } const document: JSONContent = JSON.parse(saved); openDocument(document); setStatus(text.opened); }; return (
{ event.preventDefault(); if (!saving) { void save(); } }} >
{status} ); }; ```
Pass `image` or `video` with `accept`, optional `maxBytes`, and `preview(file)`. Keep the returned preview URLs and their files for the editing session. On save, upload the files referenced in the current document, replace their `src` attributes with stored URLs, and persist the JSON. Release the preview URLs when the session ends. Keep them when saving fails so the draft can be retried. ## Controlled and read-only [#controlled-and-read-only] Replace the value from the parent, then turn off read-only to edit. Use `RichTextEditorRoot` with its parts to customize the layout. ```tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import type { JSONContent, RichTextEditorLocale, } from "@/components/ui/hacline/components/rich-text-editor"; import { RichTextEditorContent, RichTextEditorRoot, RichTextEditorStatusBar, RichTextEditorToolbar, } from "@/components/ui/hacline/components/rich-text-editor"; import { Switch } from "@/components/ui/hacline/components/switch"; const labels = { en: { content: ["Draft content", "Content loaded from outside the editor"], editor: "Controlled document", readOnly: "Read only", replace: "Replace document", }, ja: { content: ["下書きの内容", "エディターの外部から読み込んだ内容"], editor: "制御された文書", readOnly: "読み取り専用", replace: "文書を差し替える", }, zh: { content: ["草稿内容", "由编辑器外部载入的内容"], editor: "受控文档", readOnly: "只读", replace: "替换文档", }, }; const makeDocument = (text: string): JSONContent => ({ type: "doc", content: [{ type: "paragraph", content: [{ type: "text", text }] }], }); export const RichTextEditorControlledDemo = ({ locale = "en", }: { locale?: RichTextEditorLocale; }) => { const text = labels[locale]; const [initial, replacement] = text.content; const [document, setDocument] = useState(() => makeDocument(initial)); const [readOnly, setReadOnly] = useState(true); return (
); }; ```
| Prop | Usage | | --- | --- | | `value`, `onChange` | Read and update a Tiptap `JSONContent` document. | | `readOnly` | Show the document with editing controls hidden. Defaults to `false`. | | `label`, `placeholder`, `className` | Set the accessible name, empty hint, and container class. | | `locale` | UI language. Use `en`, `zh`, or `ja`. Defaults to `en`. | | `image`, `video` | Enable the corresponding file picker. The image configuration also enables pasting and dropping image files. | # ScrollArea (/docs/components/scroll-area) ## Import [#import] ```tsx import { ScrollArea, ScrollAreaContent, ScrollAreaCorner, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, } from "@/components/ui/hacline/components/scroll-area"; ``` ## Vertical Scrolling [#vertical-scrolling] By default, `type="hover"` fades in custom scrollbars on pointer hover or active scrolling and hides them automatically afterward. ```tsx {/* Long list content */} ``` ## Horizontal Scrolling [#horizontal-scrolling] Set `orientation="horizontal"` with `type="auto"` to keep the scrollbar visible whenever content overflows horizontally. ```tsx {/* Horizontal cards */} ``` ## Auto-Pinning Logs (`stickToEnd`) [#auto-pinning-logs-sticktoend] When `stickToEnd` is enabled, the viewport tracks new content to the bottom automatically, pauses when the user scrolls up to inspect earlier lines, and resumes once scrolled back to the bottom. ```tsx {/* Dynamically appended log entries */} ``` ## Props [#props] ### ScrollAreaOwnProps | Prop | Type | Description | | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | `type?` | `ScrollAreaType \| undefined` | When scrollbars are shown: `"hover"` (on hover), `"scroll"` (while scrolling), `"auto"` (whenever content overflows), or `"always"`. Default: `"hover"` | | `scrollHideDelay?` | `number \| undefined` | Delay in milliseconds before hiding scrollbars after scrolling stops or the pointer leaves. | | `stickToEnd?` | `boolean \| undefined` | Whether to automatically stay scrolled to the end as content grows (useful for log streams and chat feeds). Default: `false` | | `controller?` | `{ scrollToEnd: (options?: ScrollAreaScrollOptions) => void; scrollToStart: (options?: ScrollAreaScrollOptions) => void; isAtEnd: () => boolean; isAtStart: () => boolean; isSticking: () => boolean; } \| undefined` | External controller instance for programmatic scrolling. | | `className?` | `string \| ((state: NoInfer) => string \| undefined) \| undefined` | Custom class name as a string or a function of `ScrollAreaState`. | # SegmentedControl (/docs/components/segmented-control) ## Usage [#usage] Click or press arrow keys to change the reporting window. The indicator slides to track selection, and the root `value` can drive sibling content. ```tsx "use client"; import { SegmentedControl, SegmentedControlIndicator, SegmentedControlItem, } from "@/components/ui/hacline/components/segmented-control"; export const Example = () => ( Today Last 7 days Last 30 days ); ``` ### Vertical Orientation & Disabled Options [#vertical-orientation--disabled-options] Arrange options vertically and navigate across available density levels with Up/Down arrow keys. ```tsx "use client"; import { SegmentedControl, SegmentedControlIndicator, SegmentedControlItem, } from "@/components/ui/hacline/components/segmented-control"; export const Example = () => ( Comfortable Compact Custom ); ``` ## Parts [#parts] ## Props [#props] ### SegmentedControlOptions The options `segmentedControl` takes. A component takes them as props on its root. | Prop | Type | Description | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `value?` | `T \| null \| undefined` | The checked item's value. Pass it to control the segmented control. `null` checks nothing. | | `defaultValue?` | `T \| null \| undefined` | The item checked at first, when uncontrolled. A form reset returns to it. | | `onValueChange?` | `((value: T \| null, details: ChangeDetails) => void) \| undefined` | Runs when a user or a form reset wants to change the value. `details.reason` says why, and `details.cancel()` stops it. | | `disabled?` | `boolean \| undefined` | Disables every item: they can't be focused or changed, and the value isn't submitted. | | `readOnly?` | `boolean \| undefined` | Keeps the items focusable and the value submitted, but stops changes. | | `required?` | `boolean \| undefined` | Blocks form submission until an item is checked, with the browser's own message. | | `name?` | `string \| undefined` | The name the value submits under. Without one, the segmented control submits nothing. | | `form?` | `string \| undefined` | The id of a form to belong to, when the segmented control isn't inside that form. | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last item to the first. Default: `true` | | `orientation?` | `SegmentedControlOrientation \| undefined` | Which way the items run, for styling and for screen readers. Arrow keys on both axes move between items either way, as in any radio group. Default: `"horizontal"` | | `controller?` | `{ getValue: () => T \| null; setValue: (value: T \| null, details?: SegmentedControlChangeOptions) => boolean; focus: () => void; } \| undefined` | Checks items from anywhere. Create one with `createSegmentedControlController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/segmented-control). # Select (/docs/components/select) ## Import [#import] ```tsx import { Select, SelectArrow, SelectClear, SelectContent, SelectEmpty, SelectGroup, SelectGroupLabel, SelectInput, SelectItem, SelectItemIcon, SelectItemIndicator, SelectItems, SelectItemText, SelectLabel, SelectList, SelectSelectAll, SelectSeparator, SelectStatus, SelectTrigger, SelectValue, SelectValueIcon, } from "@/components/ui/hacline/components/select"; ``` ## Basic Usage [#basic-usage] Group options semantically with `SelectGroup`, `SelectGroupLabel`, and `SelectSeparator`. ```tsx ``` ### Sizes [#sizes] Supports `sm`, `md` (default), and `lg` height scales aligned cleanly with `Input` and `Button`. ```tsx ``` ### Data-Driven [#data-driven] Pass structured `items` (with groups, separators, and disabled flags) directly to `Select` and leave `SelectContent` empty to render styled `SelectItems` automatically, complete with closed-state label reflection and typeahead search. ```tsx import { Select, SelectContent, SelectLabel, SelectTrigger, SelectValue, } from "@/components/ui/hacline/components/select"; import type { ListData } from "@/components/ui/hacline/components/select"; const items: ListData = [ { type: "group", label: "Domestic Regions", items: [ { value: "cn-east", label: "China East (Shanghai)" }, { value: "cn-north", label: "China North (Beijing)" }, { value: "cn-south", label: "China South (Maintenance)", disabled: true }, ], }, { type: "separator" }, { type: "group", label: "Global Regions", items: [ { value: "jp-tokyo", label: "Japan (Tokyo)" }, { value: "us-west", label: "US West (Silicon Valley)" }, ], }, ]; export function RegionDataSelect() { return ( ); } ``` ### Items with Icons [#items-with-icons] Place icons inside options via `SelectItemIcon` and mirror the selected icon onto the trigger with `SelectValueIcon`. ```tsx import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react"; ; ``` ### Multiple Selection, Select All & Clear [#multiple-selection-select-all--clear] Enable `multiple` to select multiple options at once, pair with `SelectSelectAll` to toggle all items, summarize overflow badges with `maxLabels` and `getMoreLabel` on `SelectValue`, and reset quickly with `SelectClear`. ```tsx ``` ### Search Filtering & Status [#search-filtering--status] Combine `SelectInput`, `SelectStatus`, `SelectList`, and `SelectEmpty` inside `SelectContent` for built-in query matching, `` highlights, and an empty state. ```tsx ``` ### Read-Only & Disabled [#read-only--disabled] ```tsx ``` ## Props [#props] ### Select [#select] ### SelectOwnProps | Prop | Type | Description | | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `value?` | `string \| string[] \| null \| undefined` | Controlled selected value (a string or object for single selection, or an array for multiple selection). | | `defaultValue?` | `string \| string[] \| null \| undefined` | Default selected value when uncontrolled. | | `onValueChange?` | `((value: string \| null, details: ChangeDetails) => void) \| ((value: string[], details: ChangeDetails) => void) \| undefined` | Runs when the selected value changes; call `details.cancel()` to cancel the change. | | `multiple?` | `boolean \| undefined` | Whether multiple items can be selected. Default: `false` | | `items?` | `ListData \| undefined` | Data-driven item list supporting automatic list rendering, trigger label resolution, and typeahead search. | | `emptyItems?` | `ListData \| undefined` | Fallback item list shown when the search input is empty (such as recent choices); requires `items` and `SelectInput`. | | `placeholder?` | `string \| undefined` | Placeholder text shown when nothing is selected. | | `query?` | `string \| undefined` | Controlled search query. | | `defaultQuery?` | `string \| undefined` | Default search query when uncontrolled. | | `onQueryChange?` | `((query: string, details: TextChangeDetails) => void) \| undefined` | Runs when the search query changes. | | `filter?` | `ListFilter \| undefined` | Filtering strategy used with `SelectInput`: `"contains"`, `"startsWith"`, a custom filter function, or `false` (for server-side filtering). Default: `"contains"` | | `status?` | `AsyncOptionsStatus \| undefined` | Async option loading status: `"idle"`, `"loading"`, or `"error"`. Default: `"idle"` | | `onLoadMore?` | `(() => void) \| undefined` | Runs when scrolling or highlighting reaches the last item to load the next page. | | `announcement?` | `((change: ListAnnouncement) => string \| null \| undefined) \| undefined` | Function that generates screen reader announcements when search results change. | | `itemToValue?` | `((value: string) => string) \| undefined` | Function that serializes an object item value into a unique string for form submission. | | `itemToLabel?` | `((value: string) => string) \| undefined` | Function that formats a selected value into display text for the trigger (useful for unrendered async items). | | `isItemEqualToValue?` | `((itemValue: string, value: string) => boolean) \| undefined` | Custom equality comparator to determine whether an item value matches a selected value. | | `onHighlight?` | `((value: string \| null, details: ListHighlightDetails) => void) \| undefined` | Runs when the highlighted item changes, including its visible index for virtualized list scrolling. | | `loop?` | `boolean \| undefined` | Whether arrow key navigation wraps between the first and last items. Default: `true` | | `virtualFocus?` | `boolean \| undefined` | Whether focus stays on the trigger while open, pointing to the highlighted item with `aria-activedescendant`. Default: `false` | | `modal?` | `"pointer" \| boolean \| undefined` | Modal interaction mode: `"pointer"` (default), `true` (locks scroll and makes the rest of the page inert), or `false`. Default: `"pointer"` | | `presentation?` | `PresentationSetting<"popover"> \| undefined` | Popup presentation mode: `"popover"`, `"sheet"`, or `"auto"` (switches to a bottom sheet on small touch screens). Default: `"popover"` | | `disabled?` | `boolean \| undefined` | Whether the select is disabled. Default: `false` | | `readOnly?` | `boolean \| undefined` | Whether the select is read-only (focusable and submitted with the form, but cannot be changed). Default: `false` | | `required?` | `boolean \| undefined` | Whether a selection is required. Default: `false` | | `name?` | `string \| undefined` | Field name used when submitting the form. | | `form?` | `string \| undefined` | The `id` of an associated external form. | | `autoComplete?` | `string \| undefined` | Browser autofill hint (such as `"country"`). | | `open?` | `boolean \| undefined` | Controlled open state. | | `defaultOpen?` | `boolean \| undefined` | Default open state when uncontrolled. Default: `false` | | `onOpenChange?` | `((open: boolean, details: ChangeDetails) => void) \| undefined` | Runs when the open state changes. | | `onOpenChangeComplete?` | `((open: boolean) => void) \| undefined` | Runs once the open or close animation finishes. | | `controller?` | `{ isOpen: () => boolean; setOpen: (open: boolean, options?: SelectChangeOptions) => boolean; open: (options?: SelectChangeOptions & { signal?: AbortSignal; }) => Promise>; close: (options?: SelectChangeOptions) => boolean; toggle: (options?: SelectChangeOptions) => boolean; getValue: () => any; setValue: (value: any, options?: SelectChangeOptions) => boolean; clear: (options?: SelectChangeOptions) => boolean; getQuery: () => string; setQuery: (query: string, options?: SelectChangeOptions) => boolean; focus: () => void; } \| undefined` | External controller instance created with `createSelectController()`. | ### SelectTrigger [#selecttrigger] ### SelectTriggerOwnProps | Prop | Type | Description | | ------------ | ----------------------------------------------------------------------------- | -------------------------------------------- | | `size?` | `"lg" \| "md" \| "sm" \| null \| undefined` | Size variant of the trigger. Default: `"md"` | | `className?` | `string \| ((state: SelectTriggerState) => string \| undefined) \| undefined` | Custom class name. | ### SelectValue [#selectvalue] ### SelectValueOwnProps | Prop | Type | Description | | --------------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | `placeholder?` | `string \| undefined` | Placeholder text shown when nothing is selected (overrides the `placeholder` on `Select`). | | `maxLabels?` | `number \| undefined` | Maximum number of labels shown in multiple-selection mode; extra items are summarized using `getMoreLabel`. | | `getMoreLabel?` | `((count: number) => string) \| undefined` | Function that formats the summary label when selected items exceed `maxLabels`. | | `className?` | `string \| ((state: SelectValueState) => string \| undefined) \| undefined` | Custom class name as a string or a function of `SelectValueState`. | ### SelectContent [#selectcontent] ### SelectContentOwnProps | Prop | Type | Description | | ----------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | `side?` | `Side \| undefined` | Preferred side for the list to open on; flips automatically when there isn't room. Default: `"bottom"` | | `align?` | `Align \| undefined` | Alignment relative to the trigger. Default: `"start"` | | `sideOffset?` | `number \| undefined` | Gap between the list and its trigger, in pixels. Default: `4` | | `alignOffset?` | `number \| undefined` | Offset along the trigger, in pixels. Default: `0` | | `alignItemWithTrigger?` | `boolean \| undefined` | Whether to overlap the trigger so the selected item aligns with it (like a native macOS select). Default: `false` | | `keepMounted?` | `boolean \| undefined` | Whether to keep the popup mounted in the DOM while closed. Default: `false` | | `className?` | `string \| ((state: SelectContentState) => string \| undefined) \| undefined` | Custom class name as a string or a function of `SelectContentState`. | # Separator (/docs/components/separator) ## Import [#import] ```tsx import { Separator } from "@/components/ui/hacline/components/separator"; ``` ## Horizontal & Vertical [#horizontal--vertical] ```tsx
Docs Components
```
## Decorative Dividers [#decorative-dividers] Mark purely visual dividers with `decorative` so screen readers flow seamlessly across adjacent text. ```tsx "use client"; import { Separator } from "@/components/ui/hacline/components/separator"; export const Example = () => (
Version 2.4 Synced
); ```
## Props [#props] ### SeparatorOwnProps | Prop | Type | Description | | -------------- | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | `orientation?` | `SeparatorOrientation \| undefined` | Orientation of the separator: `"horizontal"` or `"vertical"`. Default: `"horizontal"` | | `decorative?` | `boolean \| undefined` | Whether the separator is purely decorative (when `true`, hides the `separator` role from screen readers). Default: `false` | | `className?` | `string \| ((state: NoInfer) => string \| undefined) \| undefined` | Custom class name as a string or a function of `SeparatorState`. | # Slider (/docs/components/slider) ## Usage [#usage] Drag either endpoint of the range or step incrementally with arrow keys. Each `SliderThumb` binds to a value by `index` and exposes its own accessible label. ```tsx "use client"; import { Slider, SliderControl, SliderIndicator, SliderThumb, SliderTrack, SliderValue, } from "@/components/ui/hacline/components/slider"; export const Example = () => ( ); ``` ### Vertical Single Value & Percentage [#vertical-single-value--percentage] Represent notification volume from `0` to `1` while formatting the readout as a percentage via `format`. ```tsx "use client"; import { Slider, SliderControl, SliderIndicator, SliderThumb, SliderTrack, SliderValue, } from "@/components/ui/hacline/components/slider"; export const Example = () => ( ); ``` ## Parts [#parts] ## Props [#props] ### SliderOptions The options `slider` takes. A component takes them as props on its root. | Prop | Type | Description | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `value?` | `Value \| undefined` | The value: a number for one thumb, or an array with one number per thumb, like `[20, 80]` for a range. Pass it to control the slider. | | `defaultValue?` | `Value \| undefined` | The value at first, when uncontrolled. A form reset returns to it. Default: `min` | | `onValueChange?` | `((value: Value, details: SliderValueChangeDetails) => void) \| undefined` | Runs while the value changes: on every step of a drag or a key. `details.thumb` says which thumb moved, and `details.cancel()` stops it. | | `onValueCommit?` | `((value: Value, details: SliderValueCommitDetails) => void) \| undefined` | Runs once an interaction that changed the value ends: the pointer lifts, the key comes up, or a screen reader adjusts it. For saving. | | `min?` | `number \| undefined` | The lowest value. Default: `0` | | `max?` | `number \| undefined` | The highest value. When the steps from `min` don't land on it, the highest step below it is the end. Default: `100` | | `step?` | `number \| undefined` | How far one step moves, from `min`. Default: `1` | | `largeStep?` | `number \| undefined` | How far Page Up, Page Down and Shift with an arrow key move. Default: `10 steps` | | `minStepsBetweenThumbs?` | `number \| undefined` | How many steps apart neighbouring thumbs stay. Thumbs never pass each other. Default: `0` | | `orientation?` | `"horizontal" \| "vertical" \| undefined` | The slider's axis. Vertical sliders grow upward. Default: `"horizontal"` | | `disabled?` | `boolean \| undefined` | Disables it like a native control: thumbs can't be focused or moved, and nothing is submitted. | | `readOnly?` | `boolean \| undefined` | Keeps it focusable and submitted, but stops drags, keys and screen reader adjustments from changing it. | | `required?` | `boolean \| undefined` | Marks it required, with `data-required`. A slider always has a value, so it never blocks a form. | | `name?` | `string \| undefined` | The name it submits under: the number, or a range as `"start/end"`. Without one, it submits nothing. | | `form?` | `string \| undefined` | The id of a form to belong to, when it isn't inside that form. | | `format?` | `NumberFormat \| undefined` | How values read, for screen readers and `SliderValue`: `Intl.NumberFormat` options, like `{ style: "currency", currency: "EUR" }`, or a function of the value. | | `locale?` | `string \| undefined` | The locale values are formatted in. Defaults to the page's `lang`, or the browser's language without one, once the page is interactive. Server markup uses English until then, so it never disagrees with the client. | | `controller?` | `{ getValue: () => Value; setValue(value: Value, options?: SliderChangeOptions): boolean; focus: (thumb?: number) => void; } \| undefined` | Moves the slider from anywhere. Create one with `createSliderController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View UI SDK parts and state attributes](https://ui-sdk.dev/docs/react/components/slider). # Switch (/docs/components/switch) ## Import [#import] ```tsx import { Switch, SwitchThumb } from "@/components/ui/hacline/components/switch"; ``` ## Basic Usage [#basic-usage] Pair with `Field` (`orientation="horizontal"`) and `FieldLabel` to bind the label automatically, allowing users to toggle the switch by clicking the label. ```tsx const [enabled, setEnabled] = useState(true);
Auto-sync settings Status: {enabled ? "On" : "Off"}
Small disabled
; ```
### Submitting Boolean Settings [#submitting-boolean-settings] Associate the switch with a form field. Your app saves the switch state based on whether the field is present in the submitted form data. ```tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/hacline/components/button"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; import { Switch } from "@/components/ui/hacline/components/switch"; export const Example = () => { const [saved, setSaved] = useState(""); return (
setSaved( data.has("weekly") ? "Weekly digest enabled" : "Weekly digest disabled" ) } className="grid justify-items-start gap-3" > Receive weekly digest {saved && {saved}} ); }; ```
## Props [#props] ### SwitchOwnProps | Prop | Type | Description | | ------------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- | | `size?` | `"md" \| "sm" \| null \| undefined` | Size variant of the switch. Default: `"md"` | | `checked?` | `boolean \| undefined` | Controlled checked state of the switch. | | `defaultChecked?` | `boolean \| undefined` | Default checked state of the switch when uncontrolled. Default: `false` | | `onCheckedChange?` | `((checked: boolean, details: ChangeDetails) => void) \| undefined` | Runs when the checked state changes. | | `disabled?` | `boolean \| undefined` | Disables the switch. Default: `false` | | `name?` | `string \| undefined` | Field name used when submitting the form. | | `className?` | `string \| ((state: SwitchState) => string \| undefined) \| undefined` | Custom class name as a string or a function of `SwitchState`. | # Tabs (/docs/components/tabs) ## Usage [#usage] Click a tab or use the arrow keys to switch content. Pass the same `value` to `TabsTab` and `TabsPanel` to connect them. ```tsx "use client"; import { Tabs, TabsIndicator, TabsList, TabsPanel, TabsTab, } from "@/components/ui/hacline/components/tabs"; export const Example = () => ( Overview Activity Members Design handoff is scheduled for this week. Latest edit by the docs lead. 4 collaborators on this project. ); ``` ### Manually Activated Vertical Tabs [#manually-activated-vertical-tabs] The Up and Down arrow keys move focus only; press Enter or Space to switch the active panel. ```tsx "use client"; import { Tabs, TabsList, TabsPanel, TabsTab, } from "@/components/ui/hacline/components/tabs"; export const Example = () => ( Raw data Summary report Showing 32 records. Grouped by department. ); ``` ## Parts [#parts] ## Props [#props] ### TabsOptions The options `tabs` takes. A component takes them as props on its root. | Prop | Type | Description | | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `value?` | `T \| null \| undefined` | The selected tab's value. Pass it to control the tabs. `null` selects nothing. | | `defaultValue?` | `T \| null \| undefined` | The tab selected at first, when uncontrolled. Defaults to the first enabled tab, which never calls `onValueChange`. | | `onValueChange?` | `((value: T \| null, details: ChangeDetails) => void) \| undefined` | Runs when the selection wants to change. `details.reason` says why, and `details.cancel()` stops it. | | `orientation?` | `TabsOrientation \| undefined` | Which arrow keys move between tabs: left and right, or up and down. Default: `"horizontal"` | | `activation?` | `"automatic" \| "manual" \| undefined` | `"automatic"` selects a tab as soon as arrow keys focus it. `"manual"` waits for Enter or Space. Default: `"automatic"` | | `loop?` | `boolean \| undefined` | Whether arrow keys wrap from the last tab to the first. Default: `true` | | `hiddenUntilFound?` | `boolean \| undefined` | Keeps hidden panels in the page as `hidden="until-found"`, so the browser's find in page can match their text and select their tab. Implies `keepMounted`. Default: `false` | | `controller?` | `{ getValue: () => T \| null; setValue: (value: T \| null, options?: TabsChangeOptions) => boolean; select: (value: T, options?: TabsChangeOptions) => boolean; focus: () => void; } \| undefined` | Selects tabs from anywhere. Create one with `createTabsController()`. | | `debug?` | `boolean \| undefined` | Logs every state change with its reason to the console, in development builds. | [View parts and state attributes in UI SDK](https://ui-sdk.dev/docs/react/components/tabs). # Textarea (/docs/components/textarea) ## Usage [#usage] Type or add line breaks to update the character count feedback. Pair `Textarea` with `FieldLabel` and set `autoResize` to expand the input area with its content. ```tsx "use client"; import { useState } from "react"; import { Field, FieldLabel } from "@/components/ui/hacline/components/field"; import { Textarea } from "@/components/ui/hacline/components/textarea"; const MAX_LENGTH = 120; export const Example = () => { const [notes, setNotes] = useState(""); const isTooShort = notes.length > 0 && notes.length < 10; return (
Review notes