Skip to main content

rc-app-bar

App bar modeled after the Material 3 Top app bar, with leading, title, center, trailing regions and optional scroll behavior.

Package
@rcarls/rc-app-bar
Element
<rc-app-bar>
Native dependency
Structural slots only; consumer supplies controls, icons, and landmarks
State model
Controlled or uncontrolled scrolled state
Main events
rc-app-bar-scroll

Installation

npm install @rcarls/rc-app-bar
import '@rcarls/rc-app-bar/define';

Live demo

Title app bar

Theming

The default demo mode shows the component without a package theme. Use the shared preview controls on this page to compare inherited, light, and dark color schemes or to apply the optional Material theme only inside the demo frames.

API

Properties

PropertyMarkupTypeDefaultDescription
variantvariantRCAppBarVariant'compact'Structural variant. `expanded` adds a flexible title row.
scrollBehaviorscroll-behaviorRCAppBarScrollBehavior'pinned'Visual response to observed scrolling.
scrollTargetscroll-targetScrollObserverTarget | string | nullnullScroll container to observe. The attribute accepts a CSS selector or `window`; the property also accepts an element, document, or window.
scrollThresholdscroll-thresholdnumber4Scroll offset in px past which the bar is scrolled (strict `>`).
scrolledJS property onlybooleanNot specifiedWhether the bar is past its scroll threshold. Host writes are silent and controlled; assigning `undefined` releases observation.
collapsedJS property onlybooleanNot specifiedWhether the expanded title row is currently collapsed.

Methods

No public methods are documented in the custom elements manifest.

Events

EventDetail typeDescription
rc-app-bar-scrollNo detail type documentedWhen observed scroll state crosses the threshold; `detail: { scrolled }`

Slots

NameDescription
leadingLeading navigation or controls; accepts multiple children
(default)The single title region; may contain title and subtitle markup
centerContent kept at the exact horizontal center, such as search
trailingTrailing action controls

CSS Custom Properties

PropertyDefaultDescription
--rc-app-bar-bgCanvasBar background
--rc-app-bar-colorCanvasTextBar text color
--rc-app-bar-compact-min-height3remCompact row minimum height
--rc-app-bar-expanded-padding-block0.75emExpanded title padding
--rc-app-bar-padding-inline0.75emHorizontal padding
--rc-app-bar-gap0.5emGap between regions
--rc-app-bar-transition-duration200msEndpoint and hide duration
--rc-app-bar-scroll-divider1px solid GrayTextScrolled divider
--rc-app-bar-collapse-progress0Collapse animation progress 0–1; read-only
--rc-app-bar-title-font-sizeNot specifiedCompact-row title font size (opt-in; inherits when unset)
--rc-app-bar-expanded-title-font-sizeNot specifiedExpanded-row title font size (opt-in)

CSS Parts

PartDescription
rootThe grid container
leadingWrapper around the leading slot
titleWrapper around the single title slot
centerWrapper around the centered slot
trailingWrapper around the trailing slot
scroll-shadowScrolled-state separator