GitHub

Menu

A menu is a floating panel that displays a list of actions or navigational items.

Components

DaffMenuComponent

import { DaffMenuComponent } from '@daffodil/design/menu'

The floating panel that contains menu items.

@Component()
class DaffMenuComponent implements AfterContentInit, AfterViewInit {}

DaffMenuItemComponent

import { DaffMenuItemComponent } from '@daffodil/design/menu'

Individual clickable items within the menu. Applied to <button> or <a> elements.

@Component()
class DaffMenuItemComponent implements FocusableOption {
  focus(): void
}

() Methods

focus
void

Focus the menu item.


Directives

DaffMenuActivatorDirective

import { DaffMenuActivatorDirective } from '@daffodil/design/menu'

Directive that triggers the menu to open/close. Applied to the button that activates the menu. The selector doubles as an input for the menu content to display.

@Directive()
class DaffMenuActivatorDirective implements OnDestroy {
  readonly isOpen: WritableSignal<boolean> = signal(false)

  daffMenuActivator: InputSignal<TemplateRef<unknown> | Type<unknown>>
  id: InputSignal<string>
  xPosition: InputSignal<DaffMenuXPosition> = 'after'
  yPosition: InputSignal<DaffMenuYPosition> = 'below'
}

Inputs

daffMenuActivator
InputSignal<TemplateRef<unknown> | Type<unknown>>
Default
Description

The menu content to display when activated.

id
InputSignal<string>
Default
Description

An optional ID for the activator. When set, the menu's ID is derived as ${id}-menu.

xPosition
InputSignal<DaffMenuXPosition>
Default'after'
Description

The horizontal alignment of the menu relative to the activator. Defaults to after.

yPosition
InputSignal<DaffMenuYPosition>
Default'below'
Description

The vertical position of the menu relative to the activator. Defaults to below.


Services

DaffMenuService

import { DaffMenuService } from '@daffodil/design/menu'

@Injectable()
class DaffMenuService {
  open$: Observable<boolean> = this.$_open.asObservable()

  close(): void
  open(
    activator: ViewContainerRef
    component: DaffMenuSlot
    config?: DaffMenuConfig
  ): void
}

() Methods

close
void
open
void
Parameters
Parameteractivator: ViewContainerRef
Description
Parametercomponent: DaffMenuSlot
Description
Parameterconfig: DaffMenuConfig
Description

Modules

DaffMenuModule

Deprecated

import { DaffMenuModule } from '@daffodil/design/menu'

@NgModule()
class DaffMenuModule {}

Providers

provideDaffMenuItemToken

import { provideDaffMenuItemToken } from '@daffodil/design/menu'

function provideDaffMenuItemToken<R extends T = T>(klass: Type<R>): ExistingProvider
Parameters
Parameterklass: Type<R>
Description

Tokens

DAFF_MENU_ITEM_TOKEN

import { DAFF_MENU_ITEM_TOKEN } from '@daffodil/design/menu'

const DAFF_MENU_ITEM_TOKEN: InjectionToken<any>

Types

DaffMenuConfig

import { DaffMenuConfig } from '@daffodil/design/menu'

Configuration for a menu instance.

interface DaffMenuConfig {
  menuId: string
  xPosition: DaffMenuXPosition
  yPosition: DaffMenuYPosition
}

Properties

menuId
string

A unique identifier for the menu instance.

xPosition
DaffMenuXPosition

The horizontal alignment of the menu relative to its activator. Defaults to after.

yPosition
DaffMenuYPosition

The vertical position of the menu relative to its activator. Defaults to below.


DaffMenuXPosition

import { DaffMenuXPosition } from '@daffodil/design/menu'

The horizontal alignment of the menu relative to its activator.

  • after lines the menu's left edge up with the activator's left edge.
  • before lines the menu's right edge up with the activator's right edge.
type DaffMenuXPosition = 'before' | 'after'

DaffMenuYPosition

import { DaffMenuYPosition } from '@daffodil/design/menu'

The vertical position of the menu relative to its activator.

  • below drops the menu down from the activator's bottom edge.
  • above raises the menu up from the activator's top edge.
type DaffMenuYPosition = 'above' | 'below'

DaffMenuSlot

import { DaffMenuSlot } from '@daffodil/design/menu'

type DaffMenuSlot = TemplateRef<unknown> | DaffLazyComponent | Type<unknown>