# Radix NG Primitives — Full Documentation Unstyled, accessible, signals-first Angular primitives for building design systems and web apps. Examples use Angular signals and Tailwind CSS v4 utilities; the primitives themselves are styling-agnostic. Generated from `@radix-ng/primitives@1.4.2` — if the installed version differs, verify the API against the installed package. --- # Build with Radix NG #### Build your application's styled components on top of headless primitives. Start with the version check in [Getting started](agents/getting-started.md). Use the local bundle for focused retrieval rather than loading the complete documentation each time. ## From a request to your AppSelect One recorded task asked an agent to build a reusable selection control inside a Project settings Dialog. The result was a standalone `AppSelect` with typed `value` / `valueChange` bindings plus `disabled` and `label` inputs, public Select imports and an application-owned Dialog composition. The application supplies the options, selected value, disabled state, content and CSS tokens. It retains the value when Dialog closes. The checks covered external updates, one change callback per selection, disabled navigation, keyboard selection, nested `Escape` and return to the appropriate Select or Dialog trigger. See [the recorded result](agents/verify-the-result.md#recorded-generation-results), including the correction to its disabled tests. Start from the maintained [Select focus-management example](components/select.md) and its bundled source, `references/examples/select--focus-management.md`. A design system is not required: one wrapper and an explicit styling approach are enough to begin. ### Prompt: AppSelect inside Dialog Replace bracketed values with your application's files, data and labels. This is an adaptable product task based on the completed experiment, not a promise that another run will pass. ```text Use the installed radix-ng and radix-ng-examples skills. Check the installed Radix NG and Angular versions, then read the Select/Dialog contracts and the closest nesting example. When versions differ, verify the API against installed exports and types. Create a reusable standalone AppSelect inside a Dialog for [route or feature]. Styles: [paths to our tokens/styles and CSS or utility conventions]. Use application-owned styles for the control, popup, Dialog, focus and disabled states; replace Storybook helpers. Data: [our typed options and labels; for example Private/private and Public/public]. Dialog title: [Project settings]. Select label: [Visibility]. Expose typed value/valueChange, disabled and label bindings using public Radix NG imports. The parent owns the selected value and disabled state; use explicit parent value bindings. Keep selection after closing/reopening Dialog. Add a small demo with external value updates and a disabled toggle. Preserve the primitives' composition and interaction behavior. Check strict Angular template compilation, public imports and accessible names. Verify keyboard selection and one valueChange per user selection, with no extra emission for external updates. Tab/Shift+Tab must skip a disabled Select; enabling restores selection. Escape closes Select before Dialog. Closing each overlay returns focus to its trigger, including after exit transitions; focus stays within the modal Dialog while it is open. Return the component/integration changes, commands and check results, and anything unverified. ``` ## AppEmailField with a parent-owned FormControl A separate recorded task produced a standalone `AppEmailField` over Radix NG Field. Its required inputs are `control: FormControl`, `label` and `description`. The wrapper associates a native email input with Field's label, description and error messages, using Angular Reactive Forms. The application creates the control, owns its value and validators, calls `disable()` / `enable()`, handles submission/reset and supplies CSS. The wrapper binds that control directly. Checks covered label/description relationships, initially hidden errors, required/email feedback after blur or submission, correction, two-way control updates, disabled behavior, reset and exactly-once delivery of the current value. See [the recorded result](agents/verify-the-result.md#recorded-generation-results). The maintained [Field Reactive Forms example](components/field.md), bundled as `references/examples/field--reactive-forms.md`, supplies a starting pattern; it is separate from the agent-generated wrapper. ### Prompt: AppEmailField ```text Use the installed radix-ng and radix-ng-examples skills. Check the installed Radix NG and Angular versions, then read the Field contracts and Reactive Forms example. When versions differ, verify the API against installed exports and types. Create a standalone AppEmailField over Radix NG Field for [route or feature]. Styles: [paths to our tokens/styles and CSS or utility conventions]. Use application-owned focus, disabled and error styles; replace Storybook helpers. Content: label [Project email], description [where and why this address is used]. Data/delivery: [our initial value and submit handler; use a local list for a standalone demo]. Required inputs: control: FormControl, label: string and description: string. Use Angular Reactive Forms and public Radix NG Field imports. Bind the supplied control directly; the parent owns its value, validators and disabled state. Do not duplicate its model or replace its validators. Connect the native email input to its label/description. In a demo form, the parent creates a nonNullable control with required/email validators. Show separate required/email errors only after blur or an attempted submission that marks the controls touched. Provide submit, reset, external setValue and disable/enable controls. Reset restores the initial value, pristine/untouched and hidden errors. Invalid submission shows errors without delivery; each valid submission delivers the current value once. Compile both the demo and a separate parent against this public API with strict templates. Verify label/description associations, error timing/correction and two-way value updates. Check that disabled prevents editing and is skipped by Tab/Shift+Tab, external setValue still renders while disabled, and enable restores keyboard editing. Verify reset and submit. Return the implementation, commands and check results, and anything still unverified. ``` Both prompts ask for code in your application and evidence from its checks. Recorded outcomes apply to the earlier skills snapshot listed in Verify the result, not to every later bundle or generated UI. ## Choose the interaction | Need | Start with | | ----------------------------------------------- | ------------------------------------------------------ | | A labelled text field with validation feedback | Input, Field; Form or Fieldset when grouping is needed | | Select one or more known values | Select; Combobox when filtering is needed | | Suggest text without committing a selected item | Autocomplete | | A modal task | Dialog; Alert Dialog for an interrupting confirmation | | A list of actions | Menu; Menubar for persistent coordinated menus | | Layered sections of one page | Tabs | The `radix-ng-examples` index links to `references/components/.md`. That component index contains imports and anatomy and links to `references/examples/--.md` for the full source of one example. Prefer the closest form, wrapper or nesting example to a bare default. ## Read the contract before writing bindings Open these files in the installed `radix-ng` skill for each primitive involved: - `references/api-contract/.json`: directive names, selectors, `exportAs`, input types and defaults, outputs, and the `twoWay` model bindings. - `references/styling-contract/.json`: anatomy and documented hooks with their owning parts and authored value descriptions. Import standalone directives from their public secondary entry points and include template directives in the component's `imports`. A directive composed through `hostDirectives` belongs in that metadata instead. Expose the wrapper's intended inputs and outputs explicitly. Examples may use local story helpers for classes or icons. Replace those with your application's own tokens and dependencies; repository-only `../../storybook` imports are not an npm API. ## Preserve the part's own state hooks Select Popup exposes `data-open` / `data-closed`; Accordion Trigger exposes `data-panel-open`. Tabs Tab uses `data-active`. These are different contracts. Read each part rather than assuming a universal `data-state`. Presence attributes are normally empty strings when present, so match presence rather than `data-open="true"`. Toast Root retains its documented `data-state` values. State attributes describe the primitive's state. Set documented inputs or models to change that state; adding attributes to your markup does not operate the component. ## Complete one interaction Compile it in the consumer application before adding variants. Then follow [Verify the result](agents/verify-the-result.md). For a compound component, read [Compose components](agents/compose-components.md) before moving parts into wrappers. Agent Playground's experimental `snapshot` / `query` / `act` operates an already running UI. It does not generate these wrappers and is not installed with the consumer skills. --- # Compose components #### Preserve Angular ownership while adapting headless parts to your application. Use the [composition guide](guides/composition.md) and the chosen primitive's anatomy for the full patterns. The installed `radix-ng` skill also bundles `references/composition.md` and `references/forms.md` for offline use. ## Wrappers and hostDirectives Keep the state-owning Root on the wrapper host when projected children need its context. `hostDirectives` composes the primitive onto that host; explicitly expose the inputs and outputs that form your wrapper API. Use standalone components and direct public imports. Projection moves rendering, not the declaring injector ancestry. A Root hidden inside the wrapper's template can be out of reach of projected parts. Tabs and Navigation Menu document a bridge for their projected top-level items; this is a specific contract, not a property of every primitive. For Tabs, start with [Projected through wrapper](components/tabs.md). Its source composes `RdxTabsRoot` onto the wrapper host, keeps `RdxTabsList` in the wrapper view, and projects the consumer's tabs and panels. The nearest example is bundled as `references/examples/tabs--projected-through-a-wrapper.md` in `radix-ng-examples`. ## DI and part placement Keep each part beneath its documented provider-bearing owner. DOM containment alone does not establish the Angular injection context. A Menu submenu uses its own Menu Root; a trigger, popup or form part should not acquire an unrelated outer owner's state after a refactor. Use the documented portal directive and template placement. Moving an overlay into a new wrapper or replacing its portal with an `@if` can change queries, focus ownership and close completion. Check the real browser behavior after changing these boundaries. ## Forms Follow the [forms guide](guides/forms.md) for your chosen form system. Field groups a control with its label, description and errors; it does not supply Angular validators itself. Use `rdxFieldControl` for an ordinary native control, or a control such as `rdxInput` that already integrates with Field. Avoid stacking both integrations on the same native input. For Reactive Forms, the documented `rdxNgControlField` adapter reports form state. For Signal Forms, check the installed Angular version and the [Signal Forms examples](components/signal-forms.md). Use `rdxFieldLabel` for Field's automatic association or explicit native `for` / `id` elsewhere. Displayed invalid state can remain neutral until the configured validation interaction occurs. ## Nested overlays Treat each overlay as an independent owner. A Select inside Dialog must close without dismissing its parent; closing the Dialog must restore its own trigger. Read [Select focus management](components/select.md) and use the Dialog shell variant. For a Dialog opened from Menu, start with [Menu's opening-a-dialog example](components/menu.md). It composes `rdxMenuItem` with `rdxDialogTrigger` and a shared Dialog handle. Menu close completion must preserve focus in the new Dialog, including when the Menu is retained or finishing an exit. Use documented handles and events rather than timeouts or manually focusing a popup after each change. The four tasks in [Verify the result](agents/verify-the-result.md) make these composition requirements observable. --- # Getting started #### Give a coding agent context to build and verify your own Angular UI components. Radix NG is a headless library. Its skills help an agent build your application's components on top of the primitives while preserving their behavior. Your application supplies the appearance. - **Installing skills gives the agent context:** documentation, versioned API contracts and example source from `radix-ng` and `radix-ng-examples`. - **Assigning a UI task should produce application code:** your own standalone Angular component, such as `AppSelect`, integrated with your styles and chosen forms approach, plus a report of the checks performed and their results. Installing skills does not create components. You can start with one component and a chosen styling approach; a finished design system is not a prerequisite. | Responsibility | What it supplies | | ---------------- | ------------------------------------------------------------------------------ | | Radix NG | Headless primitives, state, composition and interaction mechanisms. | | Skills | Instructions for using the API, example source and documented checks to adapt. | | Your application | Visual tokens, CSS, the product API of wrappers, content and business logic. | Skills provide context, not a guarantee of correctness. Compile and test the assembled UI in your application, and support keyboard, focus and accessibility claims with the checks you actually ran. ## Install the consumer skills Install the library using the [installation guide](overview/installation.md), then install the two consumer skills: ```bash npx skills add radix-ng/primitives/skills ``` With pnpm, use `pnpm dlx skills add radix-ng/primitives/skills`. Select the coding agent and scope offered by the installer. The `/skills` source path distributes the consumer bundle; the repository's `.agents/skills` directory contains contributor workflows instead. - `radix-ng` explains API lookup, styling, forms and composition. - `radix-ng-examples` indexes documented examples and bundles their source offline. Ask your agent to use both skills explicitly if it does not select them automatically. Find their installed folders before following the relative reference paths in these guides. ## Check the installed version In your application, inspect the resolved library version, for example: ```bash pnpm list @radix-ng/primitives --depth 0 ``` Compare it with `version` in `radix-ng/references/api-contract/.json` and `radix-ng/references/styling-contract/.json`. Example shards also carry a generation stamp. The bundle's version is the source package version, not a certification that it matches your app. **The installed package wins.** When versions differ, inspect its exported declarations and `.d.ts` files before applying an example. Check the installed package's Angular peer dependencies as well. Use documentation from the matching release when available, and let Angular's template compiler verify selectors, inputs, outputs and value types. Current online docs can be newer than your install. ## Start with a bounded prompt ```text Use the radix-ng and radix-ng-examples skills. Task: create our AppSelect on Radix NG for [route or use case]. Interaction: [selection mode, options, labels, value and disabled/read-only behavior]. Appearance: [project tokens and CSS/Tailwind conventions, or the chosen styling approach]. Forms: [the project's form strategy, or explicit value bindings if no forms are needed]. Acceptance: [expected value updates, validation, keyboard selection, closing and focus return]. First identify the installed @radix-ng/primitives and Angular versions. Read the relevant per-primitive API and styling contracts and the closest example. If the bundle version differs, verify the API against installed exports and types. Use standalone components and preserve the documented DI and projection boundaries. Implement the component and integrate it with this application's styles and forms. Compile the application's Angular templates, then check the acceptance criteria. Return the implementation and integration changes, the commands/checks run and their results, and anything still unverified. Do not claim a check passed if it was not run. ``` Replace the bracketed requirements with your choices. See [Build with Radix NG](agents/build-with-radix-ng.md) for the expected AppSelect deliverable. Prefer one interaction you can run and inspect before expanding the page. ## Separate runtime experiment The [Agent Playground](https://www.radix-ng.com/playground/agents/) is a runtime experiment for inspecting and interacting with controls in a running demo. Try a built-in command in the browser or follow the local Codex setup. Use the consumer skills above to build components in your application. ## Continue - [Build with Radix NG](agents/build-with-radix-ng.md): select a primitive and example. - [Compose components](agents/compose-components.md): wrappers, forms and overlays. - [Verify the result](agents/verify-the-result.md): checks and four reproducible tasks. - [Reference](agents/reference.md): contracts, Markdown and LLM exports. --- # Reference #### Retrieve one versioned contract or example before loading the full documentation. ## Installed consumer bundle Paths are relative to the installed skill, not this repository's contributor skills. | Material | Path | | ------------------------------- | ------------------------------------------------------------ | | API for one primitive | `radix-ng/references/api-contract/.json` | | Styling for one primitive | `radix-ng/references/styling-contract/.json` | | Component index and anatomy | `radix-ng-examples/references/components/.md` | | One example's source | `radix-ng-examples/references/examples/--.md` | | Agents guides | `radix-ng-examples/references/agents/*.md` | | Discovery index | `radix-ng-examples/references/llms.txt` | | Complete rendered documentation | `radix-ng-examples/references/llms-full.txt` | The whole-library `api-contract.json` and `styling-contract.json` files are deprecated compatibility exports. Prefer individual primitive files to keep retrieval focused. ## Public contracts These exports are generated from the same sources as the local bundle. Read their `version` field; the installed package's types take precedence when versions differ. | Primitive | API | Styling | | --------- | ----------------------------------------------------------------- | --------------------------------------------------------------------- | | Input | [input.json](https://radix-ng.com/docs/api-contract/input.json) | [input.json](https://radix-ng.com/docs/styling-contract/input.json) | | Select | [select.json](https://radix-ng.com/docs/api-contract/select.json) | [select.json](https://radix-ng.com/docs/styling-contract/select.json) | | Dialog | [dialog.json](https://radix-ng.com/docs/api-contract/dialog.json) | [dialog.json](https://radix-ng.com/docs/styling-contract/dialog.json) | Other primitive files use the same slug as their component index. Styling entries retain the documented part name in `parts` and the authored value or presence description in `values`. The styling export contains documented hooks, not an inferred inventory of private DOM attributes. ## Markdown and LLM discovery - [llms.txt](https://radix-ng.com/docs/llms.txt): links to individual Markdown pages. - [llms-full.txt](https://radix-ng.com/docs/llms-full.txt): complete documentation when broad context is needed. - [Agents getting started](https://radix-ng.com/docs/agents/getting-started.md): this guide as Markdown. - [Select index](https://radix-ng.com/docs/components/select.md): anatomy and links to focused source shards. Storybook's **Agents** section and these files share their MDX source. The exports are generated with `pnpm skills:build`; generation does not run a coding agent or certify its output. --- # Verify the result #### Compile the consumer's templates and verify observable interaction contracts. Use the application's existing build and test commands. Run its Angular template compiler with strict template checks: a TypeScript-only transpile cannot establish that Angular bindings are valid. Check public imports, standalone `imports`, input types, event payloads and exposed wrapper bindings. ## Observe the rendered result - Find controls by role and accessible name; verify label and description relationships. - Exercise the documented keyboard path, including disabled controls, selection and dismissal. - Check initial focus, containment where required, and focus return after closing. - Exercise nested overlays and real portal/exit behavior in a browser. DOM-only tests cannot prove positioning, visibility, native focus or scrolling. - Check that no runtime or Angular errors appear during the interaction. Follow the relevant primitive's [accessibility documentation](overview/accessibility.md). An automated check covers its assertions, not complete accessibility conformance. ## Recorded generation results Two separate coding tasks produced application components in clean Angular consumers using the installed skills and a local library tarball. Both generated applications and their independent parents passed production builds with strict templates and public-import checks. Neither component was manually repaired by the evaluator; agent self-corrections stayed within its own coding session. | Generated component | Confirmed Chromium result | Checked behavior | Engineering report | | ------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | AppSelect inside Dialog | **4/4 after correcting the tests** | External value/disabled bindings, callback payload/count, selection persistence, keyboard, nested Escape and focus return. | [AppSelect report and test correction](https://github.com/radix-ng/primitives/blob/1fb1ee33805cfe5f685b4b4d4e92a3b228e0b1b0/tools/consumer-testing/generation/REPORT-REEVALUATION-V2.md) | | AppEmailField with parent FormControl | **8/8 original frozen checks** | Labels/descriptions, required/email errors, control synchronization, disabled navigation/editing, reset and submission. Four cases per host. | [AppEmailField report](https://github.com/radix-ng/primitives/blob/7743fc39590779aac048ba1bed499ef5f318a7d6/tools/consumer-testing/generation/email-field/REPORT.md) | Both used **Chromium 148.0.7778.96**, **Radix NG 1.3.0**, **Angular 22.0.2**, the earlier consumer skills snapshot [d000174e](https://github.com/radix-ng/primitives/tree/d000174e3fb69ef5424b73492d73f34b84e3c80f/skills), and **gpt-6.1-sol** with **low** reasoning effort through a Codex subscription coding session. These historical results do not validate the newly generated bundle containing this page. **AppSelect's test correction remains part of the result.** The original frozen suite recorded **3/4**. Its disabled checks were corrected to use real `Tab` / `Shift` + `Tab` navigation and expected focus targets instead of pressing a disabled trigger. The same unchanged component then passed **4/4**, without another generation session. The original failure remains in the engineering report. AppEmailField passed all eight checks frozen before its session, without a later test correction. These are two individual generation results, **not an overall reliability estimate**. Their test counts cover different tasks and are not comparable success rates. The original generation checks used Chromium; the saved code was later reevaluated across engines below. Complete accessibility conformance was not evaluated. Exact inputs, hashes, logs and sandbox limitations belong to the linked engineering reports. ### Cross-browser reevaluation of the saved code The same saved components, library and installed dependencies were checked again on macOS, without another generation session or manual component repairs. All **36 checks passed**, with no retries or skips. Library **1.3.0**, Angular **22.0.2** and the original **d000174e** skills context stayed unchanged; this does not evaluate the current consumer bundle or establish general generation reliability. | Saved component | Chromium 148.0.7778.96 | Firefox 150.0.2 | WebKit 26.4 | | ------------------------------------- | ---------------------- | --------------- | ----------- | | AppSelect inside Dialog | 4/4 | 4/4 | 4/4 | | AppEmailField with parent FormControl | 8/8 | 8/8 | 8/8 | The first cross-browser matrix recorded **35/36**: a check assumed that pointer-clicking a checkbox focused it in macOS WebKit. A native HTML reproduction showed the same difference without Angular or Radix NG. The corrected check explicitly establishes its keyboard starting focus and retains all focus, disabled, value and event assertions. WebKit uses the repository's native full-keyboard navigation convention. Both matrices and the reproduction are retained in the [cross-browser engineering report](https://github.com/radix-ng/primitives/blob/main/tools/consumer-testing/generation/cross-browser/REPORT.md). For tasks you can adapt to your styles and data, use the [AppSelect prompt](agents/build-with-radix-ng.md#prompt-appselect-inside-dialog) or [AppEmailField prompt](agents/build-with-radix-ng.md#prompt-appemailfield). ## Reproducible coding-agent tasks The prompts below describe maintained reference fixtures. Pair each one with the starter prompt from [Getting started](agents/getting-started.md) and your application's constraints. They remain separate from the generated components reported above: passing these example checks does not establish an agent-generation success rate. ### Form with labels and validation ```text Build a standalone email form using Radix NG Field and Angular Reactive Forms. Use a visible Email label, description, required/email validators and separate error messages. Preserve invalid, dirty and touched styling through the documented state hooks. Compile the Angular template and verify the form with keyboard input. ``` Reference: [Field — Reactive Forms](components/field.md), bundled source `references/examples/field--reactive-forms.md`. Success criteria: - Public Field imports and `ReactiveFormsModule`; valid `formControlName`, `rdxFieldControl` and `rdxNgControlField` bindings compile without permissive schemas. - The native input is named Email and is connected to the visible description and errors. - Keyboard submission reveals the required error. Entering invalid email shows the email error; correcting it clears displayed invalid state. Dirty/touched state reflects actual interaction. - `Tab` moves between the input and Submit; submission does not strand focus. ### Select inside Dialog ```text Build a Dialog titled Choose a fruit with a labelled Fruit Select inside it. Offer Apple, Banana and Cherry. Keep selection state when the Select closes. Escape must close the Select before the Dialog; each close restores the right trigger. Compile the Angular template and verify keyboard selection and nested focus in a browser. ``` Reference: [Select — Focus management](components/select.md), using its Dialog shell; bundled source `references/examples/select--focus-management.md`. Success criteria: - Public Select and Dialog imports, portal anatomy and value/open bindings compile. - The Dialog and combobox have the requested accessible names before selecting an option. - `Enter` opens Select, arrows change the highlighted option, and `Enter` commits selection. - Closing Select preserves the Dialog and returns focus to the combobox; the next `Escape` closes the Dialog and focuses Open dialog. Focus remains contained while the modal Dialog is open. ### Open Dialog from Menu ```text Build a Document actions Menu with a Rename document item that opens a labelled Dialog. The Dialog contains a Document name input and Cancel/Save actions. Use the documented composition and handle API, and preserve Dialog focus while the Menu exits. Compile the Angular template and verify keyboard activation and focus return. ``` Reference: [Menu — Opening a dialog from an item](components/menu.md), bundled source `references/examples/menu--open-dialog.md`. Success criteria: - Public Menu/Dialog imports, `rdxMenuItem` + `rdxDialogTrigger` composition and handle bindings compile. - `Enter` opens Menu and activates Rename document. The Menu closes and the Dialog's input receives focus without the Menu's exit restoring focus underneath it. - The Dialog has a title, description and labelled input. `Tab` stays within the modal Dialog. - `Escape` or Cancel closes the Dialog and returns focus to Document actions. ### Tabs wrapper using hostDirectives ```text Build a standalone Tabs wrapper with RdxTabsRoot composed through hostDirectives. Keep its list in the wrapper view and project three consumer tabs and their panels. Preserve Root DI ownership, active state and keyboard navigation without reimplementing Tabs. Compile the projected consumer template and verify Arrow, Home, End and activation keys. ``` Reference: [Tabs — Projected through wrapper](components/tabs.md), bundled source `references/examples/tabs--projected-through-a-wrapper.md`. Success criteria: - Public Tabs imports and `hostDirectives` metadata compile, including the consuming template. - Projected tabs resolve the host's Root and the inner List without missing-context errors. - Tabs and panels have linked roles and names; exactly one tab is selected and tabbable. - Arrow keys, `Home` and `End` move focus; activation follows the documented mode, and the corresponding panel becomes visible. `Tab` can leave the tab list. ## Fixture checks versus generation runs In the Radix NG repository, `apps/radix-storybook/tsconfig.agents.json` checks these example templates with Angular, and `apps/visual-regression/tests/agents.behavior.spec.ts` exercises the four fixtures through the existing Playwright setup. They verify examples that an agent can consult. To evaluate generation, run the prompts in clean consumer projects with recorded library, bundle, Angular and agent/model versions. Preserve the exact prompt, generated diff, compiler output and browser results for each task. Report unassisted results separately from human fixes. A checked reference example does not count as a generation run. Agent Playground's experimental `snapshot` / `query` / `act` controls an existing application. Its runtime-integration tests exercise commands and state; they do not measure component generation. The runtime is separate from the consumer skills. --- # Accordion #### A vertically stacked set of interactive headings that each reveal an associated section of content. ```typescript import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { LucidePlus } from '@lucide/angular'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ host: { class: 'contents' }, changeDetection: ChangeDetectionStrategy.OnPush, selector: 'rdx-accordion-default-example', imports: [ RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelPresenceDirective, RdxAccordionPanelDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective, LucidePlus ], template: `
@for (item of items; track item.id) {

{{ item.answer }}
}
` }) export class AccordionDefaultStory { readonly disabled = input(false); readonly multiple = input(false); protected readonly items = [ { id: 'about', question: 'What is Radix NG?', answer: 'Radix NG provides unstyled Angular primitives for design systems and web apps.' }, { id: 'start', question: 'How do I get started?', answer: 'Install the primitives and compose them using standalone Angular imports.' }, { id: 'license', question: 'Can I use it for my project?', answer: 'Yes. Radix NG is free and open source.' } ]; } ``` ## Features - ✅ Native button keyboard interaction (`Space` / `Enter`) with browser tab order. - ✅ Base UI state hooks: `data-open` / `data-panel-open` plus enter/leave `data-starting-style` / `data-ending-style`. - ✅ Exposes horizontal/vertical orientation state for styling. - ✅ Expand a single item or multiple items at once (`multiple`). - ✅ Can be controlled or uncontrolled. - ✅ Cancelable `onValueChange` (root) and `onOpenChange` (item) events carry an `eventDetails` payload. - ✅ Exposes the panel size as `--accordion-panel-height` / `--accordion-panel-width` for animations. - ✅ Keep collapsed panels mounted (`keepMounted`) or findable by browser search (`hiddenUntilFound`). ## Import Get started with importing the directives: ```typescript import { RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective } from '@radix-ng/primitives/accordion'; ``` ## Anatomy ```html
``` ## Examples Example setup ### Default The preview above uses this standalone component. Copy the setup and shared files below as well. ```typescript import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { LucidePlus } from '@lucide/angular'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ host: { class: 'contents' }, changeDetection: ChangeDetectionStrategy.OnPush, selector: 'rdx-accordion-default-example', imports: [ RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelPresenceDirective, RdxAccordionPanelDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective, LucidePlus ], template: `
@for (item of items; track item.id) {

{{ item.answer }}
}
` }) export class AccordionDefaultStory { readonly disabled = input(false); readonly multiple = input(false); protected readonly items = [ { id: 'about', question: 'What is Radix NG?', answer: 'Radix NG provides unstyled Angular primitives for design systems and web apps.' }, { id: 'start', question: 'How do I get started?', answer: 'Install the primitives and compose them using standalone Angular imports.' }, { id: 'license', question: 'Can I use it for my project?', answer: 'Yes. Radix NG is free and open source.' } ]; } ``` ### Disabled Disable the whole accordion via `disabled` on the root, or a single item via `disabled` on the item. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'accordion-disabled-example', imports: [ RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `

Yes. It adheres to the WAI-ARIA design pattern.

Yes. It's unstyled by default, giving you freedom over the look and feel.

Yes! You can animate the Accordion with CSS or JavaScript.
` }) export class AccordionDisabledExample {} ``` ### Multiple Set `multiple` to let several items stay open at once. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { LucidePlus } from '@lucide/angular'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'accordion-multiple-example', imports: [ LucidePlus, RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `

Yes. It adheres to the WAI-ARIA design pattern.

Yes. It's unstyled by default, giving you freedom over the look and feel.

Yes. It's unstyled by default, giving you freedom over the look and feel.
` }) export class AccordionMultipleExample {} ``` ### Collapsible In single mode the open item can always be closed by clicking its trigger again (Base UI parity — there is no separate `collapsible` input). ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'accordion-collapsible-example', imports: [ RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `

Yes. It adheres to the WAI-ARIA design pattern.

Yes. It's unstyled by default, giving you freedom over the look and feel.

Yes! You can animate the Accordion with CSS or JavaScript.
` }) export class AccordionCollapsibleExample {} ``` ### Horizontal Set `orientation="horizontal"` to expose horizontal state for styling. Following the APG guidance update adopted by Base UI, orientation no longer changes keyboard focus behavior. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'accordion-horizontal-example', imports: [ RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `
Yes. It adheres to the WAI-ARIA design pattern.
Yes. It's unstyled by default, giving you freedom over the look and feel.
Yes! You can animate the Accordion with CSS or JavaScript.
` }) export class AccordionHorizontalExample {} ``` ### Events An interaction first emits Item `onOpenChange` with `{ open, eventDetails }`, then Root `onValueChange` with `{ value, eventDetails }`, using the same event details. Either handler can cancel before commit. Changes to the controlled value and single-mode sibling closure do not emit Item requests. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'accordion-events-example', imports: [ RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `

Yes. It adheres to the WAI-ARIA design pattern.

Yes. It's unstyled by default.

Last event: {{ status() }}

` }) export class AccordionEventsExample { readonly status = signal('—'); log(title: string, event: { open: boolean }): void { this.status.set(`${title} ${event.open ? 'opened' : 'closed'}`); } } ``` ### Controlled Use `[(value)]` to accept array requests. Cancel a request in `onValueChange` to keep the current selection. ```typescript import { Component, signal } from '@angular/core'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective, RdxAccordionValueChangeEvent } from '@radix-ng/primitives/accordion'; @Component({ selector: 'accordion-controlled-example', imports: [ RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `
@for (item of items; track item) {

Content for {{ item }}.
}

Selected: {{ selected().join(', ') }}

Requests: {{ requests() }}

` }) export class AccordionControlledExample { readonly items = ['First', 'Second']; readonly selected = signal(['First']); readonly blocked = signal(false); readonly requests = signal(0); request(event: RdxAccordionValueChangeEvent) { this.requests.update((count) => count + 1); if (this.blocked()) event.eventDetails.cancel(); } } ``` ### Motion and dynamic content Use the height variable with `data-starting-style` and `data-ending-style` for CSS transitions. During motion it contains a measured scroll size. After motion it returns to `auto`, so the panel follows later content changes. Closing measures the current expanded content before applying exit styles. ```typescript import { Component, signal } from '@angular/core'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ selector: 'accordion-motion-example', imports: [ RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `
@for (item of ['Details', 'Another item']; track item) {

The panel follows content changes after opening.

}
` }) export class AccordionMotionExample { readonly tall = signal(false); } ``` ### Panel lifetime Apply `*rdxAccordionPanelPresence` to each Panel host. Closed Panels create no Angular children by default. Closing destroys the complete view after exit motion; reopening creates fresh children and native form state. Retained Panels preserve that state. ```typescript import { Component } from '@angular/core'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; @Component({ selector: 'accordion-panel-lifetime-example', imports: [ RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `

Edit each field, then close and reopen its panel to compare state retention.

@for (retained of [false, true]; track retained) {

}
` }) export class AccordionPanelLifetimeExample {} ``` ### Keep mounted With `keepMounted`, collapsed panels keep their element in the DOM while hidden — useful to preserve form state. Use `hiddenUntilFound` instead to keep collapsed content discoverable by the browser's find-in-page (it renders `hidden="until-found"`). ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { RdxAccordionHeaderDirective, RdxAccordionItemDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective, RdxAccordionRootDirective, RdxAccordionTriggerDirective } from '@radix-ng/primitives/accordion'; /** * With `keepMounted`, collapsed panels keep their element in the DOM while hidden. * Type something below, collapse the panel, and reopen it — the value is retained. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'accordion-keep-mounted-example', imports: [ FormsModule, RdxAccordionRootDirective, RdxAccordionItemDirective, RdxAccordionHeaderDirective, RdxAccordionTriggerDirective, RdxAccordionPanelDirective, RdxAccordionPanelPresenceDirective ], template: `

Same as shipping.
` }) export class AccordionKeepMountedExample { address = ''; } ``` ## API Reference ### Root `RdxAccordionRootDirective` — groups all parts and owns the expanded value. Apply to a container element (typically a `
`). `value`, `defaultValue`, and event values are arrays in both modes, for example `[defaultValue]="['one']"`. A supplied `value` (including `[]`) owns selection; use `[(value)]` to accept requests automatically, or update `[value]` in a request handler. Without `value`, Root snapshots `defaultValue` once. Later default changes do not reset selection. **Data attributes** | Attribute | Present when | | ------------------ | ------------------------------------------- | | `data-orientation` | Always — `"horizontal"` \| `"vertical"`. | | `data-disabled` | The accordion is disabled. | ### Item `RdxAccordionItemDirective` — groups a header with its panel. Apply to a container element (typically a `
`). Item values use reference/value identity and can be objects, functions or arrays. An array item remains a single value. Omitted or nullish values receive a stable generated identity. **Data attributes** | Attribute | Present when | | --------------- | --------------------------------------- | | `data-open` | The item is open. | | `data-closed` | The item is closed. | | `data-hidden` | The item is closed and its exit has finished. | | `data-orientation` | Always — `"horizontal"` \| `"vertical"`. | | `data-disabled` | The item is disabled. | | `data-index` | Always — the item's zero-based index. | ### Header `RdxAccordionHeaderDirective` — the heading that labels the panel. Reads everything from context, so it takes no inputs. Apply to a heading element (typically an `

`). **Data attributes** | Attribute | Present when | | --------------- | --------------------------------------- | | `data-open` | The item is open. | | `data-closed` | The item is closed. | | `data-hidden` | The item is closed and its exit has finished. | | `data-orientation` | Always — `"horizontal"` \| `"vertical"`. | | `data-disabled` | The item is disabled. | | `data-index` | Always — the item's zero-based index. | ### Trigger `RdxAccordionTriggerDirective` — the button that toggles the panel. Apply to a native `

Are you absolutely sure?

This action cannot be undone. This will permanently delete your account and remove your data from our servers.

` }) export class RdxAlertDialogDefaultComponent {} ``` ## Features - ✅ Always modal: document scrolling is locked and outside pointer events are disabled. - ✅ Does not close on outside interaction — requires an explicit choice; Escape still closes. - ✅ Renders the popup with `role="alertdialog"` for assertive screen-reader semantics. - ✅ Supports uncontrolled state, `defaultOpen`, and Angular two-way binding with `[(open)]`. - ✅ Supports multiple triggers, controlled `triggerId`, and detached triggers through a shared handle. - ✅ Traps and restores focus; links the popup to title and description for accessible labeling. ## Import ```typescript import { alertDialogImports, createRdxAlertDialogHandle, RdxAlertDialogBackdrop, RdxAlertDialogClose, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle, RdxAlertDialogTrigger } from '@radix-ng/primitives/alert-dialog'; ``` Or import all parts through the module: ```typescript import { RdxAlertDialogModule } from '@radix-ng/primitives/alert-dialog'; ``` ## Anatomy ```html

Are you sure?

This action cannot be undone.

``` ## Examples Example setup ### Default A destructive confirmation with Cancel and an action button. Clicking the backdrop keeps it open. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAlertDialogBackdrop, RdxAlertDialogClose, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle, RdxAlertDialogTrigger } from '@radix-ng/primitives/alert-dialog'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-alert-dialog-default', imports: [ RdxAlertDialogRoot, RdxAlertDialogTrigger, RdxAlertDialogPortal, RdxAlertDialogBackdrop, RdxAlertDialogPopup, RdxAlertDialogTitle, RdxAlertDialogDescription, RdxAlertDialogClose ], template: `

Are you absolutely sure?

This action cannot be undone. This will permanently delete your account and remove your data from our servers.

` }) export class RdxAlertDialogDefaultComponent {} ``` ### Controlled Bind `[(open)]` to open or close the alert dialog from component state. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAlertDialogBackdrop, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle, RdxAlertDialogTrigger } from '@radix-ng/primitives/alert-dialog'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-alert-dialog-controlled', imports: [ RdxAlertDialogRoot, RdxAlertDialogTrigger, RdxAlertDialogPortal, RdxAlertDialogBackdrop, RdxAlertDialogPopup, RdxAlertDialogTitle, RdxAlertDialogDescription ], template: `

Alert dialog is {{ open() ? 'open' : 'closed' }}

Discard unsaved changes?

The open state is owned by the component and bound with [(open)] .

` }) export class RdxAlertDialogControlledComponent { protected readonly open = signal(false); } ``` ### Multiple triggers Several triggers can open the same alert dialog. The active trigger's `payload` is exposed on the root so the content can adapt to what is being confirmed. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAlertDialogBackdrop, RdxAlertDialogClose, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle, RdxAlertDialogTrigger } from '@radix-ng/primitives/alert-dialog'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-alert-dialog-multiple-triggers', imports: [ RdxAlertDialogRoot, RdxAlertDialogTrigger, RdxAlertDialogPortal, RdxAlertDialogBackdrop, RdxAlertDialogPopup, RdxAlertDialogTitle, RdxAlertDialogDescription, RdxAlertDialogClose ], template: `

Delete this {{ root.payload() || 'item' }}?

Every trigger opens the same alert dialog; the active trigger's payload decides what is being deleted.

` }) export class RdxAlertDialogMultipleTriggersComponent {} ``` ### Controlled mode with multiple triggers Bind both `[(open)]` and `[(triggerId)]` to choose which trigger is active from component state. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAlertDialogBackdrop, RdxAlertDialogClose, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle, RdxAlertDialogTrigger } from '@radix-ng/primitives/alert-dialog'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-alert-dialog-controlled-multiple', imports: [ RdxAlertDialogRoot, RdxAlertDialogTrigger, RdxAlertDialogPortal, RdxAlertDialogBackdrop, RdxAlertDialogPopup, RdxAlertDialogTitle, RdxAlertDialogDescription, RdxAlertDialogClose ], template: `

open: {{ open() }} · triggerId: {{ triggerId() ?? '—' }}

{{ triggerId() === 'delete' ? 'Delete account?' : 'Log out?' }}

Both open and triggerId are bound, so the active action is driven from component state.

` }) export class RdxAlertDialogControlledMultipleComponent { protected readonly open = signal(false); protected readonly triggerId = signal(null); protected confirmDelete() { this.triggerId.set('delete'); this.open.set(true); } } ``` ### Detached triggers Connect a trigger rendered outside the root with `createRdxAlertDialogHandle()`; the handle also exposes imperative `open(id)` / `close()`. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAlertDialogBackdrop, RdxAlertDialogClose, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle, RdxAlertDialogTrigger, createRdxAlertDialogHandle } from '@radix-ng/primitives/alert-dialog'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-alert-dialog-detached', imports: [ RdxAlertDialogRoot, RdxAlertDialogTrigger, RdxAlertDialogPortal, RdxAlertDialogBackdrop, RdxAlertDialogPopup, RdxAlertDialogTitle, RdxAlertDialogDescription, RdxAlertDialogClose ], template: `

Delete this file?

The trigger and this alert dialog are connected with createRdxAlertDialogHandle() .

` }) export class RdxAlertDialogDetachedComponent { protected readonly handle = createRdxAlertDialogHandle(); } ``` ### Close confirmation A regular Dialog editor asks an Alert Dialog to confirm before discarding unsaved changes — the classic reason to reach for an alert dialog. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { RdxAlertDialogBackdrop, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle } from '@radix-ng/primitives/alert-dialog'; import { RdxDialogBackdrop, RdxDialogDescription, RdxDialogOpenChange, RdxDialogPopup, RdxDialogPortal, RdxDialogRoot, RdxDialogTitle, RdxDialogTrigger } from '@radix-ng/primitives/dialog'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-alert-dialog-close-confirmation', imports: [ RdxDialogRoot, RdxDialogTrigger, RdxDialogPortal, RdxDialogBackdrop, RdxDialogPopup, RdxDialogTitle, RdxDialogDescription, RdxAlertDialogRoot, RdxAlertDialogPortal, RdxAlertDialogBackdrop, RdxAlertDialogPopup, RdxAlertDialogTitle, RdxAlertDialogDescription, FormsModule ], template: `

Edit note

Closing with unsaved changes asks an alert dialog to confirm.

Discard changes?

Your unsaved note will be lost.

` }) export class RdxAlertDialogCloseConfirmationComponent { protected readonly editorOpen = signal(false); protected readonly confirmOpen = signal(false); protected text = ''; private get hasChanges() { return this.text.trim().length > 0; } protected onEditorOpenChange(change: RdxDialogOpenChange) { // Re-open the editor and ask for confirmation when there are unsaved changes. if (!change.open && this.hasChanges) { this.editorOpen.set(true); this.confirmOpen.set(true); } } protected requestClose() { if (this.hasChanges) { this.confirmOpen.set(true); } else { this.editorOpen.set(false); } } protected save() { this.text = ''; this.editorOpen.set(false); } protected discard() { this.text = ''; this.confirmOpen.set(false); this.editorOpen.set(false); } } ``` ### Open from a menu Control the alert dialog's `open` state from a menu item to launch a destructive confirmation from a `Menu`. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAlertDialogBackdrop, RdxAlertDialogClose, RdxAlertDialogDescription, RdxAlertDialogPopup, RdxAlertDialogPortal, RdxAlertDialogRoot, RdxAlertDialogTitle } from '@radix-ng/primitives/alert-dialog'; import { RdxMenuItem, RdxMenuPopup, RdxMenuPositioner, RdxMenuRoot, RdxMenuSeparator, RdxMenuTrigger } from '@radix-ng/primitives/menu'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-alert-dialog-from-menu', imports: [ RdxAlertDialogRoot, RdxAlertDialogPortal, RdxAlertDialogBackdrop, RdxAlertDialogPopup, RdxAlertDialogTitle, RdxAlertDialogDescription, RdxAlertDialogClose, RdxMenuRoot, RdxMenuTrigger, RdxMenuPositioner, RdxMenuPopup, RdxMenuItem, RdxMenuSeparator ], template: ` @if (menu.open()) {
}

Delete project?

This permanently deletes the project. Opened by controlling the alert dialog from a menu item.

` }) export class RdxAlertDialogFromMenuComponent { protected readonly deleteOpen = signal(false); } ``` ## API Reference ### Root `RdxAlertDialogRoot` composes the Dialog root and forces alert semantics (always modal, no pointer dismissal, `role="alertdialog"`). It forwards the Dialog root's state API — `[(open)]`, `[(triggerId)]`, `defaultOpen`, `defaultTriggerId`, and `handle`, plus the `onOpenChange` and `onOpenChangeComplete` outputs — but not `modal` or `disablePointerDismissal`, which are fixed for the alert variant. See the Dialog reference for their types and defaults. ### Trigger `RdxAlertDialogTrigger` opens the alert dialog; it behaves like the dialog trigger and forwards its inputs: `handle`, `payload`, `id`, and `disabled`. See the Dialog reference for their types and defaults. ### Portal, Backdrop, Popup, Title, Description, Close, Viewport These are thin wrappers around the matching dialog parts and read their behavior from context. See the Dialog docs for their full reference. Portal exposes `[keepMounted]` to retain the closed view. The exported Root exposes `unmount()` to finish a manually held close. ## Data attributes Alert Dialog composes the corresponding Dialog parts. These hooks are inherited on their hosts. | Attribute | Parts | Present when | | ------------------------- | ------------------------- | --------------------------------------------- | | `data-popup-open` | Trigger | The alert dialog is open. | | `data-open` | Popup, Backdrop, Viewport | The alert dialog is open. | | `data-closed` | Popup, Backdrop, Viewport | The alert dialog is closed. | | `data-starting-style` | Popup, Backdrop, Viewport | The enter transition is starting. | | `data-ending-style` | Popup, Backdrop, Viewport | The exit transition is running. | | `data-nested` | Popup, Backdrop, Viewport | The alert dialog is nested in another dialog. | | `data-nested-dialog-open` | Popup, Backdrop, Viewport | A descendant dialog is open. | ## Accessibility ### Keyboard Interactions | Key | Description | | ----------------- | ----------------------------------------------------------------------------------------- | | `Enter` / `Space` | Opens the alert dialog when focus is on the trigger; activates the focused action button. | | `Escape` | Closes the alert dialog. Only the topmost dialog closes when dialogs are nested. | | `Tab` | Moves focus to the next focusable element; focus is trapped within the popup. | | `Shift` + `Tab` | Moves focus to the previous focusable element inside the popup. | --- # Aspect Ratio #### Displays content within a desired ratio. ```html
${IMG_ALT}
``` --- # Autocomplete #### A text input with a list of suggestions: free-form text whose value **is** the input string, with the active option tracked via `aria-activedescendant`. Autocomplete is headless — it ships no styles and exposes state via `data-*` attributes. It is built on the same engine as [Combobox](components/combobox.md), configured for a single, free-form string value: typing, picking a suggestion, or clearing all change one string. DOM focus stays in the `` at all times; the active option is virtual (`data-highlighted` + `aria-activedescendant`). Use Autocomplete for free-form entry with suggestions (search boxes, command inputs); use Combobox when the value is a chosen item (or items) rather than the typed text. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; const TAGS = [ 'feature', 'fix', 'bug', 'docs', 'internal', 'mobile', 'component: accordion', 'component: alert dialog', 'component: autocomplete', 'component: avatar', 'component: checkbox', 'component: checkbox group', 'component: collapsible', 'component: combobox', 'component: context menu', 'component: dialog', 'component: field', 'component: fieldset', 'component: filterable menu', 'component: form', 'component: input', 'component: menu', 'component: menubar', 'component: meter', 'component: navigation menu', 'component: number field', 'component: popover', 'component: preview card', 'component: progress', 'component: radio', 'component: scroll area', 'component: select', 'component: separator', 'component: slider', 'component: switch', 'component: tabs', 'component: toast', 'component: toggle', 'component: toggle group', 'component: toolbar', 'component: tooltip' ]; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-default', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
@for (tag of tags; track tag) {
{{ tag }}
}
No tags found.
` }) export class AutocompleteDefault { readonly value = signal(''); readonly tags = TAGS; } ``` ## Features - ✅ The value **is** the input string — `[(value)]`, `defaultValue`, and `onValueChange` (with a `reason`: `input-change` / `item-press` / `input-clear`). - ✅ Four `mode`s: `list` (filter), `both` (filter + inline complete), `inline` (static + inline complete), `none` (static). - ✅ Inline autocompletion: keyboard highlighting displays the active item's full label without committing it. - ✅ Built-in locale-aware filtering, a custom `filter` function, or `[filter]="null"` for external/async lists. - ✅ `autoHighlight`: `true` (first match while typing) or `'always'` (keep first highlighted). - ✅ Hover behavior: `highlightItemOnHover` (default `true`) and `keepHighlight` (keep the highlight when the pointer leaves the list). - ✅ Keyboard navigation: ArrowDown / ArrowUp, RTL grids, Home / End, Enter, Space, Escape and Tab. - ✅ Grid layout (`grid` + `rdxAutocompleteRow`) with 2D arrow navigation (Up/Down by row, Left/Right within a row). - ✅ Inline list (command palette): render `List` directly without `Portal` / `Positioner` / `Popup` for an always-open list. - ✅ WAI-ARIA `combobox` / `listbox` semantics with `aria-activedescendant` (focus never leaves the input). - ✅ Optional `modal` mode: locks page scroll and makes outside content inert, with a `Backdrop` part. - ✅ `onOpenChange` is cancellable and emits `{ open, reason, event, trigger, eventDetails }`; controlled autocomplete can inspect or reject close/open requests. - ✅ `limit` caps how many matches show; arrow-key navigation never fights a resting mouse cursor. - ✅ External virtualization: `virtualized` + `[items]` drives index navigation and exposes `filteredItems()`. - ✅ Forms: `ControlValueAccessor` on the root (value = input string), Field integration, and native `name` / `form` serialization through the visible input. - ✅ Headless — state via `data-popup-open`, `data-list-empty`, `data-highlighted`, `data-disabled` (no `data-selected` — autocomplete does not commit a selection). ## Import ```typescript import { RdxAutocompleteAnchor, RdxAutocompleteArrow, RdxAutocompleteBackdrop, RdxAutocompleteClear, RdxAutocompleteEmpty, RdxAutocompleteGroup, RdxAutocompleteGroupLabel, RdxAutocompleteIcon, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteItemIndicator, RdxAutocompleteLabel, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot, RdxAutocompleteRow, RdxAutocompleteStatus, RdxAutocompleteTrigger, RdxAutocompleteValue } from '@radix-ng/primitives/autocomplete'; ``` ## Anatomy The input is the popper anchor and keeps focus; suggestions live in a portalled popup and are filtered in place (non-matching items are hidden, not destroyed). ```html
``` ## Examples Example setup ### Default Type to filter a list of suggestions; pick one to fill the input. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; const TAGS = [ 'feature', 'fix', 'bug', 'docs', 'internal', 'mobile', 'component: accordion', 'component: alert dialog', 'component: autocomplete', 'component: avatar', 'component: checkbox', 'component: checkbox group', 'component: collapsible', 'component: combobox', 'component: context menu', 'component: dialog', 'component: field', 'component: fieldset', 'component: filterable menu', 'component: form', 'component: input', 'component: menu', 'component: menubar', 'component: meter', 'component: navigation menu', 'component: number field', 'component: popover', 'component: preview card', 'component: progress', 'component: radio', 'component: scroll area', 'component: select', 'component: separator', 'component: slider', 'component: switch', 'component: tabs', 'component: toast', 'component: toggle', 'component: toggle group', 'component: toolbar', 'component: tooltip' ]; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-default', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
@for (tag of tags; track tag) {
{{ tag }}
}
No tags found.
` }) export class AutocompleteDefault { readonly value = signal(''); readonly tags = TAGS; } ``` ### Inline autocompletion With `mode="both"` (filter + inline), keyboard highlighting displays the item's full label. The committed `value` stays unchanged until an edit or selection, and filtering uses its trimmed text. `mode="inline"` keeps the list unfiltered. Inline modes use the same `autoHighlight` default (`false`) as other modes. The preview preserves native caret behavior; it does not select a completed suffix. Pointer highlighting leaves an existing preview in place. `rdxAutocompleteValue.slotText()` reflects the displayed text, including a temporary preview. Closing the popup, changing the value or disabling completion clears it. With `autoHighlight`, an uncontrolled input can preview the first result during typing. A controlled `[(value)]` input keeps the accepted edit visible; subsequent keyboard navigation displays the highlighted label. External value changes preserve the supplied text, including surrounding spaces. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; const TAGS = [ 'feature', 'fix', 'bug', 'docs', 'internal', 'mobile', 'component: accordion', 'component: alert dialog', 'component: autocomplete', 'component: avatar', 'component: checkbox', 'component: checkbox group', 'component: collapsible', 'component: combobox', 'component: context menu', 'component: dialog', 'component: field', 'component: fieldset', 'component: filterable menu', 'component: form', 'component: input', 'component: menu', 'component: menubar', 'component: meter', 'component: navigation menu', 'component: number field', 'component: popover', 'component: preview card', 'component: progress', 'component: radio', 'component: scroll area', 'component: select', 'component: separator', 'component: slider', 'component: switch', 'component: tabs', 'component: toast', 'component: toggle', 'component: toggle group', 'component: toolbar', 'component: tooltip' ]; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-inline', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
@for (tag of tags; track tag) {
{{ tag }}
}
No tags found.
` }) export class AutocompleteInline { readonly value = signal(''); readonly tags = TAGS; } ``` ### Auto highlight `autoHighlight` keeps the first match highlighted as you type, so Enter selects it immediately. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; const TAGS = [ 'feature', 'fix', 'bug', 'docs', 'internal', 'mobile', 'component: accordion', 'component: alert dialog', 'component: autocomplete', 'component: avatar', 'component: checkbox', 'component: checkbox group', 'component: collapsible', 'component: combobox', 'component: context menu', 'component: dialog', 'component: field', 'component: fieldset', 'component: filterable menu', 'component: form', 'component: input', 'component: menu', 'component: menubar', 'component: meter', 'component: navigation menu', 'component: number field', 'component: popover', 'component: preview card', 'component: progress', 'component: radio', 'component: scroll area', 'component: select', 'component: separator', 'component: slider', 'component: switch', 'component: tabs', 'component: toast', 'component: toggle', 'component: toggle group', 'component: toolbar', 'component: tooltip' ]; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-auto-highlight', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
@for (tag of tags; track tag) {
{{ tag }}
}
No tags found.
` }) export class AutocompleteAutoHighlight { readonly value = signal(''); readonly tags = TAGS; } ``` ### Grouped Group related suggestions with `rdxAutocompleteGroup` / `rdxAutocompleteGroupLabel`; an empty group hides its heading automatically. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteGroup, RdxAutocompleteGroupLabel, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; interface Group { label: string; items: string[]; } @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-grouped', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteGroup, RdxAutocompleteGroupLabel, RdxAutocompleteEmpty ], template: `
@for (group of groups; track group.label) {
{{ group.label }}
@for (item of group.items; track item) {
{{ item }}
}
}
No tags found.
` }) export class AutocompleteGrouped { readonly value = signal(''); readonly groups: Group[] = [ { label: 'Type', items: ['feature', 'fix', 'bug', 'docs', 'internal', 'mobile'] }, { label: 'Component', items: [ 'component: accordion', 'component: alert dialog', 'component: autocomplete', 'component: avatar', 'component: checkbox', 'component: checkbox group', 'component: collapsible', 'component: combobox', 'component: context menu', 'component: dialog', 'component: field', 'component: fieldset', 'component: filterable menu', 'component: form', 'component: input', 'component: menu', 'component: menubar', 'component: meter', 'component: navigation menu', 'component: number field', 'component: popover', 'component: preview card', 'component: progress', 'component: radio', 'component: scroll area', 'component: select', 'component: separator', 'component: slider', 'component: switch', 'component: tabs', 'component: toast', 'component: toggle', 'component: toggle group', 'component: toolbar', 'component: tooltip' ] } ]; } ``` ### Limit `limit` caps how many matches are shown at once. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-limit', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
@for (tag of tags; track tag) {
{{ tag }}
}
No tags found.
@if (hiddenCount(ac.value()); as hidden) {
{{ hidden }} more {{ hidden === 1 ? 'result' : 'results' }} not shown
}
` }) export class AutocompleteLimit { readonly value = signal(''); /** How many matches are hidden by the `limit` of 8, for the "N more results" hint. */ hiddenCount(query: string): number { const q = query.trim().toLowerCase(); const matches = q ? this.tags.filter((tag) => tag.toLowerCase().includes(q)).length : this.tags.length; return Math.max(0, matches - 8); } // Larger dataset (15 type tags + 35 component tags) so the `limit` of 8 is visible. readonly tags = [ 'feature', 'fix', 'bug', 'docs', 'internal', 'mobile', 'frontend', 'backend', 'performance', 'accessibility', 'design', 'research', 'testing', 'infrastructure', 'documentation', 'component: accordion', 'component: alert dialog', 'component: autocomplete', 'component: avatar', 'component: checkbox', 'component: checkbox group', 'component: collapsible', 'component: combobox', 'component: context menu', 'component: dialog', 'component: field', 'component: fieldset', 'component: filterable menu', 'component: form', 'component: input', 'component: menu', 'component: menubar', 'component: meter', 'component: navigation menu', 'component: number field', 'component: popover', 'component: preview card', 'component: progress', 'component: radio', 'component: scroll area', 'component: select', 'component: separator', 'component: slider', 'component: switch', 'component: tabs', 'component: toast', 'component: toggle', 'component: toggle group', 'component: toolbar', 'component: tooltip' ]; } ``` ### Fuzzy matching A custom `filter` receives the item's text, the query, **and the item value** — so it can rank across multiple fields. This example uses `match-sorter` over `title` / `description` / `category` and highlights the matched text. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { AutocompleteFilter, RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; import { matchSorter, rankings } from 'match-sorter'; interface DocItem { title: string; description: string; category: string; } /** Fuzzy, multi-field ranking with `match-sorter`. The filter receives the item value (object). */ const fuzzyFilter: AutocompleteFilter = (value, query) => { if (!query) { return true; } const item = value as DocItem; return ( matchSorter([item], query, { keys: [ 'title', 'description', 'category', { key: 'title', threshold: rankings.CONTAINS }, { key: 'description', threshold: rankings.WORD_STARTS_WITH } ] }).length > 0 ); }; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-fuzzy', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
No results found for "{{ ac.value() }}".
@for (item of items; track item.title) {
}
` }) export class AutocompleteFuzzy { protected readonly fuzzy = fuzzyFilter; protected readonly markClass = 'text-match bg-transparent font-semibold'; readonly value = signal(''); readonly items: DocItem[] = [ { title: 'React Hooks Guide', description: 'Learn how to use React Hooks like useState, useEffect, and custom hooks', category: 'React' }, { title: 'JavaScript Array Methods', description: 'Master array methods like map, filter, reduce, and forEach in JavaScript', category: 'JavaScript' }, { title: 'CSS Flexbox Layout', description: 'Complete guide to CSS Flexbox for responsive web design', category: 'CSS' }, { title: 'TypeScript Interfaces', description: 'Understanding TypeScript interfaces and type definitions', category: 'TypeScript' }, { title: 'React Performance Optimization', description: 'Tips and techniques for optimizing React application performance', category: 'React' }, { title: 'HTML Semantic Elements', description: 'Using semantic HTML elements for better accessibility and SEO', category: 'HTML' }, { title: 'Node.js Express Server', description: 'Building RESTful APIs with Node.js and Express framework', category: 'Node.js' }, { title: 'Vue Composition API', description: 'Modern Vue.js development using the Composition API', category: 'Vue.js' }, { title: 'Angular Components', description: 'Creating reusable Angular components with TypeScript', category: 'Angular' }, { title: 'Python Django Framework', description: 'Web development with Python Django framework', category: 'Python' }, { title: 'CSS Grid Layout', description: 'Advanced CSS Grid techniques for complex layouts', category: 'CSS' }, { title: 'React Testing Library', description: 'Testing React components with React Testing Library', category: 'React' }, { title: 'MongoDB Queries', description: 'Advanced MongoDB queries and aggregation pipelines', category: 'Database' }, { title: 'Webpack Configuration', description: 'Optimizing webpack configuration for production builds', category: 'Build Tools' }, { title: 'SASS/SCSS Guide', description: 'Writing maintainable CSS with SASS and SCSS', category: 'CSS' } ]; /** * Wraps the query matches in `text` with ``, returning an HTML string. Built with `join('')` * (no template whitespace between segments) and bound via `[innerHTML]` so adjacent matched/unmatched * runs render contiguously — a `` interpolated in the template would gain stray spaces around it. * Segments are HTML-escaped; `` survives Angular's default sanitizer, so no bypass is needed. */ highlight(text: string, query: string): string { const esc = (s: string) => s.replace(/&/g, '&').replace(//g, '>'); const trimmed = query.trim(); if (!trimmed) { return esc(text); } const escaped = trimmed.slice(0, 100).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const regex = new RegExp(`(${escaped})`, 'gi'); const lower = trimmed.toLowerCase(); return text .split(regex) .filter((part) => part !== '') .map((part) => part.toLowerCase() === lower ? `${esc(part)}` : esc(part) ) .join(''); } } ``` ### Localization Set `locale` to make the default `contains` filter compare strings with that locale's collation rules. Under Turkish, the lowercase query `i` matches the dotted `İ` but not the dotless `I`; changing `locale` re-filters the list immediately. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; /** Turkish cities that differ by the dotted/dotless `i`, so the collator's locale is observable. */ const CITIES = ['Ankara', 'Bursa', 'Isparta', 'Iğdır', 'İstanbul', 'İzmir', 'Mersin', 'Trabzon']; /** * The default `contains` filter is locale-aware. Type `i` and switch the locale: under Turkish, the * lowercase `i` matches the dotted `İ` (İstanbul, İzmir) but not the dotless `I` (Isparta, Iğdır); * under English it matches both. Switching re-filters live because the collator is rebuilt reactively. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-locale', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
Locale
@for (loc of locales; track loc.value) { }
@for (city of cities; track city) {
{{ city }}
}
No cities found.

Under Turkish, typing “i” keeps the dotted-İ cities (İzmir, İstanbul) and drops the dotless-I ones (Isparta, Iğdır). Switch to English to match both.

` }) export class AutocompleteLocale { readonly value = signal(''); readonly cities = CITIES; readonly locale = signal('tr'); readonly locales = [ { value: 'tr' as Intl.LocalesArgument, label: 'Turkish (tr)' }, { value: 'en' as Intl.LocalesArgument, label: 'English (en)' } ]; } ``` ### Async `[filter]="null"` hands filtering to you; a fake request searches the movie list (`will_error` simulates a failure) and `RdxAutocompleteStatus` announces loading, result counts, and errors. ```typescript import { ChangeDetectionStrategy, Component, computed, signal } from '@angular/core'; import { RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot, RdxAutocompleteStatus } from '@radix-ng/primitives/autocomplete'; interface Movie { id: string; title: string; year: number; } const top100Movies: Movie[] = [ { id: '1', title: 'The Shawshank Redemption', year: 1994 }, { id: '2', title: 'The Godfather', year: 1972 }, { id: '3', title: 'The Dark Knight', year: 2008 }, { id: '4', title: 'The Godfather Part II', year: 1974 }, { id: '5', title: '12 Angry Men', year: 1957 }, { id: '6', title: 'The Lord of the Rings: The Return of the King', year: 2003 }, { id: '7', title: "Schindler's List", year: 1993 }, { id: '8', title: 'Pulp Fiction', year: 1994 }, { id: '9', title: 'The Lord of the Rings: The Fellowship of the Ring', year: 2001 }, { id: '10', title: 'The Good, the Bad and the Ugly', year: 1966 }, { id: '11', title: 'Forrest Gump', year: 1994 }, { id: '12', title: 'The Lord of the Rings: The Two Towers', year: 2002 }, { id: '13', title: 'Fight Club', year: 1999 }, { id: '14', title: 'Inception', year: 2010 }, { id: '15', title: 'Star Wars: Episode V – The Empire Strikes Back', year: 1980 }, { id: '16', title: 'The Matrix', year: 1999 }, { id: '17', title: 'Goodfellas', year: 1990 }, { id: '18', title: 'Interstellar', year: 2014 }, { id: '19', title: "One Flew Over the Cuckoo's Nest", year: 1975 }, { id: '20', title: 'Se7en', year: 1995 }, { id: '21', title: "It's a Wonderful Life", year: 1946 }, { id: '22', title: 'The Silence of the Lambs', year: 1991 }, { id: '23', title: 'Seven Samurai', year: 1954 }, { id: '24', title: 'Saving Private Ryan', year: 1998 }, { id: '25', title: 'City of God', year: 2002 }, { id: '26', title: 'Life Is Beautiful', year: 1997 }, { id: '27', title: 'The Green Mile', year: 1999 }, { id: '28', title: 'Star Wars: Episode IV – A New Hope', year: 1977 }, { id: '29', title: 'Terminator 2: Judgment Day', year: 1991 }, { id: '30', title: 'Back to the Future', year: 1985 }, { id: '31', title: 'Spirited Away', year: 2001 }, { id: '32', title: 'The Pianist', year: 2002 }, { id: '33', title: 'Psycho', year: 1960 }, { id: '34', title: 'Parasite', year: 2019 }, { id: '35', title: 'Gladiator', year: 2000 }, { id: '36', title: 'Léon: The Professional', year: 1994 }, { id: '37', title: 'American History X', year: 1998 }, { id: '38', title: 'The Departed', year: 2006 }, { id: '39', title: 'Whiplash', year: 2014 }, { id: '40', title: 'The Prestige', year: 2006 }, { id: '41', title: 'Grave of the Fireflies', year: 1988 }, { id: '42', title: 'The Usual Suspects', year: 1995 }, { id: '43', title: 'Casablanca', year: 1942 }, { id: '44', title: 'Harakiri', year: 1962 }, { id: '45', title: 'The Lion King', year: 1994 }, { id: '46', title: 'The Intouchables', year: 2011 }, { id: '47', title: 'Modern Times', year: 1936 }, { id: '48', title: 'The Lives of Others', year: 2006 }, { id: '49', title: 'Once Upon a Time in the West', year: 1968 }, { id: '50', title: 'Rear Window', year: 1954 }, { id: '51', title: 'Alien', year: 1979 }, { id: '52', title: 'City Lights', year: 1931 }, { id: '53', title: 'The Shining', year: 1980 }, { id: '54', title: 'Cinema Paradiso', year: 1988 }, { id: '55', title: 'Avengers: Infinity War', year: 2018 }, { id: '56', title: 'Paths of Glory', year: 1957 }, { id: '57', title: 'Django Unchained', year: 2012 }, { id: '58', title: 'WALL·E', year: 2008 }, { id: '59', title: 'Sunset Boulevard', year: 1950 }, { id: '60', title: 'The Great Dictator', year: 1940 }, { id: '61', title: 'The Dark Knight Rises', year: 2012 }, { id: '62', title: 'Princess Mononoke', year: 1997 }, { id: '63', title: 'Witness for the Prosecution', year: 1957 }, { id: '64', title: 'Oldboy', year: 2003 }, { id: '65', title: 'Aliens', year: 1986 }, { id: '66', title: 'Once Upon a Time in America', year: 1984 }, { id: '67', title: 'Coco', year: 2017 }, { id: '68', title: 'Your Name.', year: 2016 }, { id: '69', title: 'American Beauty', year: 1999 }, { id: '70', title: 'Braveheart', year: 1995 }, { id: '71', title: 'Das Boot', year: 1981 }, { id: '72', title: '3 Idiots', year: 2009 }, { id: '73', title: 'Toy Story', year: 1995 }, { id: '74', title: 'Inglourious Basterds', year: 2009 }, { id: '75', title: 'High and Low', year: 1963 }, { id: '76', title: 'Amadeus', year: 1984 }, { id: '77', title: 'Good Will Hunting', year: 1997 }, { id: '78', title: 'Star Wars: Episode VI – Return of the Jedi', year: 1983 }, { id: '79', title: 'The Hunt', year: 2012 }, { id: '80', title: 'Capharnaüm', year: 2018 }, { id: '81', title: 'Reservoir Dogs', year: 1992 }, { id: '82', title: 'Eternal Sunshine of the Spotless Mind', year: 2004 }, { id: '83', title: 'Requiem for a Dream', year: 2000 }, { id: '84', title: 'Come and See', year: 1985 }, { id: '85', title: 'Ikiru', year: 1952 }, { id: '86', title: 'Vertigo', year: 1958 }, { id: '87', title: 'Lawrence of Arabia', year: 1962 }, { id: '88', title: 'Citizen Kane', year: 1941 }, { id: '89', title: 'Memento', year: 2000 }, { id: '90', title: 'North by Northwest', year: 1959 }, { id: '91', title: 'Star Wars: Episode III – Revenge of the Sith', year: 2005 }, { id: '92', title: '2001: A Space Odyssey', year: 1968 }, { id: '93', title: 'Amélie', year: 2001 }, { id: '94', title: "Singin' in the Rain", year: 1952 }, { id: '95', title: 'Apocalypse Now', year: 1979 }, { id: '96', title: 'Taxi Driver', year: 1976 }, { id: '97', title: 'Downfall', year: 2004 }, { id: '98', title: 'The Wolf of Wall Street', year: 2013 }, { id: '99', title: 'A Clockwork Orange', year: 1971 }, { id: '100', title: 'Double Indemnity', year: 1944 } ]; /** * Asynchronous, server-style search with `[filter]="null"`: the autocomplete does no matching of its * own and the result list starts **empty** — nothing is loaded until the user types. Each keystroke * fires a debounced fake request over `top100Movies` (by title or year); `will_error` simulates a * failure. The popup is hidden until there is a status to show, so pressing ArrowDown on an empty * input never reveals the whole catalogue. `RdxAutocompleteStatus` announces loading / counts / errors. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-async', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteStatus ], template: `
@if (loading()) { Searching… } @else { {{ status() }} }
@for (movie of results(); track movie.id) {
{{ movie.title }} {{ movie.year }}
}
` }) export class AutocompleteAsync { readonly value = signal(''); readonly results = signal([]); readonly loading = signal(false); readonly error = signal(null); /** Status text shown above the list; `null` keeps the popup hidden (empty, idle input). */ readonly status = computed(() => { if (this.loading()) { return 'Searching…'; } if (this.error()) { return this.error(); } if (this.value() === '') { return null; } if (this.results().length === 0) { return `Movie or year "${this.value()}" does not exist in the Top 100 IMDb movies`; } const count = this.results().length; return `${count} result${count === 1 ? '' : 's'} found`; }); private handle: ReturnType | undefined; private requestId = 0; /** Debounced "server" search. Empty query loads nothing; stale responses are ignored. */ search(query: string): void { clearTimeout(this.handle); this.error.set(null); if (query === '') { this.loading.set(false); this.results.set([]); return; } this.loading.set(true); const requestId = ++this.requestId; this.handle = setTimeout(() => { if (requestId !== this.requestId) { return; // superseded by a newer keystroke } if (query === 'will_error') { this.results.set([]); this.error.set('Failed to fetch movies. Please try again.'); } else { const q = query.trim().toLowerCase(); this.results.set( top100Movies.filter( (movie) => movie.title.toLowerCase().includes(q) || String(movie.year).includes(q) ) ); } this.loading.set(false); }, 350); } } ``` ### Command palette An always-open, inline autocomplete (no popup — the `List` is rendered directly) inside a `Dialog`. `autoHighlight="always"` keeps the first match highlighted; selecting a command closes the dialog (the autocomplete's `open` is shared with the dialog via `[(open)]`). ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteEmpty, RdxAutocompleteGroup, RdxAutocompleteGroupLabel, RdxAutocompleteInput, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; import { RdxDialogBackdrop, RdxDialogPopup, RdxDialogPortal, RdxDialogRoot, RdxDialogTrigger } from '@radix-ng/primitives/dialog'; interface Item { value: string; label: string; } interface Group { value: string; items: Item[]; } /** * Command palette: an always-open, inline autocomplete (no popup) inside a `Dialog`. `autoHighlight` * keeps the first match highlighted; selecting a command closes the dialog (the autocomplete sets * `open` to `false`, which is shared with the dialog via `[(open)]`). */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-command-palette', imports: [ RdxDialogRoot, RdxDialogTrigger, RdxDialogPortal, RdxDialogBackdrop, RdxDialogPopup, RdxAutocompleteRoot, RdxAutocompleteInput, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteGroup, RdxAutocompleteGroupLabel, RdxAutocompleteEmpty ], template: `
@for (group of groups; track group.value) {
{{ group.value }}
@for (item of group.items; track item.value) {
{{ item.label }} {{ group.value === 'Suggestions' ? 'Application' : 'Command' }}
}
}
No results found.
Activate Enter Actions Cmd K
` }) export class AutocompleteCommandPalette { readonly open = signal(false); readonly groups: Group[] = [ { value: 'Suggestions', items: [ { value: 'linear', label: 'Linear' }, { value: 'figma', label: 'Figma' }, { value: 'slack', label: 'Slack' }, { value: 'youtube', label: 'YouTube' }, { value: 'raycast', label: 'Raycast' }, { value: 'notion', label: 'Notion' }, { value: 'github', label: 'GitHub' }, { value: 'jira', label: 'Jira' }, { value: 'calendar', label: 'Google Calendar' }, { value: 'chrome', label: 'Google Chrome' }, { value: 'mail', label: 'Apple Mail' }, { value: 'terminal', label: 'Terminal' } ] }, { value: 'Commands', items: [ { value: 'clipboard-history', label: 'Clipboard History' }, { value: 'import-extension', label: 'Import Extension' }, { value: 'create-snippet', label: 'Create Snippet' }, { value: 'system-preferences', label: 'System Preferences' }, { value: 'window-management', label: 'Window Management' }, { value: 'toggle-dark-mode', label: 'Toggle Dark Mode' }, { value: 'new-window', label: 'New Window' }, { value: 'new-tab', label: 'New Tab' }, { value: 'search-docs', label: 'Search Documentation' }, { value: 'capture-screen', label: 'Capture Screenshot' }, { value: 'close-sidebar', label: 'Toggle Sidebar' }, { value: 'toggle-terminal', label: 'Toggle Integrated Terminal' }, { value: 'run-script', label: 'Run Script' } ] } ]; } ``` ### Grid An emoji picker: enable `grid` and wrap each row in `rdxAutocompleteRow` for two-dimensional arrow navigation. The search input lives **inside** the popup (opened by the trigger) and auto-focuses on open; pressing an item inserts it into the message field, and `onValueChange` is ignored when `reason === 'item-press'` so the search box is not overwritten. ```typescript import { ChangeDetectionStrategy, Component, ElementRef, signal, viewChild } from '@angular/core'; import { RdxAutocompleteAnchor, RdxAutocompleteEmpty, RdxAutocompleteGroup, RdxAutocompleteGroupLabel, RdxAutocompleteInput, RdxAutocompleteItem, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot, RdxAutocompleteRow, RdxAutocompleteTrigger, type AutocompleteValueChangeDetails } from '@radix-ng/primitives/autocomplete'; interface Emoji { emoji: string; name: string; } interface EmojiGroup { label: string; rows: Emoji[][]; } const COLUMNS = 5; function chunk(items: T[], size: number): T[][] { const result: T[][] = []; for (let i = 0; i < items.length; i += size) { result.push(items.slice(i, i + size)); } return result; } /** * Grid layout (an emoji picker). `grid` enables two-dimensional arrow navigation — Up/Down by row * (keeping the column), Left/Right within a row. The search `Input` lives **inside** the `Popup` * (opened by the `Trigger`) and auto-focuses on open. Pressing an emoji inserts it into the message * field; the consumer cancels the `item-press` value request and closes the popup so the search query * is not replaced by the emoji name. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-grid', imports: [ RdxAutocompleteRoot, RdxAutocompleteAnchor, RdxAutocompleteInput, RdxAutocompleteTrigger, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteRow, RdxAutocompleteItem, RdxAutocompleteGroup, RdxAutocompleteGroupLabel, RdxAutocompleteEmpty ], template: `
@for (group of groups; track group.label) {
{{ group.label }}
@for (row of group.rows; track $index) {
@for (item of row; track item.emoji) {
{{ item.emoji }}
}
}
}
No emoji found.
` }) export class AutocompleteGrid { protected readonly message = viewChild>('message'); readonly search = signal(''); readonly open = signal(false); readonly groups: EmojiGroup[] = [ { label: 'Smileys & Emotion', rows: chunk( [ { emoji: '😀', name: 'grinning face' }, { emoji: '😃', name: 'grinning face with big eyes' }, { emoji: '😄', name: 'grinning face with smiling eyes' }, { emoji: '😁', name: 'beaming face with smiling eyes' }, { emoji: '😆', name: 'grinning squinting face' }, { emoji: '😅', name: 'grinning face with sweat' }, { emoji: '🤣', name: 'rolling on the floor laughing' }, { emoji: '😂', name: 'face with tears of joy' }, { emoji: '🙂', name: 'slightly smiling face' }, { emoji: '🙃', name: 'upside-down face' }, { emoji: '😉', name: 'winking face' }, { emoji: '😊', name: 'smiling face with smiling eyes' }, { emoji: '😇', name: 'smiling face with halo' }, { emoji: '🥰', name: 'smiling face with hearts' }, { emoji: '😍', name: 'smiling face with heart-eyes' }, { emoji: '🤩', name: 'star-struck' }, { emoji: '😘', name: 'face blowing a kiss' }, { emoji: '😗', name: 'kissing face' }, { emoji: '☺️', name: 'smiling face' }, { emoji: '😚', name: 'kissing face with closed eyes' }, { emoji: '😙', name: 'kissing face with smiling eyes' }, { emoji: '🥲', name: 'smiling face with tear' }, { emoji: '😋', name: 'face savoring food' }, { emoji: '😛', name: 'face with tongue' }, { emoji: '😜', name: 'winking face with tongue' }, { emoji: '🤪', name: 'zany face' }, { emoji: '😝', name: 'squinting face with tongue' }, { emoji: '🤑', name: 'money-mouth face' }, { emoji: '🤗', name: 'hugging face' }, { emoji: '🤭', name: 'face with hand over mouth' } ], COLUMNS ) }, { label: 'Animals & Nature', rows: chunk( [ { emoji: '🐶', name: 'dog face' }, { emoji: '🐱', name: 'cat face' }, { emoji: '🐭', name: 'mouse face' }, { emoji: '🐹', name: 'hamster' }, { emoji: '🐰', name: 'rabbit face' }, { emoji: '🦊', name: 'fox' }, { emoji: '🐻', name: 'bear' }, { emoji: '🐼', name: 'panda' }, { emoji: '🐨', name: 'koala' }, { emoji: '🐯', name: 'tiger face' }, { emoji: '🦁', name: 'lion' }, { emoji: '🐮', name: 'cow face' }, { emoji: '🐷', name: 'pig face' }, { emoji: '🐽', name: 'pig nose' }, { emoji: '🐸', name: 'frog' }, { emoji: '🐵', name: 'monkey face' }, { emoji: '🙈', name: 'see-no-evil monkey' }, { emoji: '🙉', name: 'hear-no-evil monkey' }, { emoji: '🙊', name: 'speak-no-evil monkey' }, { emoji: '🐒', name: 'monkey' }, { emoji: '🐔', name: 'chicken' }, { emoji: '🐧', name: 'penguin' }, { emoji: '🐦', name: 'bird' }, { emoji: '🐤', name: 'baby chick' }, { emoji: '🐣', name: 'hatching chick' }, { emoji: '🐥', name: 'front-facing baby chick' }, { emoji: '🦆', name: 'duck' }, { emoji: '🦅', name: 'eagle' }, { emoji: '🦉', name: 'owl' }, { emoji: '🦇', name: 'bat' } ], COLUMNS ) }, { label: 'Food & Drink', rows: chunk( [ { emoji: '🍎', name: 'red apple' }, { emoji: '🍏', name: 'green apple' }, { emoji: '🍊', name: 'tangerine' }, { emoji: '🍋', name: 'lemon' }, { emoji: '🍌', name: 'banana' }, { emoji: '🍉', name: 'watermelon' }, { emoji: '🍇', name: 'grapes' }, { emoji: '🍓', name: 'strawberry' }, { emoji: '🫐', name: 'blueberries' }, { emoji: '🍈', name: 'melon' }, { emoji: '🍒', name: 'cherries' }, { emoji: '🍑', name: 'peach' }, { emoji: '🥭', name: 'mango' }, { emoji: '🍍', name: 'pineapple' }, { emoji: '🥥', name: 'coconut' }, { emoji: '🥝', name: 'kiwi fruit' }, { emoji: '🍅', name: 'tomato' }, { emoji: '🍆', name: 'eggplant' }, { emoji: '🥑', name: 'avocado' }, { emoji: '🥦', name: 'broccoli' }, { emoji: '🥬', name: 'leafy greens' }, { emoji: '🥒', name: 'cucumber' }, { emoji: '🌶️', name: 'hot pepper' }, { emoji: '🫑', name: 'bell pepper' }, { emoji: '🌽', name: 'ear of corn' }, { emoji: '🥕', name: 'carrot' }, { emoji: '🫒', name: 'olive' }, { emoji: '🧄', name: 'garlic' }, { emoji: '🧅', name: 'onion' }, { emoji: '🥔', name: 'potato' } ], COLUMNS ) } ]; private readonly emojiByName = new Map( this.groups.flatMap((group) => group.rows.flat()).map((item) => [item.name, item.emoji]) ); /** On selection (`item-press`) insert the emoji; otherwise update the search query. */ onSearch(details: AutocompleteValueChangeDetails): void { if (details.reason === 'item-press') { details.eventDetails.cancel(); this.open.set(false); const emoji = this.emojiByName.get(details.value); if (emoji) { this.insert(emoji); } return; } this.search.set(details.value); } private insert(emoji: string): void { const input = this.message()?.nativeElement; if (!input) { return; } const start = input.selectionStart ?? input.value.length; const end = input.selectionEnd ?? input.value.length; input.value = input.value.slice(0, start) + emoji + input.value.slice(end); const caret = start + emoji.length; input.setSelectionRange(caret, caret); // Focus the message field synchronously inside the `onValueChange` callback. The autocomplete // detects that the consumer moved focus and skips its own restoration, so this just works. input.focus(); this.open.set(false); } /** Reset the search query once the popup has fully closed. */ onOpenComplete(open: boolean): void { if (!open) { this.search.set(''); } } } ``` ### Controlled open state When the app owns `open`, listen to `(onOpenChange)` instead of treating it like a plain boolean output. Popup primitives emit a change object with `reason`, `event`, and cancellable `eventDetails`. ```ts protected readonly open = signal(false); protected onOpenChange(change: { open: boolean; eventDetails: { cancel(): void } }) { if (!change.open && this.shouldStayOpenWhileLoading) { change.eventDetails.cancel(); return; } this.open.set(change.open); } ``` ### Virtualized `virtualized` + `[items]` drives index-based navigation over a large data source while a virtualizer renders only the visible window. ```typescript import { ChangeDetectionStrategy, Component, ElementRef, signal, viewChild } from '@angular/core'; import { AutocompleteItemHighlightedDetails, RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; import { injectVirtualizer } from '@tanstack/angular-virtual'; /** * Externally virtualized list of 10,000 items. The autocomplete owns filtering and index navigation * (`virtualized` + `[items]`); `@tanstack/angular-virtual` renders only the visible window. On each * keyboard/programmatic highlight change the demo scrolls the target index into view so the * highlighted row mounts before `aria-activedescendant` references it. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-virtualized-example', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty ], template: `
No items found.
@for (row of virtualizer.getVirtualItems(); track row.key) {
{{ ac.filteredItems()[row.index] }}
}
` }) export class AutocompleteVirtualizedExample { readonly value = signal(''); /** 10,000 string items — labels double as filter text, so no `itemToStringValue` is needed here. */ protected readonly items = Array.from( { length: 10000 }, (_, index) => `Item ${String(index + 1).padStart(5, '0')}` ); private readonly scrollEl = viewChild>('scroll'); private readonly root = viewChild(RdxAutocompleteRoot); protected readonly virtualizer = injectVirtualizer(() => ({ count: this.root()?.filteredItems().length ?? 0, estimateSize: () => 36, overscan: 12, getItemKey: (index: number) => index, scrollElement: this.scrollEl() })); onHighlight(details: AutocompleteItemHighlightedDetails): void { if (details.index < 0 || details.reason === 'pointer') { return; } queueMicrotask(() => this.virtualizer.scrollToIndex(details.index, { align: 'auto' })); } } ``` ### Reactive forms The form value is the input string. Bind `[formControl]` to the root. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; /** * Reactive forms: the form value **is** the input string (typed or selected). Bind `[formControl]` * directly to the root. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-reactive-forms', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty, ReactiveFormsModule ], template: `
@for (item of fruits; track item) {
{{ item }}
}
No fruit found.

Value: {{ fruit.value || '—' }}

` }) export class AutocompleteReactiveForms { readonly fruit = new FormControl('Banana'); readonly fruits = ['Apple', 'Banana', 'Blueberry', 'Grape', 'Orange']; } ``` ### Template-driven forms `[(ngModel)]` binds the input string two-way. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; /** * Template-driven forms: `[(ngModel)]` binds the input string two-way. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-template-forms', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty, FormsModule ], template: `
@for (item of fruits; track item) {
{{ item }}
}
No fruit found.

Value: {{ value() || '—' }}

` }) export class AutocompleteTemplateForms { readonly value = signal(''); readonly fruits = ['Apple', 'Banana', 'Blueberry', 'Grape', 'Orange']; } ``` ### Validation Bind the control's validity to `[invalid]` so the input reflects `data-invalid` / `aria-invalid`; the error message and submit guard follow the standard reactive-forms pattern. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms'; import { RdxAutocompleteEmpty, RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; /** * Reactive forms with validation. The form value **is** the input string; its validity is bound to the * autocomplete `[invalid]` input, so the input reflects `data-invalid` / `aria-invalid` and the control * shows a destructive ring once touched. The error message and submit guard follow the standard pattern. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-validation', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem, RdxAutocompleteEmpty, ReactiveFormsModule ], template: `
@for (item of fruits; track item) {
{{ item }}
}
No fruit found.
@if (showError()) {

Please enter a fruit.

} @if (submitted()) {

Submitted ✓

}
` }) export class AutocompleteValidation { readonly fruit = new FormControl('', { validators: Validators.required }); readonly fruits = ['Apple', 'Banana', 'Blueberry', 'Grape', 'Orange']; readonly submitted = signal(false); protected showError(): boolean { return this.fruit.invalid && this.fruit.touched; } onSubmit(): void { if (this.fruit.invalid) { this.fruit.markAsTouched(); this.submitted.set(false); return; } this.submitted.set(true); } } ``` ### Disabled ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { RdxAutocompleteInput, RdxAutocompleteInputGroup, RdxAutocompleteItem, RdxAutocompleteList, RdxAutocompletePopup, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompleteRoot } from '@radix-ng/primitives/autocomplete'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'autocomplete-disabled', imports: [ RdxAutocompleteRoot, RdxAutocompleteInputGroup, RdxAutocompleteInput, RdxAutocompletePortal, RdxAutocompletePositioner, RdxAutocompletePopup, RdxAutocompleteList, RdxAutocompleteItem ], template: `
@for (fruit of fruits; track fruit) {
{{ fruit }}
}
` }) export class AutocompleteDisabled { readonly value = signal('Apple'); readonly fruits = ['Apple', 'Banana', 'Grape']; } ``` ## Accessibility Implements the WAI-ARIA [combobox](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/) pattern. DOM focus stays on the input; the active option is referenced with `aria-activedescendant`. With `readOnly`, the popup can still be opened and browsed using the list/grid rules below, while typing and item activation preserve the value. The input exposes native `readonly`, `aria-readonly="true"` and `aria-autocomplete="none"`; the listbox also exposes `aria-readonly`, while a grid leaves editability on the input. Enabling read-only discards a pending inline completion. Restoring editability keeps it discarded until a new input or keyboard navigation interaction. Enter with a highlighted item is consumed; without a highlight it retains native form submission. ### Keyboard interactions | Key | Behavior | | --- | --- | | `ArrowDown` / `ArrowUp` | In a list, open the popup; with auto-highlight off, opening leaves the highlight empty. Subsequent arrows navigate items. Closed grids keep their native input behavior. | | `ArrowLeft` / `ArrowRight` | In an open grid with a highlighted cell, navigate horizontally following `dir`. Otherwise move the text caret. | | `Home` / `End` | Move the text caret to an input boundary, including in grids. | | `Enter` | Activate the highlighted item. Without a highlight, non-inline modes close the popup and allow native form submission. | | `Space` | When the open input is empty, activate the highlighted item or leave an empty highlight unchanged. With text, insert a space. | | `Escape` | Close the popup; when already closed and unmounted, clear the text. | | `Tab` | Dismiss a mounted popup and allow native focus movement. | With `loopFocus`, navigation passes through an empty highlight when auto-highlight is off. With `loopFocus=false`, navigation stops at the boundary. Disabled items can be highlighted with arrows but cannot be activated. `autoHighlight="always"` starts at the first item; `autoHighlight=true` highlights the opening edge and updates the highlight on input changes. ## Example files Install `match-sorter`, `@tanstack/angular-virtual` when an example imports them. ## API Reference ### RdxAutocompleteRoot The root. Owns the value (the input string), open state, filtering, inline completion, and navigation. `defaultValue` and `defaultOpen` initialize an uncontrolled Root once. Explicit values, including `value=""` and `[open]="false"`, take precedence. A value supplied by Angular Forms also takes precedence, including an empty value. Later default changes do not refill a cleared input or reopen a closed popup. Use `[(value)]` / `[(open)]` or the form control for live application state. `onValueChange` emits `{ value, reason, eventDetails }` and is cancelable via `eventDetails.cancel()`. ### RdxAutocompleteInput The text input. Holds focus; in `both` / `inline` modes it shows the inline completion. | Attribute | Present when | | ----------------- | ------------------------------------ | | `data-popup-open` | The popup is open. | | `data-list-empty` | No matching suggestions are visible. | | `data-filled` | The input contains a value. | | `data-disabled` | The input is disabled. | | `data-invalid` | Displayed validation is invalid. | | `data-valid` | Displayed validation is valid. | | `data-required` | The input is required. | | `data-focused` | The input is focused. | | `data-touched` | The input has been touched. | | `data-dirty` | The input value has changed. | ### RdxAutocompleteItem A selectable suggestion. `value` is optional and defaults to the option's text. | Attribute | Present when | | ------------------ | ------------------------------- | | `data-highlighted` | The suggestion is highlighted. | | `data-disabled` | The suggestion is disabled. | | `data-hidden` | The suggestion is filtered out. | Items have no `data-selected`: autocomplete does not commit a selection. ### RdxAutocompletePopup The popup surface. Apply to a container element (typically a `
`). | Attribute | Present when / value | | --------------------- | ------------------------------------ | | `data-open` | The popup is open. | | `data-closed` | The popup is closed. | | `data-empty` | No matching suggestions are visible. | | `data-side` | The resolved placement side. | | `data-align` | The resolved placement alignment. | | `data-starting-style` | The enter transition is starting. | | `data-ending-style` | The exit transition is running. | ### RdxAutocompletePositioner Positions the popup against the input anchor via the popper engine. ### RdxAutocompleteValue Renders the current value as text (with a `placeholder` when empty). Other parts (`Portal` (structural), `Backdrop`, `Popup`, `List`, `Row`, `Group`, `GroupLabel`, `ItemIndicator`, `Empty`, `Status`, `Trigger`, `Icon`, `Clear`, `Label`, `Anchor`, `InputGroup`, `Arrow` (re-exposes `width` / `height`; carries `data-uncentered` when it can no longer be centered on the anchor — it stays visible rather than disappearing)) read everything from context and take no inputs of their own. --- # Avatar #### An image element with a fallback for representing the user. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarRootDirective } from '@radix-ng/primitives/avatar'; const IMG_COLM = 'https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80'; const IMG_PEDRO = 'https://images.unsplash.com/photo-1511485977113-f34c92461ad9?ixlib=rb-1.2.1&w=128&h=128&dpr=2&q=80'; /** * Image avatars with an initials fallback shown only if the image is slow to load. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-demo', imports: [RdxAvatarRootDirective, RdxAvatarImageDirective, RdxAvatarFallbackDirective], template: `
Colm Tuite CT Pedro Duarte PD
` }) export class RdxAvatarDemoComponent { protected readonly imgColm = IMG_COLM; protected readonly imgPedro = IMG_PEDRO; } ``` ## Features - ✅ Automatic and manual control over when the image renders. - ✅ Fallback part accepts any children. - ✅ Optionally delay fallback rendering to avoid content flashing. ## Import ```typescript import { RdxAvatarRootDirective, RdxAvatarImageDirective, RdxAvatarFallbackDirective } from '@radix-ng/primitives/avatar'; ``` ## Anatomy Assemble the parts: a root, the image, and a fallback shown until the image loads. ```html ... AB ``` ## Global configuration Configure the default options for all avatars with `provideRdxAvatarConfig` in a providers array. ```ts import { provideRdxAvatarConfig } from '@radix-ng/primitives/avatar'; bootstrapApplication(AppComponent, { providers: [provideRdxAvatarConfig({ delayMs: 1000 })] }); ``` ## Examples Example setup ### Default ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarRootDirective } from '@radix-ng/primitives/avatar'; const IMG_COLM = 'https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80'; const IMG_PEDRO = 'https://images.unsplash.com/photo-1511485977113-f34c92461ad9?ixlib=rb-1.2.1&w=128&h=128&dpr=2&q=80'; /** * Image avatars with an initials fallback shown only if the image is slow to load. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-demo', imports: [RdxAvatarRootDirective, RdxAvatarImageDirective, RdxAvatarFallbackDirective], template: `
Colm Tuite CT Pedro Duarte PD
` }) export class RdxAvatarDemoComponent { protected readonly imgColm = IMG_COLM; protected readonly imgPedro = IMG_PEDRO; } ``` ### Sizes `sm`, `md`, and `lg` from the demo style layer. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarRootDirective } from '@radix-ng/primitives/avatar'; const IMG_COLM = 'https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80'; const AVATAR_DIRECTIVES = [RdxAvatarRootDirective, RdxAvatarImageDirective, RdxAvatarFallbackDirective]; /** * The same avatar at the three sizes from the style layer. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-sizes', imports: AVATAR_DIRECTIVES, template: `
Colm Tuite CT Colm Tuite CT Colm Tuite CT
` }) export class RdxAvatarSizesComponent { protected readonly img = IMG_COLM; } /** * The fallback renders when there is no image or the image fails to load. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-fallback', imports: AVATAR_DIRECTIVES, template: `
PD Broken JD
` }) export class RdxAvatarFallbackComponent {} /** * `delayMs` waits before showing the fallback, so it only appears on slower * connections (here the image never loads, so the fallback appears after 600ms). */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-delay', imports: AVATAR_DIRECTIVES, template: ` Slow RN ` }) export class RdxAvatarDelayComponent {} ``` ### Fallback The fallback renders when there is no image or the image fails to load. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarRootDirective } from '@radix-ng/primitives/avatar'; const IMG_COLM = 'https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80'; const AVATAR_DIRECTIVES = [RdxAvatarRootDirective, RdxAvatarImageDirective, RdxAvatarFallbackDirective]; /** * The same avatar at the three sizes from the style layer. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-sizes', imports: AVATAR_DIRECTIVES, template: `
Colm Tuite CT Colm Tuite CT Colm Tuite CT
` }) export class RdxAvatarSizesComponent { protected readonly img = IMG_COLM; } /** * The fallback renders when there is no image or the image fails to load. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-fallback', imports: AVATAR_DIRECTIVES, template: `
PD Broken JD
` }) export class RdxAvatarFallbackComponent {} /** * `delayMs` waits before showing the fallback, so it only appears on slower * connections (here the image never loads, so the fallback appears after 600ms). */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-delay', imports: AVATAR_DIRECTIVES, template: ` Slow RN ` }) export class RdxAvatarDelayComponent {} ``` ### Delayed fallback `delayMs` waits before showing the fallback, so it only appears for slower connections. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarRootDirective } from '@radix-ng/primitives/avatar'; const IMG_COLM = 'https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80'; const AVATAR_DIRECTIVES = [RdxAvatarRootDirective, RdxAvatarImageDirective, RdxAvatarFallbackDirective]; /** * The same avatar at the three sizes from the style layer. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-sizes', imports: AVATAR_DIRECTIVES, template: `
Colm Tuite CT Colm Tuite CT Colm Tuite CT
` }) export class RdxAvatarSizesComponent { protected readonly img = IMG_COLM; } /** * The fallback renders when there is no image or the image fails to load. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-fallback', imports: AVATAR_DIRECTIVES, template: `
PD Broken JD
` }) export class RdxAvatarFallbackComponent {} /** * `delayMs` waits before showing the fallback, so it only appears on slower * connections (here the image never loads, so the fallback appears after 600ms). */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-avatar-delay', imports: AVATAR_DIRECTIVES, template: ` Slow RN ` }) export class RdxAvatarDelayComponent {} ``` ## API Reference ### Root `RdxAvatarRootDirective` — provides the shared image loading status. Apply to a ``. It takes no inputs and exposes no data attributes (matching Base UI, which surfaces the loading status through the context, not the DOM). ### Image `RdxAvatarImageDirective` — apply to an ``. It loads the image off-DOM and reveals it only once loaded; it carries no role (the native `` role is used) and no data attributes. ### Fallback `RdxAvatarFallbackDirective` — apply to a ``. Shown until the image loads (optionally after `delayMs`). It exposes no data attributes. ## Accessibility Give the `` a meaningful `alt`, and put a meaningful label in the fallback (e.g. the person's name rather than bare initials) so it remains understandable to assistive technology when the image fails to load. --- # Button #### A button, or any element that should behave like one. Headless button behavior modeled on [Base UI](https://base-ui.com/)'s `useButton`. It carries no styles — visual variants in the examples come from the centralized demo style layer (see the **Guides/Styling** page). ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxButtonDirective } from '@radix-ng/primitives/button'; /** * Shared button variants applied on top of the headless `rdxButton` directive. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-button-variants', imports: [RdxButtonDirective], template: `
` }) export class RdxButtonVariantsComponent {} ``` ## Features - ✅ Works on a native ` ... ``` Standalone Button activates Space on keyup. With `rdxCompositeItem` or `rdxToolbarButton`, it uses the item's roving tabindex and activates Space on keydown. Toolbar group/root disabled state is inherited when both `rdxToolbarButton` and `rdxButton` are applied to the same element. Consumer `keydown` / `keyup` handlers run before Button's keyboard behavior. Preventing Enter keydown or standalone Space keyup cancels activation; composite Space follows its keydown policy. Explicit `role` and `tabindex` override the defaults, including disabled and roving tab order. For dynamic values, bind `[role]` and `[tabIndex]`: `null` removes the attribute and `undefined` restores the default. An explicit tab index makes the application responsible for the tab order. ## Examples Example setup ### Default The preview above uses this standalone component. Copy the setup and shared files below as well. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxButtonDirective } from '@radix-ng/primitives/button'; @Component({ host: { class: 'contents' }, changeDetection: ChangeDetectionStrategy.OnPush, selector: 'rdx-button-default-example', imports: [RdxButtonDirective], template: ` ` }) export class ButtonDefaultStory {} ``` ### Variants Visual variants — `primary`, `secondary`, `outline`, `ghost`, and `destructive` — use `.demo-button` with the matching `.demo-button-*` recipe from the shared components layer. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxButtonDirective } from '@radix-ng/primitives/button'; /** * Shared button variants applied on top of the headless `rdxButton` directive. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-button-variants', imports: [RdxButtonDirective], template: `
` }) export class RdxButtonVariantsComponent {} ``` ### Sizes `sm`, `md`, `lg`, and a square `icon` size. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { LucidePlus } from '@lucide/angular'; import { RdxButtonDirective } from '@radix-ng/primitives/button'; /** * Sizes, including a square icon button. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-button-sizes', imports: [RdxButtonDirective, LucidePlus], template: `
` }) export class RdxButtonSizesComponent {} ``` ### Disabled The first button uses the native `disabled` attribute (removed from the tab order). The second sets `focusableWhenDisabled`, so it stays focusable via `aria-disabled` while its activation is suppressed. Disabled Button also suppresses consumer click, pointerdown, mousedown, keydown and keyup handlers. Tab and composite arrow navigation remain available; hover and release handlers remain available. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxButtonDirective } from '@radix-ng/primitives/button'; /** * Disabled handling. The first button uses the native `disabled` attribute * (removed from the tab order). The second sets `focusableWhenDisabled`, so it * stays focusable via `aria-disabled` while its activation is suppressed. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-button-disabled', imports: [RdxButtonDirective], template: `
` }) export class RdxButtonDisabledComponent {} ``` ### As link The directive applies button semantics to any element. Here an `` renders as a button while keeping native link behavior. Enter uses the browser's native link activation when `href` is present. Space prevents scrolling and activates on keyup. Keyboard events from a focusable descendant do not activate the outer button. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { RdxButtonDirective } from '@radix-ng/primitives/button'; /** * The directive works on any host. Here it renders an `` as a button while * keeping native link behavior. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-button-as-link', imports: [RdxButtonDirective], template: ` Open Base UI ` }) export class RdxButtonAsLinkComponent {} ``` ### Loading For buttons that enter a loading state after being clicked, set `disabled` while pending together with `focusableWhenDisabled` so focus stays on the button. Add `aria-busy` and render a spinner to communicate the state. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { LucideDynamicIcon, LucideLoaderCircle, LucideSave } from '@lucide/angular'; import { RdxButtonDirective } from '@radix-ng/primitives/button'; /** * Loading state. Following Base UI's guidance, the button becomes `disabled` * while loading but uses `focusableWhenDisabled` so focus stays on it. `aria-busy` * announces the pending state, and a spinner is rendered in place of the icon. */ @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'rdx-button-loading', imports: [RdxButtonDirective, LucideDynamicIcon], template: ` ` }) export class RdxButtonLoadingComponent { protected readonly loaderIcon = LucideLoaderCircle; protected readonly saveIcon = LucideSave; protected readonly loading = signal(false); protected run(): void { if (this.loading()) { return; } this.loading.set(true); setTimeout(() => this.loading.set(false), 2000); } } ``` ```html Docs ``` ## Example files Install `@lucide/angular` when an example imports it. ## API Reference `RdxButtonDirective` — headless button behavior. Apply to a native `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarDefault { date: DateValue = new CalendarDate(2024, 10, 3); } ``` ## Features - ✅ Full keyboard navigation. - ✅ Can be controlled or uncontrolled - ✅ Focus is fully managed - ✅ Localization support - ✅ Highly composable ## Preface The component depends on the [@internationalized/date package](https://react-spectrum.adobe.com/internationalized/date/index.html), which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Installation Install the date package. ```bash npm install @internationalized/date ``` Install the component from your command line. ```bash npm install @radix-ng/primitives ``` ## Anatomy Import all parts and piece them together. ```html
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
``` ## Example files Install `@internationalized/date`, `@lucide/angular` when an example imports them. ## API Reference ### Root `RdxCalendarRootDirective` Contains all the parts of a calendar ### Header `RdxCalendarHeaderDirective` Contains the navigation buttons and the heading segments. ### Prev Button `RdxCalendarPrevDirective` Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view. ### Next Button `RdxCalendarNextDirective` Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view. ### Heading `RdxCalendarHeadingDirective` Heading for displaying the current month and year. | exportAs | Description | | -------------- | ------------------------------- | | `headingValue` | `string` Current month and year | ### Grid `RdxCalendarGridDirective` Container for wrapping the calendar grid. | Data Attribute | Value | | ----------------- | --------------------- | | `[data-readonly]` | Present when readonly | | `[data-disabled]` | Present when disabled | ### Grid Head `RdxCalendarGridHeadDirective` Container for wrapping the grid head as `thead`. ### Grid Body `RdxCalendarGridBodyDirective` Container for wrapping the grid body as `tbody`. ### Grid Row `RdxCalendarGridRowDirective` Container for wrapping the grid row as `tr`. ### Head Cell `RdxCalendarHeadCellDirective` Container for wrapping the head cell. Used for displaying the week days as `th`. ### Cell `RdxCalendarCellDirective` Container for wrapping the calendar cells as `td`. | Data Attribute | Value | | ----------------- | --------------------- | | `[data-disabled]` | Present when disabled | ### Cell Trigger `RdxCalendarCellTriggerDirective` Interactable container for displaying the cell dates. Clicking it selects the date. | Data Attribute | Value | | ----------------------------- | ----------------------------------------------------------------------------- | | `[data-selected]` | Present when selected | | `[data-value]` | The ISO string value of the date. | | `[data-disabled]` | Present when disabled | | `[data-unavailable]` | Present when unavailable | | `[data-today]` | Present when today | | `[data-outside-view]` | Present when the date is outside the current month it is displayed in. | | `[data-outside-visible-view]` | Present when the date is outside the months that are visible on the calendar. | | `[data-focused]` | Present when focused | ## Examples
Example setup ### Default The preview above uses this standalone component. Copy the setup and shared files below as well. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { CalendarDate, DateValue } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-default', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarDefault { date: DateValue = new CalendarDate(2024, 10, 3); } ``` ### Calendar with Locale and Calendar System Selection This example showcases some of the available locales and how the calendar systems are displayed. ```typescript import { ChangeDetectionStrategy, Component, computed, signal } from '@angular/core'; import { CalendarIdentifier, createCalendar, getLocalTimeZone, toCalendar, today } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-with-locale', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarWithLocale { readonly preferences = [ { locale: 'en-US', label: 'Default', ordering: 'gregory' }, { label: 'Arabic (Algeria)', locale: 'ar-DZ', territories: 'DJ DZ EH ER IQ JO KM LB LY MA MR OM PS SD SY TD TN YE', ordering: 'gregory islamic islamic-civil islamic-tbla' }, { label: 'Arabic (United Arab Emirates)', locale: 'ar-AE', territories: 'AE BH KW QA', ordering: 'gregory islamic-umalqura islamic islamic-civil islamic-tbla' }, { label: 'Arabic (Egypt)', locale: 'AR-EG', territories: 'EG', ordering: 'gregory coptic islamic islamic-civil islamic-tbla' }, { label: 'Arabic (Saudi Arabia)', locale: 'ar-SA', territories: 'SA', ordering: 'islamic-umalqura gregory islamic islamic-rgsa' }, { label: 'Farsi (Iran)', locale: 'fa-IR', territories: 'IR', ordering: 'persian gregory islamic islamic-civil islamic-tbla' }, { label: 'Farsi (Afghanistan)', locale: 'fa-AF', territories: 'AF IR', ordering: 'persian gregory islamic islamic-civil islamic-tbla' }, { label: 'Amharic (Ethiopia)', locale: 'am-ET', territories: 'ET', ordering: 'gregory ethiopic ethioaa' }, { label: 'Hebrew (Israel)', locale: 'he-IL', territories: 'IL', ordering: 'gregory hebrew islamic islamic-civil islamic-tbla' }, { label: 'Hindi (India)', locale: 'hi-IN', territories: 'IN', ordering: 'gregory indian' }, { label: 'Japanese (Japan)', locale: 'ja-JP', territories: 'JP', ordering: 'gregory japanese' }, { label: 'Thai (Thailand)', locale: 'th-TH', territories: 'TH', ordering: 'buddhist gregory' }, { label: 'Chinese (Taiwan)', locale: 'zh-TW', territories: 'TW', ordering: 'gregory roc chinese' } ]; readonly calendars = [ { key: 'gregory', name: 'Gregorian' }, { key: 'japanese', name: 'Japanese' }, { key: 'buddhist', name: 'Buddhist' }, { key: 'roc', name: 'Taiwan' }, { key: 'persian', name: 'Persian' }, { key: 'indian', name: 'Indian' }, { key: 'islamic-umalqura', name: 'Islamic (Umm al-Qura)' }, { key: 'islamic-civil', name: 'Islamic Civil' }, { key: 'islamic-tbla', name: 'Islamic Tabular' }, { key: 'hebrew', name: 'Hebrew' }, { key: 'coptic', name: 'Coptic' }, { key: 'ethiopic', name: 'Ethiopic' }, { key: 'ethioaa', name: 'Ethiopic (Amete Alem)' } ]; readonly locale = signal(this.preferences[0].locale); readonly calendar = signal(this.calendars[0].key); readonly pref = computed(() => this.preferences.find((p) => p.locale === this.locale())); readonly preferredCalendars = computed(() => { const currentPref = this.pref(); return currentPref ? currentPref.ordering .split(' ') .map((p) => this.calendars.find((c) => c.key === p)) .filter(Boolean) : [this.calendars[0]]; }); readonly value = computed(() => toCalendar(today(getLocalTimeZone()), createCalendar(this.calendar() as CalendarIdentifier)) ); updateLocale(event: Event) { const newLocale = (event.target as HTMLSelectElement).value; this.locale.set(newLocale); this.calendar.set(this.pref()!.ordering.split(' ')[0]); } updateCalendar(event: Event) { this.calendar.set((event.target as HTMLSelectElement).value); } } ``` ### Multiple selection Set `multiple` to let the calendar hold an array of selected dates; clicking a selected date deselects it. ```typescript import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; import { CalendarDate } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-multiple', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarMultiple { readonly value = signal([new CalendarDate(2025, 1, 15), new CalendarDate(2025, 1, 20)]); } ``` ### Week numbers Render an extra leading column with the ISO week number via `getWeekNumber`. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { CalendarDate, DateValue } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; import { getWeekNumber } from '@radix-ng/primitives/core'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-week', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) {
{{ getWeekNumber(weekDates[0]) }}
@for (weekDate of weekDates; track $index) { } } }
Wk{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarWeek { date: DateValue = new CalendarDate(2024, 10, 3); protected readonly getWeekNumber = getWeekNumber; } ``` ### Disabled dates Pass an `isDateDisabled` matcher — a `(date) => boolean` callback run for every rendered date. Disabled dates are not focusable or selectable. This example disables weekends. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { CalendarDate, DateValue, isWeekend } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-disabled-dates', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarDisabledDates { date: DateValue = new CalendarDate(2024, 10, 3); /** Disable weekends — the matcher runs for every rendered date. */ readonly isDateDisabled = (date: DateValue): boolean => isWeekend(date, 'en-US'); } ``` ### Unavailable dates `isDateUnavailable` is a `(date) => boolean` callback that marks dates as present-but-not-selectable (e.g. already booked). They render struck-through and ignore pointer interaction. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { CalendarDate, DateValue } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-unavailable-dates', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarUnavailableDates { date: DateValue = new CalendarDate(2024, 10, 3); /** Mark the 10th–14th as unavailable: rendered struck-through and not selectable. */ readonly isDateUnavailable = (date: DateValue): boolean => date.day >= 10 && date.day <= 14; } ``` ### Custom navigation Override how the previous/next buttons move the view with `propsPrevPage` / `propsNextPage` — each a `(placeholder) => DateValue` callback. This example jumps a whole year per click. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { CalendarDate, DateValue } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-custom-navigation', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } } }
{{ day }}
{{ cell.dayValue() }}
` }) export class CalendarCustomNavigation { date: DateValue = new CalendarDate(2024, 10, 3); /** The prev/next buttons jump a whole year instead of a month. */ readonly nextYear = (placeholder: DateValue): DateValue => placeholder.add({ years: 1 }); readonly prevYear = (placeholder: DateValue): DateValue => placeholder.subtract({ years: 1 }); } ``` ### Multiple months Set `numberOfMonths` to render several months at once. Arrow-key navigation flows across the page boundary between months, and (without `pagedNavigation`) the prev/next buttons shift the view by one month. ```typescript import { ChangeDetectionStrategy, Component } from '@angular/core'; import { CalendarDate, DateValue } from '@internationalized/date'; import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular'; import { RdxCalendarCellDirective, RdxCalendarCellTriggerDirective, RdxCalendarGridBodyDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarHeadCellDirective, RdxCalendarHeaderDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, RdxCalendarRootDirective } from '@radix-ng/primitives/calendar'; @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'app-calendar-number-of-months', imports: [ RdxCalendarRootDirective, RdxCalendarHeaderDirective, RdxCalendarGridDirective, RdxCalendarGridHeadDirective, RdxCalendarGridBodyDirective, RdxCalendarCellTriggerDirective, RdxCalendarCellDirective, RdxCalendarHeadCellDirective, RdxCalendarHeadingDirective, RdxCalendarNextDirective, RdxCalendarPrevDirective, LucideChevronLeft, LucideChevronRight ], template: `
{{ head.headingValue() }}
@for (month of root.months(); track $index) { @for (day of root.weekDays(); track $index) { } @for (weekDates of month.weeks; track $index) { @for (weekDate of weekDates; track $index) { } }
{{ day }}
{{ cell.dayValue() }}
}
` }) export class CalendarNumberOfMonths { date: DateValue = new CalendarDate(2024, 10, 3); } ``` ## Accessibility ### Keyboard Interactions | Key | Description | | ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | `Tab` | When focus moves onto the calendar, focuses the first navigation button. | | `Space` / `Enter` | When focus is on `CalendarNext` or `CalendarPrev`, navigates the calendar. Otherwise, selects the date. | | `ArrowLeft` / `ArrowRight` / `ArrowUp` / `ArrowDown` | When focus is on `CalendarCellTrigger`, navigates the dates, changing the month/year/decade if necessary. | --- # Checkbox #### A control that allows the user to toggle between checked and not checked. ```typescript import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { LucideCheck } from '@lucide/angular'; import { RdxCheckboxButtonDirective, RdxCheckboxIndicatorDirective, RdxCheckboxIndicatorPresenceDirective, RdxCheckboxRootDirective } from '@radix-ng/primitives/checkbox'; @Component({ host: { class: 'contents' }, changeDetection: ChangeDetectionStrategy.OnPush, selector: 'rdx-checkbox-default-example', imports: [ LucideCheck, RdxCheckboxButtonDirective, RdxCheckboxIndicatorDirective, RdxCheckboxIndicatorPresenceDirective, RdxCheckboxRootDirective ], template: `
` }) export class CheckboxDefaultStory { readonly readOnly = input(false); readonly disabled = input(false); } ``` ## Features - ✅ Full keyboard navigation. - ✅ Supports indeterminate state. - ✅ Can be controlled or uncontrolled. - ✅ Native form submission with an optional native input for constraint validation. - ✅ Base UI state hooks: `data-checked`, `data-unchecked`, and `data-indeterminate`. ## Import ```typescript import { RdxCheckboxRootDirective, RdxCheckboxButtonDirective, RdxCheckboxIndicatorDirective, RdxCheckboxIndicatorPresenceDirective, RdxCheckboxInputDirective } from '@radix-ng/primitives/checkbox'; ``` ## Anatomy Assemble the root, button trigger, and indicator. ```html
``` The root generates a native checkbox after browser rendering. It supports `required`, bubbling `input` and `change` events, and `FormData` when it has a name. Add an `` to control the input's placement or include it in server-rendered HTML. The authored input takes over automatically. ## Examples Example setup ### Default The preview above uses this standalone component. Copy the setup and shared files below as well. ```typescript import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { LucideCheck } from '@lucide/angular'; import { RdxCheckboxButtonDirective, RdxCheckboxIndicatorDirective, RdxCheckboxIndicatorPresenceDirective, RdxCheckboxRootDirective } from '@radix-ng/primitives/checkbox'; @Component({ host: { class: 'contents' }, changeDetection: ChangeDetectionStrategy.OnPush, selector: 'rdx-checkbox-default-example', imports: [ LucideCheck, RdxCheckboxButtonDirective, RdxCheckboxIndicatorDirective, RdxCheckboxIndicatorPresenceDirective, RdxCheckboxRootDirective ], template: `
` }) export class CheckboxDefaultStory { readonly readOnly = input(false); readonly disabled = input(false); } ``` ### Labeling Associate a standalone checkbox with a native `