Primitiveaction

Command

Stable

Paleta de comandos: uma busca sobre coisas a fazer e lugares aonde ir, conduzida pelo teclado — digitar estreita, as setas percorrem, Enter executa. É um Autocomplete sempre aberto que lista no lugar, com o primeiro resultado sempre destacado, e vive dentro de um dialog (CommandDialog, sobre Base UI Dialog) ou inline na página, com grupos, atalhos por linha e rodapé. Use o Command para executar ações e navegar; para escolher um valor de formulário, use o Combobox ou o Autocomplete.

Instalação

npx up-web-ds add command

Gera search para a biblioteca de ícones do projeto (components.json → iconLibrary).

Preview

Basic

Default

Nenhuma ação executada ainda.

Inline

Nenhuma ação executada ainda.

Empty

Nenhum comando encontrado.

All states

Basic

Default

Nenhuma ação executada ainda.

Inline

Nenhuma ação executada ainda.

Empty

Nenhum comando encontrado.

Usage

Imports de Command
import {
  Command,
  CommandDialog,
  CommandDialogPopup,
  CommandDialogTrigger,
  CommandEmpty,
  CommandInput,
  CommandItem,
  CommandList,
  CommandPanel,
} from '@/components/ui/command'
import { Button } from '@/components/ui/button'
Command
<CommandDialog>
  <CommandDialogTrigger render={<Button variant="outline" />}>
    Abrir paleta de comandos
  </CommandDialogTrigger>
  <CommandDialogPopup aria-label="Paleta de comandos">
    <Command>
      <CommandInput
        aria-label="Buscar um comando"
        placeholder="Buscar um comando…"
      />
      <CommandPanel>
        <CommandEmpty>Nenhum comando encontrado.</CommandEmpty>
        <CommandList>
          <CommandItem value="Abrir catálogo">Abrir catálogo</CommandItem>
          <CommandItem value="Copiar comando de instalação">
            Copiar comando de instalação
          </CommandItem>
          <CommandItem value="Validar o design system">
            Validar o design system
          </CommandItem>
        </CommandList>
      </CommandPanel>
    </Command>
  </CommandDialogPopup>
</CommandDialog>

Props

CommandDialog

Props de CommandDialog
PropTypeDefaultDescription
actionsRefReact.RefObject<DialogRootActions | null>sem valor padrãoA ref to imperative actions. - `unmount`: Manually unmounts the dialog. Call this after any externally controlled closing animation finishes. - `close`: Closes the dialog imperatively when called.
childrenReact.ReactNode | PayloadChildRenderFunction<Payload>sem valor padrãoThe content of the dialog. This can be a regular React node or a render function that receives the `payload` of the active trigger.
defaultOpenbooleanfalseWhether the dialog is initially open. To render a controlled dialog, use the `open` prop instead.
defaultTriggerIdstring | nullsem valor padrãoID of the trigger that the dialog is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open dialog.
disablePointerDismissalbooleanfalseWhether to prevent the dialog from closing on outside presses. For non-modal dialogs, this also prevents the dialog from closing when focus moves outside of it.
handleDialogHandle<Payload>sem valor padrãoA handle to associate the dialog with a trigger. If specified, allows external triggers to control the dialog's open state. Can be created with the Dialog.createHandle() method.
modalboolean | "trap-focus"trueDetermines if the dialog enters a modal state when open. - `true`: user interaction is limited to just the dialog: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed. - `'trap-focus'`: focus is trapped inside the dialog, but document page scroll is not locked and pointer interactions outside of it remain enabled. When `modal` is `true` or `'trap-focus'`, render `<Dialog.Close>` inside `<Dialog.Popup>` so touch screen readers can escape the popup.
onOpenChange((open: boolean, eventDetails: DialogRoot.ChangeEventDetails) => void)sem valor padrãoEvent handler called when the dialog is opened or closed.
onOpenChangeComplete((open: boolean) => void)sem valor padrãoEvent handler called after any animations complete when the dialog is opened or closed.
openbooleansem valor padrãoWhether the dialog is currently open.
triggerIdstring | nullsem valor padrãoID of the trigger that the dialog is associated with. This is useful in conjunction with the `open` prop to create a controlled dialog. There's no need to specify this prop when the dialog is uncontrolled (that is, when the `open` prop is not set).

Estende DialogRoot.Props<Payload>.

CommandDialogPortal

Props de CommandDialogPortal
PropTypeDefaultDescription
classNamestring | ((state: DialogPortalState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
containerHTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | nullsem valor padrãoA parent element to render the portal element into.
keepMountedbooleanfalseWhether to keep the portal mounted in the DOM while the popup is hidden.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogPortalState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: DialogPortalState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende P. Aceita também os atributos padrão de um elemento React (275 não listados).

CommandDialogTrigger

Props de CommandDialogTrigger
PropTypeDefaultDescription
classNamestring | ((state: DialogTriggerState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
handleDialogHandle<unknown>sem valor padrãoA handle to associate the trigger with a dialog. Can be created with the Dialog.createHandle() method.
idstringsem valor padrãoID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for the dialog in controlled mode (with the DialogRoot `triggerId` prop).
nativeButtonbooleantrueWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).
payloadunknownsem valor padrãoA payload to pass to the dialog when it is opened.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTriggerState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: DialogTriggerState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende CommandDialogPrimitive.Trigger.Props. Aceita também os atributos padrão de um elemento React (284 não listados).

CommandDialogClose

Props de CommandDialogClose
PropTypeDefaultDescription
classNamestring | ((state: DialogCloseState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
nativeButtonbooleantrueWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogCloseState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: DialogCloseState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende CommandDialogPrimitive.Close.Props. Aceita também os atributos padrão de um elemento React (285 não listados).

CommandDialogBackdrop

Props de CommandDialogBackdrop
PropTypeDefaultDescription
classNamestring | ((state: DialogBackdropState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
forceRenderbooleanfalseWhether the backdrop is forced to render even when nested.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogBackdropState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: DialogBackdropState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende CommandDialogPrimitive.Backdrop.Props. Aceita também os atributos padrão de um elemento React (275 não listados).

CommandDialogViewport

Props de CommandDialogViewport
PropTypeDefaultDescription
classNamestring | ((state: DialogViewportState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogViewportState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: DialogViewportState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende CommandDialogPrimitive.Viewport.Props. Aceita também os atributos padrão de um elemento React (275 não listados).

CommandDialogPopup

Props de CommandDialogPopup
PropTypeDefaultDescription
portalPropsDialogPortalPropssem valor padrãoProps for the portal the dialog renders into.
classNamestring | ((state: DialogPopupState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
finalFocusboolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | HTMLElement | null | void)sem valor padrãoDetermines the element to focus when the dialog is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, `null` to fall back to the default behavior, or `false`/`undefined` to do nothing.
initialFocusboolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | HTMLElement | null | void)sem valor padrãoDetermines the element to focus when the dialog is opened. By default, focus moves to the first tabbable element inside the popup, except when the dialog is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (first tabbable element or popup). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, `null` to fall back to the default behavior, or `false`/`undefined` to do nothing.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogPopupState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: DialogPopupState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende CommandDialogPrimitive.Popup.Props. Aceita também os atributos padrão de um elemento React (275 não listados).

Command

Props de Command
PropTypeDefaultDescription
actionsRefReact.RefObject<AutocompleteRootActions | null>sem valor padrãoA ref to imperative actions. - `unmount`: Manually unmounts the autocomplete. Call this after any externally controlled closing animation finishes.
autoHighlightboolean | "always"'always'Whether the first matching item is highlighted automatically. - `true`: highlight after the user types and keep the highlight while the query changes. - `'always'`: always highlight the first item.
childrenReact.ReactNodesem valor padrão
defaultOpenbooleanfalseWhether the popup is initially open. To render a controlled popup, use the `open` prop instead.
defaultValuestring | number | readonly string[]sem valor padrãoThe uncontrolled input value of the autocomplete when it's initially rendered. To render a controlled autocomplete, use the `value` prop instead.
disabledbooleanfalseWhether the component should ignore user interaction.
filter((itemValue: unknown, query: string, itemToString?: ((itemValue: unknown) => string) | undefined) => boolean) | nullsem valor padrãoFilter function used to match items vs input query.
filteredItemsreadonly any[] | readonly Group<any>[]sem valor padrãoFiltered items to display in the list. When provided, the list will use these items instead of filtering the `items` prop internally. Use when you want to control filtering logic externally with the `useFilter()` hook.
formstringsem valor padrãoIdentifies the form that owns the internal input. Useful when the autocomplete is rendered outside the form.
gridbooleanfalseWhether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.
highlightItemOnHoverbooleantrueWhether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.
idstringsem valor padrãoThe id of the component.
inlinebooleanfalseWhether the list is rendered inline without using the component's own popup. Specify `open` unconditionally in conjunction with this prop so the list is considered visible: `<Autocomplete.Root inline open>`
inputRefReact.Ref<HTMLInputElement>sem valor padrãoA ref to the hidden input element.
itemsreadonly unknown[]sem valor padrãoThe items to be displayed in the list. Can be either a flat array of items or an array of groups with items.
itemToStringValue((itemValue: unknown) => string)sem valor padrãoWhen the item values are objects (`<Autocomplete.Item value={object}>`), this function converts the object value to a string representation for both display in the input and form submission. If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop.
keepHighlightbooleantrueWhether the highlighted item should be preserved when the pointer leaves the list.
limitnumber-1The maximum number of items to display in the list.
localeIntl.LocalesArgumentsem valor padrãoThe locale to use for string comparison. Defaults to the user's runtime locale.
loopFocusbooleantrueWhether to loop keyboard focus back to the input when the end of the list is reached while using the arrow keys. The first item can then be reached by pressing <kbd>ArrowDown</kbd> again from the input, or the last item can be reached by pressing <kbd>ArrowUp</kbd> from the input. The input is always included in the focus loop per [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/). When disabled, focus does not move when on the last element and the user presses <kbd>ArrowDown</kbd>, or when on the first element and the user presses <kbd>ArrowUp</kbd>.
modalbooleanfalseDetermines if the popup enters a modal state when open. - `true`: user interaction is limited to the popup: document page scroll is locked and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed. On touch devices, a `true` modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior.
mode"none" | "list" | "inline" | "both"'list'Controls how the autocomplete behaves with respect to list filtering and inline autocompletion. - `list` (default): items are dynamically filtered based on the input value. The input value does not change based on the active item. - `both`: items are dynamically filtered based on the input value, which will temporarily change based on the active item (inline autocompletion). - `inline`: items are static (not filtered), and the input value will temporarily change based on the active item (inline autocompletion). - `none`: items are static (not filtered), and the input value will not change based on the active item.
namestringsem valor padrãoIdentifies the field when a form is submitted.
onItemHighlighted((highlightedValue: unknown, eventDetails: AutocompleteRootHighlightEventDetails) => void)sem valor padrãoCallback fired when an item is highlighted or unhighlighted. Receives the highlighted item value (or `undefined` if no item is highlighted) and event details with a `reason` property describing why the highlight changed. The `reason` can be: - `'keyboard'`: the highlight changed due to keyboard navigation. - `'pointer'`: the highlight changed due to pointer hovering. - `'none'`: the highlight changed programmatically.
onOpenChange((open: boolean, eventDetails: AutocompleteRootChangeEventDetails) => void)sem valor padrãoEvent handler called when the popup is opened or closed.
onOpenChangeComplete((open: boolean) => void)sem valor padrãoEvent handler called after any animations complete when the popup is opened or closed.
onValueChange((value: string, eventDetails: AutocompleteRootChangeEventDetails) => void)sem valor padrãoEvent handler called when the input value of the autocomplete changes.
openbooleansem valor padrãoWhether the popup is currently open. Use when controlled.
openOnInputClickbooleanfalseWhether the popup opens when clicking the input.
readOnlybooleanfalseWhether the user should be unable to choose a different option from the popup.
requiredbooleanfalseWhether the user must choose a value before submitting a form.
submitOnItemClickbooleanfalseWhether clicking an item should submit the autocomplete's owning form. By default, clicking an item via a pointer or <kbd>Enter</kbd> key does not submit the owning form. Useful when the autocomplete is used as a single-field form search input.
valuestring | number | readonly string[]sem valor padrãoThe input value of the autocomplete. Use when controlled.
virtualizedbooleanfalseWhether the items are being externally virtualized.

Estende React.ComponentProps<typeof Autocomplete>.

CommandInput

Props de CommandInput
PropTypeDefaultDescription
clearPropsComboboxClearPropssem valor padrãoProps for the clear button, including its accessible name.
showClearbooleanfalseRenders a button at the end of the field that clears the text. It appears only while there is text, and takes the trigger's place when both are on.
showTriggerbooleanfalseRenders a button at the end of the field that opens the suggestions. It is a pointer affordance: from the keyboard, ArrowDown opens the list.
sizenumber | "default" | "sm" | "lg"'default'Height of the field. A number is forwarded to the native `size` attribute (the width in characters) and keeps the default height.
startAddonReact.ReactNodesem valor padrãoContent drawn at the start of the field, usually an icon. Decorative.
triggerPropsAutocompleteTriggerPropssem valor padrãoProps for the trigger button, including its accessible name.
classNamestring | ((state: ComboboxInputState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
disabledbooleanfalseWhether the component should ignore user interaction.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxInputState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: ComboboxInputState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende React.ComponentProps<typeof AutocompleteInput>. Aceita também os atributos padrão de um elemento React (303 não listados).

CommandList

Props de CommandList
PropTypeDefaultDescription
childrenReact.ReactNode | ((item: any, index: number) => React.ReactNode)sem valor padrão
classNamestring | ((state: ComboboxListState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxListState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: ComboboxListState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende React.ComponentProps<typeof AutocompleteList>. Aceita também os atributos padrão de um elemento React (274 não listados).

CommandEmpty

Props de CommandEmpty
PropTypeDefaultDescription
classNamestring | ((state: ComboboxEmptyState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxEmptyState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: ComboboxEmptyState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende React.ComponentProps<typeof AutocompleteEmpty>. Aceita também os atributos padrão de um elemento React (275 não listados).

CommandPanel

Estende React.ComponentProps<'div'>. Aceita também os atributos padrão de um elemento React (280 não listados).

CommandGroup

Props de CommandGroup
PropTypeDefaultDescription
classNamestring | ((state: ComboboxGroupState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
itemsreadonly any[]sem valor padrãoItems to be rendered within this group. When provided, child `Collection` components will use these items.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: ComboboxGroupState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende React.ComponentProps<typeof AutocompleteGroup>. Aceita também os atributos padrão de um elemento React (275 não listados).

CommandGroupLabel

Props de CommandGroupLabel
PropTypeDefaultDescription
classNamestring | ((state: ComboboxGroupLabelState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupLabelState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: ComboboxGroupLabelState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende React.ComponentProps<typeof AutocompleteGroupLabel>. Aceita também os atributos padrão de um elemento React (275 não listados).

CommandCollection

Props de CommandCollection
PropTypeDefaultDescription
children, obrigatória(item: any, index: number) => React.ReactNodesem valor padrão

Estende ComboboxCollection.Props.

CommandItem

Props de CommandItem
PropTypeDefaultDescription
childrenReact.ReactNodesem valor padrão
classNamestring | ((state: AutocompleteItemState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
disabledbooleanfalseWhether the component should ignore user interaction.
indexnumbersem valor padrãoThe index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.
nativeButtonbooleanfalseWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button.
onClick((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void)sem valor padrãoAn optional click handler for the item when selected. It fires when clicking the item with the pointer, as well as when pressing `Enter` with the keyboard if the item is highlighted when the `Input` or `List` element has focus.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, AutocompleteItemState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: AutocompleteItemState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.
valueanynullA unique value that identifies this item.

Estende React.ComponentProps<typeof AutocompleteItem>. Aceita também os atributos padrão de um elemento React (272 não listados).

CommandSeparator

Props de CommandSeparator
PropTypeDefaultDescription
classNamestring | ((state: AutocompleteSeparatorState) => string | undefined)sem valor padrãoCSS class applied to the element, or a function that returns a class based on the component's state.
orientationOrientation'horizontal'The orientation of the separator.
renderReact.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, AutocompleteSeparatorState>sem valor padrãoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
styleReact.CSSProperties | ((state: AutocompleteSeparatorState) => React.CSSProperties | undefined)sem valor padrãoStyle applied to the element, or a function that returns a style object based on the component's state.

Estende React.ComponentProps<typeof AutocompleteSeparator>. Aceita também os atributos padrão de um elemento React (275 não listados).

CommandShortcut

Estende React.ComponentProps<'kbd'>. Aceita também os atributos padrão de um elemento React (280 não listados).

prop obrigatória.

Composition

No dialog, o Command vai dentro do CommandDialogPopup; inline, direto na página. O campo fica fora do painel, e o rodapé, quando existe, segue o painel.

Composição de CommandDialog

CommandDialog

  • CommandDialogTrigger
  • CommandDialogPopup
    • Command
      • CommandInput
      • CommandPanel
        • CommandEmpty
        • CommandList
          • CommandGroup
            • CommandGroupLabel
            • CommandCollection
              • CommandItem
                • CommandShortcut
          • CommandSeparator
      • CommandFooter
        • CommandDialogClose

Metadata

Notas de acessibilidade

Teclado verificado por teste, em jsdom e em navegador: o gatilho abre o dialog por clique e por Enter, o campo de busca recebe o foco ao abrir, digitar estreita a lista mantendo um resultado destacado, as setas percorrem sem tirar o foco do campo, Enter executa o comando destacado, e Escape fecha e devolve o foco ao gatilho. Na forma inline o campo não toma o foco ao carregar a página (autoFocus={false} no exemplo). O campo de busca não desenha anel de foco, como na origem: é o único alvo de foco da paleta, o cursor de texto e a linha destacada carregam a posição. Leitor de tela verificado por teste: o dialog é nomeado por aria-label em CommandDialogPopup (uma paleta não tem título visível), o campo é um combobox cujo aria-activedescendant acompanha o destaque, os grupos são nomeados pelo rótulo e somem quando nada neles casa, o estado vazio é anunciado por role="status", e o atalho de cada linha é um <kbd> que faz parte do nome da opção — o glifo (⌘) fica aria-hidden ao lado do nome falado. O restante da página sai da árvore de acessibilidade enquanto o dialog está aberto. CommandDialogClose foi acrescentado à API como saída para leitor de tela em toque, que não tem Escape nem clique fora. Touch verificado em navegador com emulação de toque em viewport de 375px: gatilho, opções e o botão de fechar ficam acima do mínimo de 24x24, o popup cabe na viewport, tocar numa opção a executa e tocar no scrim fecha. Reduced motion verificado em navegador com prefers-reduced-motion: reduce — a escala de entrada e saída e o deslocamento do empilhamento saem (motion-reduce:), e sob reduce a transition fica só na opacidade, que é o transitionend que o Base UI espera para desmontar; o dialog abre e fecha normalmente. Light e dark verificados pela varredura axe do catálogo e com o dialog aberto.

Classificação

Layer
Primitive
Domínio
Domain-free (compartilhado)
Categoria
action
Status
Stable

Origem e distribuição

Fonte
coss registry / command
Licença
MIT
Distribuição
Interna

Acessibilidade

  • Teclado: revisado
  • Leitor de tela: revisado
  • Touch: revisado
  • Reduced motion: revisado

Dependências

Pacotes
@base-ui/react
Ícones
search
Construído sobre
Autocomplete