Skip to main content
cngx-src documentation

CngxDensity

Directivev0.1.0

projects/core/theming/cngx-density.directive.ts

Import#

import { CngxDensity } from '@cngx/core'

Description#

Scopes the density preference to a subtree by reflecting [cngxDensity] onto the host [data-density] attribute. A section so marked overrides the root density set by provideDensity for its descendants - the escape hatch, not a per-component input.

<section cngxDensity="spacious"> ... </section>

The input is optional (a bare cngxDensity attribute binds the empty string, coerced to undefined), so it never asserts a required binding; an unset value leaves [data-density] off the host.

Metadata#

Host#

Index#

Inputs

HostBindings

Inputs#

input()
default
    undefined,    {      alias: 'cngxDensity',      transform: (value) => (value === '' ? undefined : value),    },  

HostBindings#

BindingExpression
[attr.data-density]density()