@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
63 lines (62 loc) • 2.01 kB
TypeScript
import React from "react";
type VirtualFocusProps = {
children: React.ReactNode;
/**
* Whether to cause focus to loop around when it hits the first or last element
* @default false
**/
loop?: boolean;
};
/**
* A component that manages a virtual focus using the 'up' and 'down'
* arrow keys as well as selection with 'Return'.
*
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/virtualfocus)
* @see 🏷️ {@link AccordionProps}
*
* @example
* ```jsx
* <VirtualFocus>
* <VirtualFocus.Anchor
* role="combobox"
* onSelect={() => {
* console.log("you selected the anchor");
* }}
* onActive={() => {
* console.log("the anchor is now virtually focused");
* }}
* >
* <input type="text" />
* </VirtualFocus.Anchor>
* <VirtualFocus.Content>
* <VirtualFocus.Item
* onSelect={() => {
* console.log("you selected the item");
* }}
* onActive={() => {
* console.log("the item is now virtually focused");
* }}
* >
* <p>item 1</p>
* </VirtualFocus.Item>
* <VirtualFocus.Item
* onSelect={() => {
* console.log("you selected the item");
* }}
* onActive={() => {
* console.log("the item is now virtually focused");
* }}
* >
* <p>item 2</p>
* </VirtualFocus.Item>
* </VirtualFocus.Content>
* </VirtualFocus>
* ```
*/
export declare const VirtualFocus: {
({ children, loop }: VirtualFocusProps): React.JSX.Element;
Anchor: React.ForwardRefExoticComponent<import("./parts/VirtualFocusAnchor").VirtualFocusAnchorProps & React.RefAttributes<HTMLInputElement>>;
Item: React.ForwardRefExoticComponent<import("./parts/VirtualFocusItem").VirtualFocusItemProps & React.RefAttributes<HTMLElement>>;
Content: React.ForwardRefExoticComponent<import("./parts/VirtualFocusContent").VirtualFocusContentProps & React.RefAttributes<HTMLDivElement>>;
};
export default VirtualFocus;