LayerHeader

PreviousNext

The header of a Layer — a centered heading between up to two round buttons

Search filters

'use client';

import { LayerHeader } from '@/ui/LayerHeader';

export function LayerHeaderDemo() {
  return (
    <div className="border-lightGrey w-full border">
      <LayerHeader
        hLevel={2}
        leftButton={{ label: 'Back', icon: 'ArrowDefaultLeft', onClick: () => {} }}
        rightButton={{ label: 'Close', icon: 'CrossDefault', onClick: () => {} }}
      >
        Search filters
      </LayerHeader>
    </div>
  );
}

Installation

npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/layer-header.json

Usage

<Layer /> renders its own LayerHeader. Use it directly to build a layer-like panel, like a sidebar or a bottom sheet.

import { LayerHeader } from '@/ui/LayerHeader';
 
export function Component() {
  return (
    <LayerHeader
      hLevel={2}
      leftButton={{ label: 'Back', icon: 'ArrowDefaultLeft', onClick: goBack }}
      rightButton={{ label: 'Close', icon: 'CrossDefault', onClick: close }}
    >
      Search filters
    </LayerHeader>
  );
}

API Reference

LayerHeader

Extra props are spread on the <header> element.

PropTypeDefaultDescription
childrenReactNodeundefinedContent of the heading.
hLevel1 | 2 | 3 | 4 | 5 | 61Level of the heading tag.
hAriaLevelnumberundefinedLevel announced to assistive technologies (aria-level), without changing the tag.
idstringundefinedPut on the heading, and used as aria-describedby of the buttons.
leftButtonLayerHeaderButtonPropsundefinedRound button pinned to the inline start.
rightButtonLayerHeaderButtonPropsundefinedRound button pinned to the inline end.
classNamestringundefinedClasses merged on the <header>.

LayerHeaderButtonProps

Any <button> attribute and Button prop is forwarded, except variant and theme.

PropTypeDefaultDescription
iconIconicNames(required)Icon of the round button.
labelstring(required)Accessible name of the button (aria-label).
onClickMouseEventHandler<HTMLButtonElement>(required)Click handler.

Notes

  • Centered heading: the buttons are absolutely positioned and the heading keeps a 56px inline padding, so it stays centered whether there are zero, one or two buttons, and long headings wrap instead of running under them.
  • RTL: the buttons use logical positions (start / end), so they swap sides in right-to-left layouts.
  • Accessible description: give the header an id to have a screen reader announce the heading after a button name, like "Close, Search filters".